ReviewOS

also looking at this

meemalabs/meema-client-php

Feature not found exception

#74
Merged glennmichael123 wants to merge feature-exception into main
2 files +2440 -1
src/Traits/DetectsFeature.phpmodified+14-1
Changes to src/Traits/DetectsFeature.php
@@ -2,14 +2,27 @@
22
33namespace Meema\MeemaClient\Traits;
44
5use BadMethodCallException;
56use Meema\MeemaClient\Exceptions\FeatureNotImplementedException;
67
78trait DetectsFeature
89{
910 public function __call($name, $arguments)
1011 {
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)) {
1219 throw new FeatureNotImplementedException('Feature not yet implemented. Please contact us if this is something you would like to see rather sooner than later.');
1320 }
21
22 if (! method_exists($this, $name)) {
23 throw new BadMethodCallException(sprintf(
24 'Call to undefined method %s::%s()', static::class, $name
25 ));
26 }
1427 }
1528}