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