예제 #1
0
 /**
  * A scope with two arguments
  *
  * @param  mixed $min
  * @param  mixed $max
  * @return static
  */
 public function between($min, $max)
 {
     $result = [];
     foreach ($this->data as $key => $value) {
         $greaterThanMin = $value['val'] >= $min or $min === '';
         $lessThanMax = $value['val'] <= $max or $max === '';
         if ($greaterThanMin and $lessThanMax) {
             $result[$key] = ['val' => $value['val']];
         }
     }
     $this->data->replaceTarget($result);
     return $this;
 }
예제 #2
0
 /**
  * @covers Mobileka\MosaicArray\MosaicArray::replaceTarget()
  */
 public function test_replaces_target_array()
 {
     $ma = new MosaicArray($this->target);
     $expect = ['some value'];
     $result = $ma->replaceTarget($expect)->toArray();
     assertEquals($expect, $result);
     assertNotEquals($this->target, $result);
 }