[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/externals/restful/src/RESTful/ -> Field.php (source)

   1  <?php
   2  
   3  namespace RESTful;
   4  
   5  class Field
   6  {
   7      public $name;
   8  
   9      public function __construct($name)
  10      {
  11          $this->name = $name;
  12      }
  13  
  14      public function __get($name)
  15      {
  16          return new Field($this->name . '.' . $name);
  17      }
  18  
  19      public function in($vals)
  20      {
  21          return new FilterExpression($this->name, 'in', $vals, '!in');
  22      }
  23  
  24      public function startswith($prefix)
  25      {
  26          if (!is_string($prefix)) {
  27              throw new \InvalidArgumentException('"startswith" prefix  must be a string');
  28          }
  29  
  30          return new FilterExpression($this->name, 'contains', $prefix);
  31      }
  32  
  33      public function endswith($suffix)
  34      {
  35          if (!is_string($suffix)) {
  36              throw new \InvalidArgumentException('"endswith" suffix  must be a string');
  37          }
  38  
  39          return new FilterExpression($this->name, 'contains', $suffix);
  40      }
  41  
  42      public function contains($fragment)
  43      {
  44          if (!is_string($fragment)) {
  45              throw new \InvalidArgumentException('"contains" fragment must be a string');
  46          }
  47  
  48          return new FilterExpression($this->name, 'contains', $fragment, '!contains');
  49      }
  50  
  51      public function eq($val)
  52      {
  53          return new FilterExpression($this->name, '=', $val, '!eq');
  54      }
  55  
  56      public function lt($val)
  57      {
  58          return new FilterExpression($this->name, '<', $val, '>=');
  59      }
  60  
  61      public function lte($val)
  62      {
  63          return new FilterExpression($this->name, '<=', $val, '>');
  64      }
  65  
  66      public function gt($val)
  67      {
  68          return new FilterExpression($this->name, '>', $val, '<=');
  69      }
  70  
  71      public function gte($val)
  72      {
  73          return new FilterExpression($this->name, '>=', $val, '<');
  74      }
  75  
  76      public function asc()
  77      {
  78          return new SortExpression($this->name, true);
  79      }
  80  
  81      public function desc()
  82      {
  83          return new SortExpression($this->name, false);
  84      }
  85  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1