jasny /
auth
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace Jasny\Auth\User; |
||
| 6 | |||
| 7 | use AllowDynamicProperties; |
||
|
1 ignored issue
–
show
|
|||
| 8 | use Jasny\Auth\ContextInterface as Context; |
||
| 9 | use Jasny\Auth\UserInterface; |
||
| 10 | |||
| 11 | /** |
||
| 12 | * A simple user class which can be used instead of creating a custom user class. |
||
| 13 | */ |
||
| 14 | #[AllowDynamicProperties] |
||
| 15 | final class BasicUser implements UserInterface |
||
| 16 | { |
||
| 17 | public string|int $id; |
||
| 18 | protected string $hashedPassword = ''; |
||
| 19 | public string|int $role; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @inheritDoc |
||
| 23 | */ |
||
| 24 | public function getAuthId(): string |
||
| 25 | { |
||
| 26 | 1 | return (string)$this->id; |
|
| 27 | } |
||
| 28 | 1 | ||
| 29 | /** |
||
| 30 | * @inheritDoc |
||
| 31 | */ |
||
| 32 | public function verifyPassword(string $password): bool |
||
| 33 | { |
||
| 34 | 1 | return password_verify($password, $this->hashedPassword); |
|
| 35 | } |
||
| 36 | 1 | ||
| 37 | /** |
||
| 38 | * @inheritDoc |
||
| 39 | */ |
||
| 40 | public function getAuthChecksum(): string |
||
| 41 | { |
||
| 42 | 1 | return hash('sha256', $this->id . $this->hashedPassword); |
|
| 43 | } |
||
| 44 | 1 | ||
| 45 | /** |
||
| 46 | * @inheritDoc |
||
| 47 | */ |
||
| 48 | public function getAuthRole(?Context $context = null): string|int |
||
| 49 | { |
||
| 50 | 1 | return $this->role; |
|
| 51 | } |
||
| 52 | 1 | ||
| 53 | /** |
||
| 54 | * @inheritDoc |
||
| 55 | */ |
||
| 56 | public function requiresMfa(): bool |
||
| 57 | { |
||
| 58 | 1 | return false; |
|
| 59 | } |
||
| 60 | 1 | ||
| 61 | /** |
||
| 62 | * Factory method; create object from data loaded from DB. |
||
| 63 | * |
||
| 64 | * @param array<string,mixed> $data |
||
| 65 | * @return self |
||
| 66 | */ |
||
| 67 | public static function fromData(array $data): self |
||
| 68 | { |
||
| 69 | 2 | $user = new self(); |
|
| 70 | |||
| 71 | 2 | foreach ($data as $key => $value) { |
|
| 72 | $user->{$key} = $value; |
||
| 73 | 2 | } |
|
| 74 | 2 | ||
| 75 | return $user; |
||
| 76 | } |
||
| 77 | } |
||
| 78 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths