Skip to content

Commit

Permalink
Update Snapshots code with php 8.1 features (#637)
Browse files Browse the repository at this point in the history
  • Loading branch information
msmakouz committed Apr 2, 2022
1 parent 002cbaf commit 0c85859
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 0c85859

Please sign in to comment.