Skip to content

Commit

Permalink
Update Snapshots code with php 8.1 features
Browse files Browse the repository at this point in the history
  • Loading branch information
msmakouz committed Mar 28, 2022
1 parent 06a5b93 commit aa83ee1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 45 deletions.
37 changes: 6 additions & 31 deletions src/Snapshots/src/Snapshot.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
<?php

/**
* Spiral Framework.
*
* @license MIT
* @author Anton Titov (Wolfy-J)
*/

declare(strict_types=1);

namespace Spiral\Snapshots;
Expand All @@ -16,51 +9,33 @@
*/
final class Snapshot implements SnapshotInterface
{
/** @var string */
private $id;

/** @var \Throwable */
private $exception;

public function __construct(string $id, \Throwable $exception)
{
$this->id = $id;
$this->exception = $exception;
public function __construct(
private readonly string $id,
private readonly \Throwable $exception
) {
}

/**
* @inheritdoc
*/
public function getID(): string
{
return $this->id;
}

/**
* @inheritdoc
*/
public function getException(): \Throwable
{
return $this->exception;
}

/**
* @inheritdoc
*/
public function getMessage(): string
{
return sprintf(
return \sprintf(
'%s: %s in %s at line %s',
get_class($this->exception),
$this->exception::class,
$this->exception->getMessage(),
$this->exception->getFile(),
$this->exception->getLine()
);
}

/**
* @inheritdoc
*/
public function describe(): array
{
return [
Expand Down
7 changes: 0 additions & 7 deletions src/Snapshots/src/SnapshotInterface.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
<?php

/**
* Spiral Framework.
*
* @license MIT
* @author Anton Titov (Wolfy-J)
*/

declare(strict_types=1);

namespace Spiral\Snapshots;
Expand Down
7 changes: 0 additions & 7 deletions src/Snapshots/src/SnapshotterInterface.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
<?php

/**
* Spiral Framework.
*
* @license MIT
* @author Anton Titov (Wolfy-J)
*/

declare(strict_types=1);

namespace Spiral\Snapshots;
Expand Down

0 comments on commit aa83ee1

Please sign in to comment.