Пример #1
0
 /**
  * @depends testSetIn
  */
 public function testGetIn(array $target)
 {
     $this->assertSame(3, Complex::getIn($target, ['f']));
     $this->assertSame(1, Complex::getIn($target, ['a', 'b', 'c', 'd']));
     $this->assertSame(2, Complex::getIn($target, ['a', 'b', 'e']));
     $this->assertSame(['d' => 1], Complex::getIn($target, ['a', 'b', 'c']));
     $this->assertFalse(Complex::getIn($target, ['g']));
     $this->assertFalse(Complex::getIn($target, ['a', 'c']));
     $this->assertFalse(Complex::getIn($target, ['a', 'b', 'c', 'd', 'e']));
     return $target;
 }
Пример #2
0
 /**
  * @param string $key
  * @param array|string $path
  * @return mixed|false
  */
 public function getIn($key, $path)
 {
     $target = $this->get($key);
     $path = (array) $path;
     if (!is_array($target)) {
         throw new Exception\UnexpectedPropertyValueException(get_class($this) . ": Property {$key} is not complex type");
     }
     return Type\Complex::getIn($target, $path);
 }