|
7 | 7 | * @license MIT |
8 | 8 | */ |
9 | 9 |
|
10 | | -use chillerlan\HTTP\Psr7; |
| 10 | +namespace chillerlan\OAuthExamples\misc; |
| 11 | + |
11 | 12 | use chillerlan\OAuth\Providers\Flickr\Flickr; |
| 13 | +use ReflectionClass; |
| 14 | + |
| 15 | +use function chillerlan\HTTP\Psr7\get_json; |
| 16 | +use function array_column, array_shift, date, explode, file_put_contents, implode, lcfirst, ucfirst; |
12 | 17 |
|
13 | 18 | $ENVVAR = 'FLICKR'; |
14 | 19 |
|
|
22 | 27 | */ |
23 | 28 |
|
24 | 29 | $flickr = new Flickr($http, $storage, $options, $logger); |
25 | | -$epr = new \ReflectionClass($flickr->endpoints); |
| 30 | +$epr = new ReflectionClass($flickr->endpoints); |
26 | 31 | $classfile = $epr->getFileName(); |
27 | 32 |
|
28 | 33 | // fetch a list of available methods |
29 | 34 | $r = $flickr->request('flickr.reflection.getMethods', [], 'GET'); |
30 | | -$methods = \array_column(Psr7\get_json($r)->methods->method, '_content'); |
| 35 | +$methods = array_column(get_json($r)->methods->method, '_content'); |
31 | 36 |
|
32 | 37 | // now walk through the array and get the method info |
33 | 38 | $str = []; |
34 | 39 | foreach($methods as $methodname){ |
35 | 40 | $methodInfo = $flickr->request('flickr.reflection.getMethodInfo', ['method_name' => $methodname], 'GET'); |
36 | | - $m = Psr7\get_json($methodInfo); |
| 41 | + $m = get_json($methodInfo); |
37 | 42 |
|
38 | 43 | if(!$m || !isset($m->method)){ |
39 | | - $logger->debug($methodname, (array)$methodInfo->headers); |
| 44 | + $logger->debug($methodname); |
40 | 45 |
|
41 | 46 | continue; |
42 | 47 | } |
|
52 | 57 | } |
53 | 58 |
|
54 | 59 | // convert from dot.notation to camelCase |
55 | | - $name = \explode('.', $m->method->name); |
| 60 | + $name = explode('.', $m->method->name); |
56 | 61 |
|
57 | | - \array_shift($name); // remove the "flickr" |
| 62 | + array_shift($name); // remove the "flickr" |
58 | 63 |
|
59 | 64 | foreach($name as $k => $parts){ |
60 | | - $name[$k] = \ucfirst($parts); |
| 65 | + $name[$k] = ucfirst($parts); |
61 | 66 | } |
62 | 67 |
|
63 | 68 | // create a docblock |
|
66 | 71 | /** |
67 | 72 | * @link https://www.flickr.com/services/api/'.$m->method->name.'.html |
68 | 73 | */ |
69 | | - protected $'.\lcfirst(\implode('', $name)).' = [ |
| 74 | + protected $'.lcfirst(implode('', $name)).' = [ |
70 | 75 | \'path\' => \''.$m->method->name.'\', |
71 | | - \'query\' => ['.(!empty($args) ? '\''.\implode('\', \'', $args).'\'' : '').'], |
| 76 | + \'query\' => ['.(!empty($args) ? '\''.implode('\', \'', $args).'\'' : '').'], |
72 | 77 | ];'; |
73 | 78 |
|
74 | 79 | $logger->info($m->method->name); |
|
82 | 87 | * @link https://www.flickr.com/services/api/ |
83 | 88 | * |
84 | 89 | * @filesource '.$epr->getShortName().'.php |
85 | | - * @created '.\date('d.m.Y').' |
| 90 | + * @created '.date('d.m.Y').' |
86 | 91 | * @package '.$epr->getNamespaceName().' |
87 | 92 | * @license MIT |
88 | 93 | */ |
|
92 | 97 | use chillerlan\\HTTP\\MagicAPI\\EndpointMap; |
93 | 98 |
|
94 | 99 | class '.$epr->getShortName().' extends EndpointMap{ |
95 | | -'.\implode(PHP_EOL, $str).' |
| 100 | +'.implode(PHP_EOL, $str).' |
96 | 101 |
|
97 | 102 | } |
98 | 103 | '; |
99 | 104 |
|
100 | | -\file_put_contents($classfile, $content); |
| 105 | +file_put_contents($classfile, $content); |
101 | 106 |
|
102 | 107 | exit; |
0 commit comments