| Conditions | 3 |
| Paths | 3 |
| Total Lines | 17 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 14 | public function execute(string $search):array |
||
| 15 | { |
||
| 16 | $client = new Client(); |
||
| 17 | $uri = config('wiki.api_uri').'?action=query&list=search&srwhat=text&srsearch='.$search.'&srqiprofile=classic_noboostlinks&srnamespace=3000&format=json'; |
||
| 18 | try { |
||
| 19 | $response = $client->get($uri); |
||
| 20 | }catch (\Throwable $e){ |
||
| 21 | return ['results' => []]; |
||
| 22 | } |
||
| 23 | $content = json_decode($response->getBody()->getContents(), true); |
||
| 24 | if(isset($content['query']['search'])){ |
||
| 25 | $results = array_column($content['query']['search'], 'title'); |
||
| 26 | return array_map(function ($item){ |
||
| 27 | return str_replace('Structure:', '', $item); |
||
| 28 | }, $results); |
||
| 29 | } |
||
| 30 | return ['results' => []]; |
||
| 31 | } |
||
| 33 |