Bighugelabs   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 1
cbo 1
dl 0
loc 32
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getWords() 0 18 3
1
<?php
2
3
namespace Hasantayyar\Synonyms\Services;
4
5
use Yangqi\Htmldom\Htmldom as Htmldom;
6
7
/**
8
 *  
9
 *
10
 * @author Hasan Tayyar BEŞİK <[email protected]>
11
 * @author Hasan Tayyar BEŞİK 
12
 * @version 0.1
13
 * @package Synonyms 
14
 */
15
class Bighugelabs {
16
17
    /**
18
     *
19
     * @var string
20
     */
21
    public $base_url = 'http://words.bighugelabs.com/';
22
23
    /**
24
     * 
25
     * @return array
26
     */
27
    public function getWords($word) {
28
        $suggestions = array();
29
        $html = new Htmldom($this->base_url . $word);
30
        $list = $html->find('ul[class=words]', 0);
31
        $suggestions[0]['data'] = array();
32
        if(!$list){
33
            return FALSE;
34
        }
35
        foreach ($list->find('li') as $element) {
36
            $data = array();
37
            $linkElement = $element->find('a', 0);
38
            $linkHref = $linkElement->href;
39
            $data['link'] = $linkHref;
40
            $data['word'] = $linkElement->innertext;
41
            $suggestions[0]['data'][] = $data;
42
        }
43
        return $suggestions;
44
    }
45
46
}
47