Exemple #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);
 }
 public function testFromNonExistentKey()
 {
     $this->assertSame('Non-existent key "foo" provided', NonExistentKey::fromNonExistentKey('foo')->getMessage());
 }