Beispiel #1
0
 /**
  * Determines if a map contains a value by a specified key path.
  *
  * @param  string $path The key path to be looked by, e.g. "level1key.level2key".
  *
  * @return bool `true` if the map contains a value by such key path, `false` otherwise.
  */
 public function hasPath($path)
 {
     return CMap::hasPath($this->m_map, $path);
 }
Beispiel #2
0
 public function testHasPath()
 {
     $map = ["one" => "a", "two" => ["one" => "a", "two" => ["one" => "a", "two" => "b", "three" => "c"]]];
     $this->assertTrue(CMap::hasPath($map, "one"));
     $this->assertTrue(CMap::hasPath($map, "two"));
     $this->assertTrue(CMap::hasPath($map, "two.one"));
     $this->assertTrue(CMap::hasPath($map, "two.two.three"));
     $this->assertFalse(CMap::hasPath($map, "three"));
     $this->assertFalse(CMap::hasPath($map, "one.one"));
     $this->assertFalse(CMap::hasPath($map, "two.three"));
 }