also looking at this
Feature not found exception
#74
2 files
+2440
-1
| @@ -2,14 +2,27 @@ | ||
| 2 | 2 | |
| 3 | 3 | namespace Meema\MeemaClient\Traits; |
| 4 | 4 | |
| 5 | use BadMethodCallException; | |
| 5 | 6 | use Meema\MeemaClient\Exceptions\FeatureNotImplementedException; |
| 6 | 7 | |
| 7 | 8 | trait DetectsFeature |
| 8 | 9 | { |
| 9 | 10 | public function __call($name, $arguments) |
| 10 | 11 | { |
| 11 | if (! method_exists($this, $name)) { | |
| 12 | $data = file_get_contents(dirname(dirname(__DIR__)).'/data/params.json'); | |
| 13 | ||
| 14 | $data = json_decode($data, true); | |
| 15 | ||
| 16 | $params = array_keys($data['parameters']); | |
| 17 | ||
| 18 | if (! method_exists($this, $name) && in_array($name, $params)) { | |
| 12 | 19 | throw new FeatureNotImplementedException('Feature not yet implemented. Please contact us if this is something you would like to see rather sooner than later.'); |
| 13 | 20 | } |
| 21 | ||
| 22 | if (! method_exists($this, $name)) { | |
| 23 | throw new BadMethodCallException(sprintf( | |
| 24 | 'Call to undefined method %s::%s()', static::class, $name | |
| 25 | )); | |
| 26 | } | |
| 14 | 27 | } |
| 15 | 28 | } |