/** * 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; }
/** * @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); }