diff --git a/src/Samsara/Planck/Core/AbstractGrid.php b/src/Samsara/Planck/Core/AbstractGrid.php index 52e531c..b790ec2 100644 --- a/src/Samsara/Planck/Core/AbstractGrid.php +++ b/src/Samsara/Planck/Core/AbstractGrid.php @@ -32,10 +32,21 @@ abstract class AbstractGrid */ protected $addresses = []; + /** + * @var array + */ protected $maxVals = []; + /** + * @var array + */ protected $minVals = []; + /** + * @param string $name + * @param string $address + * @param GridInterface|null $protoSubGrid + */ public function __construct($name, $address = '', GridInterface $protoSubGrid = null) { $this->name = $name; @@ -49,6 +60,10 @@ public function __construct($name, $address = '', GridInterface $protoSubGrid = } } + /** + * @param GridInterface $grid + * @return $this + */ public function attachParentGrid(GridInterface $grid) { $this->parentGrid = $grid; @@ -56,6 +71,12 @@ public function attachParentGrid(GridInterface $grid) return $this; } + /** + * @param Node $node + * @param string|null $address + * @return $this + * @throws \Exception + */ public function attachNode(Node $node, $address = null) { if (is_null($address)) { @@ -67,6 +88,12 @@ public function attachNode(Node $node, $address = null) return $this; } + /** + * @param string $address + * @param GridInterface|null $grid + * @return $this + * @throws \Exception + */ public function addAddress($address, GridInterface $grid = null) { $validAddress = $this->evalAddress($address); @@ -83,11 +110,21 @@ public function addAddress($address, GridInterface $grid = null) return $this; } + /** + * @param string|null $address + * @return $this|AbstractGrid + * @throws \Exception + */ public function getLocation($address = null) { return $this->resolve($address); } + /** + * @param string|null $address + * @return Node + * @throws \Exception + */ public function getNode($address = null) { if (is_null($address)) { @@ -97,6 +134,11 @@ public function getNode($address = null) return $this->resolve($address)->getNode(); } + /** + * @param string|null $address + * @return array + * @throws \Exception + */ public function getNodeProperties($address = null) { $location = $this->resolve($address); @@ -111,6 +153,9 @@ public function getNodeProperties($address = null) return $properties; } + /** + * @return array + */ public function getNodeEvents() { $properties = $this->node->getAllEventsProperties(); @@ -122,6 +167,9 @@ public function getNodeEvents() return $properties; } + /** + * @return $this + */ public function resetGrid() { $this->name = ''; @@ -131,6 +179,10 @@ public function resetGrid() return $this; } + /** + * @param AbstractGrid|null $grid + * @return AbstractGrid + */ protected function makeSubGrid(AbstractGrid $grid = null) { if (is_null($grid)) { @@ -147,6 +199,11 @@ protected function makeSubGrid(AbstractGrid $grid = null) return $return; } + /** + * @param string $address + * @return array + * @throws \Exception + */ protected function evalAddress($address) { $return = []; @@ -169,6 +226,11 @@ protected function evalAddress($address) return $return; } + /** + * @param string $address + * @return $this + * @throws \Exception + */ protected function resolve($address = '') { if (empty($address)) { @@ -184,6 +246,10 @@ protected function resolve($address = '') } } + /** + * @param string $address + * @return bool + */ abstract protected function isValidAddress($address); } \ No newline at end of file diff --git a/src/Samsara/Planck/Core/AbstractNode.php b/src/Samsara/Planck/Core/AbstractNode.php index e6e727d..b56e5f1 100644 --- a/src/Samsara/Planck/Core/AbstractNode.php +++ b/src/Samsara/Planck/Core/AbstractNode.php @@ -4,9 +4,16 @@ abstract class AbstractNode { - + /** + * @var array + */ protected $properties = []; + /** + * @param string $key + * @param string $value + * @return $this + */ public function set($key, $value) { $this->properties[$key] = $value; @@ -14,6 +21,10 @@ public function set($key, $value) return $this; } + /** + * @param string $key + * @return null|mixed + */ public function get($key) { if (array_key_exists($key, $this->properties)) { @@ -23,6 +34,9 @@ public function get($key) return null; } + /** + * @return array + */ public function getAllProperties() { return $this->properties; diff --git a/src/Samsara/Planck/Core/GridInterface.php b/src/Samsara/Planck/Core/GridInterface.php index 17c309c..da44982 100644 --- a/src/Samsara/Planck/Core/GridInterface.php +++ b/src/Samsara/Planck/Core/GridInterface.php @@ -7,22 +7,61 @@ interface GridInterface { + /** + * @param string $name + * @param string $address + * @param GridInterface|null $protoSubGrid + * @param array|null $maxVals + * @param array|null $minVals + */ public function __construct($name, $address = '', GridInterface $protoSubGrid = null, array $maxVals = null, array $minVals = null); + /** + * @param GridInterface $grid + * @return $this + */ public function attachParentGrid(GridInterface $grid); + /** + * @param Node $node + * @param null|string $address + * @return $this + */ public function attachNode(Node $node, $address = null); + /** + * @param string $address + * @param GridInterface|null $grid + * @return $this + */ public function addAddress($address, GridInterface $grid = null); + /** + * @param string|null $address + * @return $this + */ public function getLocation($address = null); + /** + * @param string|null $address + * @return Node + */ public function getNode($address = null); + /** + * @param string|null $address + * @return array + */ public function getNodeProperties($address = null); + /** + * @return array + */ public function getNodeEvents(); + /** + * @return $this + */ public function resetGrid(); } \ No newline at end of file diff --git a/src/Samsara/Planck/Factory/GridFactory.php b/src/Samsara/Planck/Factory/GridFactory.php index 04a9ba5..027ea67 100644 --- a/src/Samsara/Planck/Factory/GridFactory.php +++ b/src/Samsara/Planck/Factory/GridFactory.php @@ -2,11 +2,19 @@ namespace Samsara\Planck\Factory; +use Samsara\Planck\Core\AbstractGrid; + class GridFactory { const TWO_DIMENSION = 'Samsara\\Planck\\Grid\\TwoDimensionGrid'; const THREE_DIMENSION = 'Samsara\\Planck\\Grid\\ThreeDimensionGrid'; + /** + * @param string|AbstractGrid $type + * @param array $options + * @return AbstractGrid + * @throws \Exception + */ public static function makeGrid($type, $options = []) { $reflector = new \ReflectionClass($type); diff --git a/src/Samsara/Planck/Grid/ThreeDimensionGrid.php b/src/Samsara/Planck/Grid/ThreeDimensionGrid.php index 3a65e5e..da4af7d 100644 --- a/src/Samsara/Planck/Grid/ThreeDimensionGrid.php +++ b/src/Samsara/Planck/Grid/ThreeDimensionGrid.php @@ -23,6 +23,14 @@ abstract class ThreeDimensionGrid extends AbstractGrid implements GridInterface self::AXIS_THREE => 0 ]; + /** + * @param string $name + * @param string $address + * @param GridInterface|null $protoSubGrid + * @param array|null $maxVals + * @param array|null $minVals + * @throws \Exception + */ public function __construct($name, $address = '', GridInterface $protoSubGrid = null, array $maxVals = null, array $minVals = null) { if (!is_null($maxVals) && count($maxVals)) { @@ -68,6 +76,10 @@ public function __construct($name, $address = '', GridInterface $protoSubGrid = parent::__construct($name, $address, $protoSubGrid); } + /** + * @param string $address + * @return bool + */ protected function isValidAddress($address) { if (is_string($address)) { diff --git a/src/Samsara/Planck/Grid/TwoDimensionGrid.php b/src/Samsara/Planck/Grid/TwoDimensionGrid.php index 69c60c6..85eaa4c 100644 --- a/src/Samsara/Planck/Grid/TwoDimensionGrid.php +++ b/src/Samsara/Planck/Grid/TwoDimensionGrid.php @@ -11,6 +11,14 @@ class TwoDimensionGrid extends AbstractGrid implements GridInterface const AXIS_ONE = 'x'; const AXIS_TWO = 'y'; + /** + * @param string $name + * @param string $address + * @param GridInterface|null $protoSubGrid + * @param array|null $maxVals + * @param array|null $minVals + * @throws \Exception + */ public function __construct($name, $address = '', GridInterface $protoSubGrid = null, array $maxVals = null, array $minVals = null) { if (!is_null($maxVals) && count($maxVals)) { @@ -54,6 +62,10 @@ public function __construct($name, $address = '', GridInterface $protoSubGrid = parent::__construct($name, $address, $protoSubGrid); } + /** + * @param string $address + * @return bool + */ protected function isValidAddress($address) { if (is_string($address)) { diff --git a/src/Samsara/Planck/Node/Node.php b/src/Samsara/Planck/Node/Node.php index 91f0d51..59597e5 100644 --- a/src/Samsara/Planck/Node/Node.php +++ b/src/Samsara/Planck/Node/Node.php @@ -11,6 +11,12 @@ class Node extends AbstractNode */ protected $events = []; + /** + * @param string $key + * @param Event $event + * @return $this + * @throws \Exception + */ public function attachEvent($key, Event $event) { if (array_key_exists($key, $this->events)) { @@ -22,6 +28,10 @@ public function attachEvent($key, Event $event) return $this; } + /** + * @param string $key + * @return null|Event + */ public function getEvent($key) { if (array_key_exists($key, $this->events)) { @@ -31,6 +41,10 @@ public function getEvent($key) return null; } + /** + * @param string $key + * @return $this + */ public function removeEvent($key) { if (array_key_exists($key, $this->events)) { @@ -40,6 +54,9 @@ public function removeEvent($key) return $this; } + /** + * @return array + */ public function getAllEventsProperties() { $properties = [];