Ejemplo n.º 1
0
 /**
  * @throws NonExistentKey When the key cannot be found and no fallback is defined
  */
 public function getValue(string $key, string $fallback = null) : string
 {
     if (array_key_exists($key, $this->data)) {
         return $this->data[$key];
     }
     if (null !== $fallback) {
         return $fallback;
     }
     throw NonExistentKey::fromNonExistentKey($key);
 }
Ejemplo n.º 2
0
 public function testFromNonExistentKey()
 {
     $this->assertSame('Non-existent key "foo" provided', NonExistentKey::fromNonExistentKey('foo')->getMessage());
 }