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}"); } }
/** * @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()); }