![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/mautic.corals.io/vendor/litesaml/lightsaml/src/Action/ |
<?php namespace LightSaml\Action; use LightSaml\Context\ContextInterface; class CompositeAction implements ActionInterface, DebugPrintTreeActionInterface, CompositeActionInterface { /** @var ActionInterface[] */ protected $children = []; /** * @param ActionInterface[] $children */ public function __construct(array $children = []) { foreach ($children as $action) { $this->add($action); } } /** * @return ActionInterface[] */ public function getChildren() { return $this->children; } /** * @return CompositeAction */ public function add(ActionInterface $action) { $this->children[] = $action; return $this; } /** * @param callable $callable * * @return ActionInterface|null */ public function map($callable) { foreach ($this->children as $k => $action) { $newAction = call_user_func($callable, $action); if ($newAction) { $this->children[$k] = $newAction; } } } /** * @return void */ public function execute(ContextInterface $context) { foreach ($this->children as $action) { $action->execute($context); } } /** * @return array */ public function debugPrintTree() { $arr = []; foreach ($this->children as $childAction) { if ($childAction instanceof DebugPrintTreeActionInterface) { $arr = array_merge($arr, $childAction->debugPrintTree()); } else { $arr = array_merge($arr, [get_class($childAction) => []]); } } $result = [ static::class => $arr, ]; return $result; } /** * @return string */ public function __toString() { return json_encode($this->debugPrintTree(), JSON_PRETTY_PRINT); } }