specs = clone $specs; $this->flags = clone $flags; Assert::parameterType( 'callable|array', $actions, '$actions' ); if ( is_callable( $actions ) ) { $this->actionsCallback = $actions; } elseif ( is_array( $actions ) ) { $this->setActions( $actions ); } } /** * @return Specs */ public function getSpecs() : Specs { return clone $this->specs; } /** * @return Flags */ public function getFlags() : Flags { return clone $this->flags; } /** * @return string */ public function getRules(): string { return $this->specs->getRules(); } /** * @return string */ public function getComments(): string { return $this->specs->getComments(); } /** * @return string */ public function getName(): string { return $this->specs->getName(); } /** * @note Callers should not rely on the order, because it's nondeterministic. * @return string[] */ public function getActionsNames(): array { return $this->specs->getActionsNames(); } /** * @return string */ public function getGroup(): string { return $this->specs->getGroup(); } /** * @return bool */ public function isEnabled(): bool { return $this->flags->getEnabled(); } /** * @return bool */ public function isDeleted(): bool { return $this->flags->getDeleted(); } /** * @return bool */ public function isHidden(): bool { return $this->flags->getHidden(); } /** * @return bool */ public function isGlobal(): bool { return $this->flags->getGlobal(); } /** * @return array[] */ public function getActions() : array { if ( $this->actions === null ) { $this->setActions( call_user_func( $this->actionsCallback ) ); } return $this->actions; } /** * @param array $actions */ protected function setActions( array $actions ) : void { $this->actions = $actions; $this->specs->setActionsNames( array_keys( $actions ) ); } /** * Make sure we don't leave any (writeable) reference */ public function __clone() { $this->specs = clone $this->specs; $this->flags = clone $this->flags; } }