| Total Complexity | 9 |
| Total Lines | 71 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 17 | final class Authorization extends Entity |
||
| 18 | { |
||
| 19 | use UrlAwareTrait; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @var array |
||
| 23 | */ |
||
| 24 | protected $identifier; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @var string |
||
| 28 | */ |
||
| 29 | public $expires; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @var Challenge[] |
||
| 33 | */ |
||
| 34 | protected $challenges; |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @var bool |
||
| 38 | */ |
||
| 39 | public $wildcard; |
||
| 40 | |||
| 41 | public function __construct(array $data, string $url) |
||
| 42 | { |
||
| 43 | $this->wildcard = false; |
||
| 44 | |||
| 45 | $data['challenges'] = array_map(static function (array $entry) { |
||
| 46 | return new Challenge($entry); |
||
| 47 | }, $data['challenges']); |
||
| 48 | |||
| 49 | parent::__construct($data); |
||
| 50 | |||
| 51 | $this->url = $url; |
||
| 52 | } |
||
| 53 | |||
| 54 | /** |
||
| 55 | * @throws ChallengeException |
||
| 56 | */ |
||
| 57 | public function getHttpChallenge(): Challenge |
||
| 58 | { |
||
| 59 | foreach ($this->challenges as $challenge) { |
||
| 60 | if ($challenge->isHttp()) { |
||
| 61 | return $challenge; |
||
| 62 | } |
||
| 63 | } |
||
| 64 | throw new ChallengeException('http'); |
||
| 65 | } |
||
| 66 | |||
| 67 | /** |
||
| 68 | * @throws ChallengeException |
||
| 69 | */ |
||
| 70 | public function getDnsChallenge(): Challenge |
||
| 71 | { |
||
| 72 | foreach ($this->challenges as $challenge) { |
||
| 73 | if ($challenge->isDns()) { |
||
| 74 | return $challenge; |
||
| 75 | } |
||
| 76 | } |
||
| 77 | throw new ChallengeException('dns'); |
||
| 78 | } |
||
| 79 | |||
| 80 | public function getIdentifierValue(): string |
||
| 83 | } |
||
| 84 | |||
| 85 | public function isIdentifierValueEqual(string $identifier): bool |
||
| 86 | { |
||
| 90 |