示例#1
0
 public function testCreationFromCoordinateArray()
 {
     $box = Box::fromArray(array('x1' => 1, 'y1' => '2.3', 'x2' => null, 'y2' => 9.99));
     $this->assertEquals(1, $box->left);
     $this->assertEquals(2.3, $box->bottom);
     $this->assertEquals(0, $box->right);
     $this->assertEquals(9.99, $box->top);
 }
示例#2
0
 /**
  * (non-PHPdoc)
  * 
  * @see \Doctrine\DBAL\Types\Type::convertToDatabaseValue()
  */
 public function convertToDatabaseValue($value, AbstractPlatform $platform)
 {
     if ($value === null) {
         return null;
     }
     if (is_array($value)) {
         $value = Box::fromArray($value);
     }
     if (!$value instanceof Box) {
         throw new \InvalidArgumentException(sprintf('Box value must be instance of Box'));
     }
     return sprintf('(%f, %f),(%f, %f)', $value->left, $value->bottom, $value->right, $value->top);
 }