コード例 #1
0
ファイル: Bag.php プロジェクト: pinepain/jetbag
 function __get($name)
 {
     if (isset($this[$name])) {
         return $this[$name];
     }
     $poirot = new Poirot($this);
     try {
         return $poirot->find($name);
     } catch (PoirotException $e) {
         $variations = $poirot->suspects();
         if (empty($variations)) {
             $variations = 'and has no variations';
         } else {
             $variations = implode(', ', $variations);
             $variations = "as well as it variations '{$variations}'";
         }
         throw new BagException("Key '{$name}' not found {$variations}");
     }
 }
コード例 #2
0
ファイル: PoirotTest.php プロジェクト: pinepain/jetbag
 /**
  * @covers       \JetBag\Poirot::find
  * @covers       \JetBag\Poirot::suspects
  * @dataProvider providerFindFound
  */
 public function testFindFound($key, $search_key, $suspects)
 {
     $value = "{$key} value";
     $poirot = new Poirot(array($key => $value));
     $this->assertEquals($value, $poirot->find($search_key));
     $this->assertEquals($suspects, $poirot->suspects());
 }