예제 #1
0
 /**
  * our constructor
  *
  * @param array<ComparisonExpression> $rangeExpressions
  *        the list of comparison expressions that make up this version range
  */
 public function __construct($rangeExpressions)
 {
     // robustness
     RequireTraversable::check($rangeExpressions, E4xx_UnsupportedType::class);
     $this->rangeExpressions = [];
     foreach ($rangeExpressions as $rangeExpression) {
         RequireObjectOfType::check($rangeExpression, ComparisonExpression::class, E4xx_UnsupportedType::class);
         $this->rangeExpressions[] = $rangeExpression;
     }
 }
 /**
  * write an array of data to the stream
  *
  * @param  array $data
  *         the data to write to the stream
  * @return void
  */
 public function writeArray($data)
 {
     // robustness!
     RequireTraversable::check($data, E4xx_UnsupportedType::class);
     foreach ($data as $item) {
         // we do not know what $item is, so send it to our generic
         // write method
         $this->write($item);
     }
 }
 /**
  * merge their array into our array
  *
  * @param  array &$ours
  *         the array that we want to merge into
  * @param  array|Traversable $theirs
  *         the array that we want to merge from
  * @return void
  */
 public static function fromArray(&$ours, $theirs)
 {
     // robustness!
     RequireIndexable::check($ours, E4xx_UnsupportedType::class);
     RequireTraversable::check($theirs, E4xx_UnsupportedType::class);
     // copy from them to us
     foreach ($theirs as $key => $value) {
         self::mergeKeyIntoArray($ours, $key, $value);
     }
     // all done
 }
 /**
  * @covers ::check
  * @covers ::checkMixed
  * @dataProvider provideNonTraversables
  * @expectedException GanbaroDigital\Reflection\Exceptions\E4xx_UnsupportedType
  */
 public function testRejectsNonTraversablesWhenCalledStatically($item)
 {
     // ----------------------------------------------------------------
     // setup your test
     // ----------------------------------------------------------------
     // perform the change
     RequireTraversable::check($item);
 }