コード例 #1
0
ファイル: Environment.php プロジェクト: acorncom/deployer
 /**
  * Checks if env var exists.
  *
  * @param string $name
  * @return bool
  */
 public function has($name)
 {
     return $this->values->hasKey($name);
 }
コード例 #2
0
ファイル: DotArrayTest.php プロジェクト: acorncom/deployer
 public function testIssetUnsetAndHasKey()
 {
     $d = new DotArray();
     $d['abc.xyz'] = ['one' => 1, 'two' => 2, 'array' => [2012, '2013', 2014, '2015'], 'null' => null];
     $this->assertTrue(isset($d['abc.xyz']));
     $this->assertTrue($d->hasKey('abc.xyz'));
     $this->assertTrue(isset($d['abc']['xyz']['one']));
     $this->assertTrue(isset($d['abc.xyz.one']));
     $this->assertTrue(isset($d['abc.xyz']['one']));
     $this->assertTrue($d->hasKey('abc.xyz.two'));
     $this->assertTrue(isset($d['abc']['xyz']['array'][0]));
     $this->assertTrue(isset($d['abc']['xyz']['array'][1]));
     $this->assertTrue(isset($d['abc.xyz.array'][0]));
     $this->assertTrue($d->hasKey('abc.xyz.array.0'));
     $this->assertFalse(isset($d['abc']['xyz']['three']));
     $this->assertFalse(isset($d['abc.xyz.three']));
     $this->assertFalse(isset($d['abc.xyz']['three']));
     // Like isset(), a value of null is considered not set.
     $this->assertFalse(isset($d['abc.xyz.null']));
     $this->assertFalse(isset($d['abc']['xyz']['null']));
     // But has key
     $this->assertTrue($d->hasKey('abc.xyz.null'));
     unset($d['abc.xyz.one']);
     $this->assertFalse(isset($d['abc']['xyz']['one']));
     $this->assertFalse(isset($d['abc.xyz.one']));
     $this->assertFalse($d->hasKey('abc.xyz.one'));
     // key not set
     unset($d['abc.xyz.three']);
     $this->assertFalse($d->hasKey('abc.xyz.three'));
     unset($d['abc.xyz']);
     $this->assertFalse(isset($d['abc.xyz']));
     $this->assertFalse($d->hasKey('abc.xyz'));
     unset($d['abc.xyz.null']);
     $this->assertFalse($d->hasKey('abc.xyz.null'));
 }