simplesamlphp /
xml-cas
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace SimpleSAML\CAS\XML; |
||
| 6 | |||
| 7 | use DOMElement; |
||
| 8 | use SimpleSAML\CAS\Assert\Assert; |
||
| 9 | use SimpleSAML\CAS\Constants as C; |
||
| 10 | use SimpleSAML\XMLSchema\Exception\MissingElementException; |
||
| 11 | |||
| 12 | /** |
||
| 13 | * Class for CAS proxies |
||
| 14 | * |
||
| 15 | * @package simplesamlphp/xml-cas |
||
| 16 | */ |
||
| 17 | abstract class AbstractProxies extends AbstractCasElement |
||
| 18 | { |
||
| 19 | final public const string LOCALNAME = 'proxies'; |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 20 | |||
| 21 | |||
| 22 | /** |
||
| 23 | * Initialize a Proxies element. |
||
| 24 | * |
||
| 25 | * @param \SimpleSAML\CAS\XML\Proxy[] $proxy |
||
| 26 | */ |
||
| 27 | public function __construct( |
||
| 28 | protected array $proxy = [], |
||
| 29 | ) { |
||
| 30 | Assert::maxCount($proxy, C::UNBOUNDED_LIMIT); |
||
| 31 | Assert::allIsInstanceOf($proxy, Proxy::class); |
||
| 32 | Assert::minCount($proxy, 1, 'Missing at least one Proxy in Proxies.', MissingElementException::class); |
||
| 33 | } |
||
| 34 | |||
| 35 | |||
| 36 | /** |
||
| 37 | * @return \SimpleSAML\CAS\XML\Proxy[] |
||
| 38 | */ |
||
| 39 | public function getProxy(): array |
||
| 40 | { |
||
| 41 | return $this->proxy; |
||
| 42 | } |
||
| 43 | |||
| 44 | |||
| 45 | /** |
||
| 46 | * Convert this Proxies to XML. |
||
| 47 | * |
||
| 48 | * @param \DOMElement|null $parent The element we should append this Proxies to. |
||
| 49 | * @return \DOMElement |
||
| 50 | */ |
||
| 51 | public function toXML(?DOMElement $parent = null): DOMElement |
||
| 52 | { |
||
| 53 | $e = $this->instantiateParentElement($parent); |
||
| 54 | |||
| 55 | foreach ($this->getProxy() as $proxy) { |
||
| 56 | $proxy->toXML($e); |
||
| 57 | } |
||
| 58 | |||
| 59 | return $e; |
||
| 60 | } |
||
| 61 | } |
||
| 62 |