Skip to content

Commit

Permalink
Updating Auth code with PHP 8.1 features (#608)
Browse files Browse the repository at this point in the history
  • Loading branch information
msmakouz authored Mar 24, 2022
1 parent 64d1049 commit 21b6b3c
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 87 deletions.
7 changes: 0 additions & 7 deletions src/Auth/src/ActorProviderInterface.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\Auth;
Expand Down
51 changes: 8 additions & 43 deletions src/Auth/src/AuthContext.php
Original file line number Diff line number Diff line change
@@ -1,41 +1,21 @@
<?php

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

declare(strict_types=1);

namespace Spiral\Auth;

final class AuthContext implements AuthContextInterface
{
/** @var ActorProviderInterface */
private $actorProvider;

/** @var TokenInterface|null */
private $token;

/** @var object|null */
private $actor;

/** @var string|null */
private $transport;

/** @var bool */
private $closed = false;

public function __construct(ActorProviderInterface $actorProvider)
{
$this->actorProvider = $actorProvider;
private ?TokenInterface $token = null;
private ?object $actor = null;
private ?string $transport = null;
private bool $closed = false;

public function __construct(
private readonly ActorProviderInterface $actorProvider
) {
}

/**
* @inheritDoc
*/
public function start(TokenInterface $token, string $transport = null): void
{
$this->closed = false;
Expand All @@ -44,25 +24,16 @@ public function start(TokenInterface $token, string $transport = null): void
$this->transport = $transport;
}

/**
* @inheritDoc
*/
public function getToken(): ?TokenInterface
{
return $this->token;
}

/**
* @inheritDoc
*/
public function getTransport(): ?string
{
return $this->transport;
}

/**
* @inheritDoc
*/
public function getActor(): ?object
{
if ($this->closed) {
Expand All @@ -76,18 +47,12 @@ public function getActor(): ?object
return $this->actor;
}

/**
* @inheritDoc
*/
public function close(): void
{
$this->closed = true;
$this->actor = null;
}

/**
* @inheritDoc
*/
public function isClosed(): bool
{
return $this->closed;
Expand Down
9 changes: 0 additions & 9 deletions src/Auth/src/AuthContextInterface.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\Auth;
Expand All @@ -18,8 +11,6 @@ interface AuthContextInterface
{
/**
* Start new auth context based on a given token. Actor can be received on demand.
*
* @param string|null $transport
*/
public function start(TokenInterface $token, string $transport = null): void;

Expand Down
7 changes: 0 additions & 7 deletions src/Auth/src/Exception/AuthException.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\Auth\Exception;
Expand Down
7 changes: 0 additions & 7 deletions src/Auth/src/Exception/TokenStorageException.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\Auth\Exception;
Expand Down
7 changes: 0 additions & 7 deletions src/Auth/src/TokenInterface.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\Auth;
Expand Down
7 changes: 0 additions & 7 deletions src/Auth/src/TokenStorageInterface.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\Auth;
Expand Down

0 comments on commit 21b6b3c

Please sign in to comment.