| Total Complexity | 5 |
| Total Lines | 52 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | trait ValidatesInput |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * Resolve the nameIdFormat. |
||
| 14 | * |
||
| 15 | * @param string $option |
||
| 16 | * |
||
| 17 | * @return string|null |
||
| 18 | */ |
||
| 19 | protected function resolveNameIdFormat(string $option = 'nameIdFormat') |
||
| 20 | { |
||
| 21 | $value = $this->option($option) ?: 'persistent'; |
||
|
|
|||
| 22 | |||
| 23 | if ($this->validateNameIdFormat($value)) { |
||
| 24 | return $value; |
||
| 25 | } |
||
| 26 | |||
| 27 | $this->error('Name ID format is invalid. Supported values: ' . implode(', ', $this->supportedNameIdFormats())); |
||
| 28 | |||
| 29 | return null; |
||
| 30 | } |
||
| 31 | |||
| 32 | /** |
||
| 33 | * Validate Name ID format. |
||
| 34 | * |
||
| 35 | * @param string $format |
||
| 36 | * |
||
| 37 | * @return bool |
||
| 38 | */ |
||
| 39 | protected function validateNameIdFormat(string $format): bool |
||
| 40 | { |
||
| 41 | return in_array($format, $this->supportedNameIdFormats()); |
||
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * The list of supported Name ID formats. |
||
| 46 | * |
||
| 47 | * See https://docs.oracle.com/cd/E19316-01/820-3886/6nfcvtepi/index.html |
||
| 48 | * |
||
| 49 | * @return string[]|array |
||
| 50 | */ |
||
| 51 | protected function supportedNameIdFormats(): array |
||
| 62 | ]; |
||
| 63 | } |
||
| 64 | } |