| Code Coverage | ||||||||||
| Lines | Functions and Methods | Classes and Traits | ||||||||
| Total |  | 0.00% | 0 / 8 |  | 0.00% | 0 / 3 | CRAP |  | 0.00% | 0 / 1 | 
| LaravelUserDecoratorIdentifier |  | 0.00% | 0 / 8 |  | 0.00% | 0 / 3 | 20 |  | 0.00% | 0 / 1 | 
| createFrom |  | 0.00% | 0 / 1 |  | 0.00% | 0 / 1 | 2 | |||
| convert |  | 0.00% | 0 / 6 |  | 0.00% | 0 / 1 | 6 | |||
| getReferenceFor |  | 0.00% | 0 / 1 |  | 0.00% | 0 / 1 | 2 | |||
| 1 | <?php | 
| 2 | |
| 3 | namespace Apie\LaravelApie\Wrappers\Security; | 
| 4 | |
| 5 | use Apie\Core\Identifiers\IdentifierInterface; | 
| 6 | use Apie\Core\ValueObjects\Exceptions\InvalidStringForValueObjectException; | 
| 7 | use Apie\Core\ValueObjects\IsStringValueObject; | 
| 8 | use Illuminate\Contracts\Auth\Authenticatable; | 
| 9 | use ReflectionClass; | 
| 10 | use Symfony\Component\Security\Core\User\UserInterface; | 
| 11 | |
| 12 | /** | 
| 13 | * @implements IdentifierInterface<LaravelUserDecorator> | 
| 14 | */ | 
| 15 | final class LaravelUserDecoratorIdentifier implements IdentifierInterface | 
| 16 | { | 
| 17 | use IsStringValueObject; | 
| 18 | |
| 19 | /** | 
| 20 | * @var class-string<UserInterface> | 
| 21 | */ | 
| 22 | private string $userClass; | 
| 23 | |
| 24 | private string $userId; | 
| 25 | |
| 26 | public static function createFrom(Authenticatable $user): self | 
| 27 | { | 
| 28 | return new self(get_class($user) . '@' . $user->getAuthIdentifier()); | 
| 29 | } | 
| 30 | |
| 31 | protected function convert(string $input): string | 
| 32 | { | 
| 33 | $split = explode('@', $input, 2); | 
| 34 | if (!class_exists($split[0])) { | 
| 35 | throw new InvalidStringForValueObjectException($input, $this); | 
| 36 | } | 
| 37 | $this->userClass = $split[0]; | 
| 38 | $this->userId = $split[1]; | 
| 39 | return $this->userClass . '@' . $this->userId; | 
| 40 | } | 
| 41 | |
| 42 | public static function getReferenceFor(): ReflectionClass | 
| 43 | { | 
| 44 | return new ReflectionClass(LaravelUserDecorator::class); | 
| 45 | } | 
| 46 | } |