Exemplo n.º 1
0
 /**
  * Validates if properties is valid or not.
  * 
  * @param mix $properties The properties array.
  * 
  * @return none
  */
 private function _validateProperties($properties)
 {
     Validate::isArray($properties, 'entity properties');
     foreach ($properties as $key => $value) {
         Validate::isString($key, 'key');
         Validate::isTrue($value instanceof Property, Resources::INVALID_PROP_MSG);
         Validate::isTrue(EdmType::validateEdmValue($value->getEdmType(), $value->getValue(), $condition), sprintf(Resources::INVALID_PROP_VAL_MSG, $key, $condition));
     }
 }
Exemplo n.º 2
0
 /**
  * @covers WindowsAzure\Table\Models\EdmType::serializeValue
  */
 public function testSerializeValueWithInvalid()
 {
     // Assert
     $this->setExpectedException('\\InvalidArgumentException');
     // Test
     EdmType::serializeValue('7amada', '1233');
 }
Exemplo n.º 3
0
 /**
  * Constructor.
  * 
  * @param string $edmType The EDM type.
  * @param string $value   The EDM value.
  */
 public function __construct($edmType, $value)
 {
     $this->_edmType = EdmType::processType($edmType);
     $this->_value = $value;
 }
Exemplo n.º 4
0
 /**
  * Sets the value of the property.
  * 
  * @param string $edmType The property type.
  * 
  * @return none
  */
 public function setEdmType($edmType)
 {
     EdmType::isValid($edmType);
     $this->_edmType = $edmType;
 }
 /**
  * Constructs XML representation for entity.
  * 
  * @param Models\Entity $entity The entity instance.
  * 
  * @return string
  */
 public function getEntity($entity)
 {
     $entityProperties = $entity->getProperties();
     $properties = array();
     foreach ($entityProperties as $name => $property) {
         $attributes = array();
         $edmType = $property->getEdmType();
         $edmValue = $property->getValue();
         if (!is_null($edmType)) {
             $attributes['type'] = $edmType;
         }
         if (is_null($edmValue)) {
             $attributes['null'] = 'true';
         }
         $value = EdmType::serializeValue($edmType, $edmValue);
         $properties[$name] = array($value => $attributes);
     }
     return $this->_serializeAtom($properties);
 }
Exemplo n.º 6
0
 /**
  * Builds filter expression
  * 
  * @param Filter $filter The filter object
  * @param string &$e     The filter expression
  * 
  * @return string
  */
 private function _buildFilterExpressionRec($filter, &$e)
 {
     if (is_null($filter)) {
         return;
     }
     if ($filter instanceof PropertyNameFilter) {
         $e .= $filter->getPropertyName();
     } else {
         if ($filter instanceof ConstantFilter) {
             $value = $filter->getValue();
             // If the value is null we just append null regardless of the edmType.
             if (is_null($value)) {
                 $e .= 'null';
             } else {
                 $type = $filter->getEdmType();
                 $e .= EdmType::serializeQueryValue($type, $value);
             }
         } else {
             if ($filter instanceof UnaryFilter) {
                 $e .= $filter->getOperator();
                 $e .= '(';
                 $this->_buildFilterExpressionRec($filter->getOperand(), $e);
                 $e .= ')';
             } else {
                 if ($filter instanceof Filters\BinaryFilter) {
                     $e .= '(';
                     $this->_buildFilterExpressionRec($filter->getLeft(), $e);
                     $e .= ' ';
                     $e .= $filter->getOperator();
                     $e .= ' ';
                     $this->_buildFilterExpressionRec($filter->getRight(), $e);
                     $e .= ')';
                 } else {
                     if ($filter instanceof QueryStringFilter) {
                         $e .= $filter->getQueryString();
                     }
                 }
             }
         }
     }
     return $e;
 }