Conditions | 4 |
Paths | 3 |
Total Lines | 24 |
Code Lines | 20 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
27 | public function getWords($word) { |
||
28 | $suggestions = array(); |
||
29 | $html = new Htmldom($this->base_url . $word); |
||
30 | $listDiv = $html->find('.relevancy-list', 0); |
||
31 | for ($i = 0; $i <= 5; ++$i) { |
||
32 | $list = $listDiv->find('ul', $i); |
||
33 | if (!$list) { |
||
34 | continue; |
||
35 | } |
||
36 | $suggestions[$i]['data'] = array(); |
||
37 | foreach ($list->find('li') as $element) { |
||
38 | $data = array(); |
||
39 | $linkElement = $element->find('a', 0); |
||
40 | $linkSpan = $element->find('a', 0)->find('span', 0); |
||
41 | $linkHref = $linkElement->href; |
||
42 | $dataCategory = html_entity_decode($linkElement->getAttribute('data-category')); |
||
43 | $data['link'] = $linkHref; |
||
44 | $data['word'] = $linkSpan->innertext; |
||
45 | $data['extra_data'] = $dataCategory; |
||
46 | $suggestions[$i]['data'][] = $data; |
||
47 | } |
||
48 | } |
||
49 | return $suggestions; |
||
50 | } |
||
51 | |||
53 |