/** * @param Node $node * @return MyNode */ public static function fromNode(Node $node) { $rowAndColumn = explode('x', $node->getID()); if (count($rowAndColumn) != 2) { throw new \InvalidArgumentException('Invalid node: ' . print_r($node, true)); } $row = $rowAndColumn[0]; $column = $rowAndColumn[1]; return new MyNode($row, $column); }
/** * @param Node $node * @return MyNode */ public static function fromNode(Node $node) { $coordinates = explode('x', $node->getID()); if (count($coordinates) != 2) { throw new \InvalidArgumentException('Invalid node: ' . print_r($node, true)); } $x = $coordinates[0]; $y = $coordinates[1]; return new MyNode($x, $y); }