TurkishSynonyms   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
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 18
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getWords() 0 12 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 TurkishSynonyms {
16
17
    public $base_url = 'http://www.tdk.gov.tr/index.php?option=com_esanlamlar&arama=esanlam&keyword=';
18
19
    public function getWords($word) {
20
        $suggestions = array();
21
        $html = new Htmldom($this->base_url . $word);
22
        $data= array();
23
        foreach ($html->find('.meaning') as $element) {
24
            foreach (explode("/", $element->innertext) as $synonym) {
25
                $data['data'][] = array('word' => trim($synonym));
26
            }
27
            $suggestions[] = $data;
28
        }
29
        return $suggestions;
30
    }
31
32
}
33