filterByAllowedKeys() публичный статический Метод

Example: $array = array('a' => 1, 'b' => 2, 'c' => 3); $filtered = Arrays::filterByAllowedKeys($array, array('a', 'b')); Result: Array ( [a] => 1 [b] => 2 )
public static filterByAllowedKeys ( array $elements, array $allowedKeys ) : array
$elements array
$allowedKeys array
Результат array
Пример #1
0
 public function matches($argument)
 {
     if (get_class($this->expected) !== get_class($argument)) {
         return false;
     }
     $actualAttributes = Arrays::filterByAllowedKeys($argument->attributes(), $this->expected->getFields());
     return $this->expectedAttributes == $actualAttributes;
 }
Пример #2
0
 private function _assertSamePersistentAttributes(Model $expected)
 {
     $expectedAttributes = Arrays::filterByAllowedKeys($expected->attributes(), $expected->getFields());
     $actualAttributes = Arrays::filterByAllowedKeys($this->_actual->attributes(), $this->_actual->getFields());
     AssertAdapter::assertEquals($expectedAttributes, $actualAttributes, 'Models have different attributes ');
 }
Пример #3
0
 public function filterByAllowedKeys($allowedKeys)
 {
     $this->_array = Arrays::filterByAllowedKeys($this->_array, $allowedKeys);
     return $this;
 }
Пример #4
0
 /**
  * @test
  */
 public function shouldFilterByAllowedKeys()
 {
     //given
     $array = array('a' => 1, 'b' => 2, 'c' => 3);
     //when
     $filtered = Arrays::filterByAllowedKeys($array, array('a', 'b'));
     //then
     $this->assertEquals(array('a' => 1, 'b' => 2), $filtered);
 }