* @author Michal Dabrowski */ class Transition implements PropertiesAwareTransitionInterface { /** * @var array */ protected $initialStates; /* * @var string */ protected $state; /** * @var string */ protected $name; /** * @var callable */ protected $guard; /** * @var OptionsResolver */ protected $propertiesOptionsResolver; /** * @param string $name * @param string|array $initialStates * @param string $state * @param callable|null $guard * @param OptionsResolver $propertiesOptionsResolver */ public function __construct( $name, $initialStates, $state, $guard = null, OptionsResolver $propertiesOptionsResolver = null ) { if (null !== $guard && !is_callable($guard)) { throw new \InvalidArgumentException('Invalid callable guard argument passed to Transition::__construct().'); } $this->name = $name; $this->state = $state; $this->initialStates = (array) $initialStates; $this->guard = $guard; $this->propertiesOptionsResolver = $propertiesOptionsResolver ?: new OptionsResolver(); } /** * @param string|StateInterface $state */ public function addInitialState($state) { if ($state instanceof StateInterface) { $state = $state->getName(); } $this->initialStates[] = $state; } /** * {@inheritdoc} */ public function getInitialStates() { return $this->initialStates; } /** * {@inheritdoc} */ public function getState() { return $this->state; } /** * {@inheritdoc} */ public function process(StateMachineInterface $stateMachine) { } /** * {@inheritdoc} */ public function getName() { return $this->name; } /** * @return callable|null */ public function getGuard() { return $this->guard; } /** * {@inheritdoc} */ public function resolveProperties(array $properties) { try { return $this->propertiesOptionsResolver->resolve($properties); } catch (MissingOptionsException $e) { throw new TransitionException( 'Testing or applying this transition need a parameter. Provide it or set it optional.', $e->getCode(), $e ); } catch (UndefinedOptionsException $e) { throw new TransitionException( 'You provided an unknown property to test() or apply(). Remove it or declare it in your graph.', $e->getCode(), $e ); } } /** * {@inheritDoc} */ public function has($property) { return array_key_exists($property, $this->getProperties()); } /** * {@inheritDoc} */ public function get($property, $default = null) { $properties = $this->getProperties(); return $this->has($property) ? $properties[$property] : $default; } /** * {@inheritDoc} */ public function getProperties() { $missingOptions = $this->propertiesOptionsResolver->getMissingOptions(); if (0 === count($missingOptions)) { return $this->propertiesOptionsResolver->resolve(array()); } $options = array_combine($missingOptions, array_fill(0, count($missingOptions), null)); return array_diff_key( $this->propertiesOptionsResolver->resolve($options), array_combine($missingOptions, $missingOptions) ); } /** * @return string */ public function __toString() { return $this->getName(); } } __halt_compiler();----SIGNATURE:----L8HoIwz9OE9SJL3L6WoKevd6xzhKQrvIbebo6EzOclYxi6aio+bHFtoCzLQmdyLxc/lEV/SOh/qJe25cP8yXZ+OicUQdWracGYq9tFQWq35mFbyA8CWl/dyCBu6yhOS5U7S/+xcPWoFlzVIHHFnycuiqaqZoHnuoJXdNExVhEjMUEFpm2Qrif3xOHD1bAMryDnMDjmtpVqRopSzY/wj1ycNz5Sy3PkRBQh3FTXk1QRY3AvXooUnwmePVwZ2bizSrF5aOpsMWQFlKNpIH4gqg//I+iqbBJVqHejup6zi78+ZrbXySevkks9OLvoVEm/a4r5U4UT1fT/BY66xQbBKDQ/d4oDnEI50VsdPHx5SC1qUcDrwprHI/COCU4GAloKmFvYdYhI2qiXUHEpt8OjmYK41hqD0ohzSVZpwzGNSFAutsvRC6n3r4Wn86JeoX4urTARBaKa+Kek3RbB74JnXLHga279qvbBwNVc5/gnqHo7Cvt87qfCJjfE4MQyv/81bJOinm/TSa+648pY/AQzpG+rn7XahFyL92A5T/IUvKspZojj2hOXMZ0+heIyv0xzF7AxVd3QsiX6KJQ7HlE6Ff+6JeOAQWdwxfpvddgWuV3g0OKlT+45sB+Z8aLJdvS1xZqZ+g6/wqbAzyFXpJpsFGnNhpyI4C5bDmRbQu4gIOaH4=----ATTACHMENT:----ODQ1NTkxNzQzNzcwNTk4OSA0OTkyMTA0MDIxNTcwMjgzIDI4MDc5MzQxOTUzMzA1OTY=