protected function outputNotNull($value) { if (is_array($value)) { $value = Point::createFromArray($value); } elseif (!$value instanceof Point) { throw TypeConversionException::unexpectedValue($this, 'output', 'instance of Point or an array', $value); } return '(' . $this->_float->output($value->x) . ',' . $this->_float->output($value->y) . ')'; }
public static function createFromArray(array $input) { $points = array(); foreach ($input as $point) { if (is_array($point)) { $point = Point::createFromArray($point); } $points[] = $point; } return new static($points); }
/** * Creates a Circle from a given array * * @param array $input * @return self * @throws InvalidArgumentException */ public static function createFromArray(array $input) { if (2 != count($input)) { throw new InvalidArgumentException(sprintf("%s() expects an array with exactly two elements", __METHOD__)); } if (array_key_exists('center', $input) && array_key_exists('radius', $input)) { $center = $input['center']; $radius = $input['radius']; } else { $center = array_shift($input); $radius = array_shift($input); } if (is_array($center)) { $center = Point::createFromArray($center); } return new self($center, $radius); }
/** * Creates an instance of PointPair from a given array * * @param array $input * @return self * @throws InvalidArgumentException */ public static function createFromArray(array $input) { if (2 != count($input)) { throw new InvalidArgumentException(sprintf("%s() expects an array with exactly two elements", __METHOD__)); } if (array_key_exists('start', $input) && array_key_exists('end', $input)) { $start = $input['start']; $end = $input['end']; } else { $start = array_shift($input); $end = array_shift($input); } if (is_array($start)) { $start = Point::createFromArray($start); } if (is_array($end)) { $end = Point::createFromArray($end); } return new static($start, $end); }