Synonyms::getWordnik()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Hasantayyar\Synonyms;
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 Synonyms {
16
17
    private $url;
18
    private $word;
19
    private $words;
20
    public $suggestions = array();
21
22
    public function __construct($word) {
23
        $this->word = $word;
24
    }
25
26
    public function getWords() {
27
        return $this->words;
28
    }
29
30
    public function getFormatted() {
31
        if (!is_array($this->words)) {
32
            return FALSE;
33
        }
34
        $formattedString = '';
35
        foreach ($this->words as $level) {
36
            foreach ($level['data'] as $item) {
37
                $formattedString.= $item['word'] . "\n";
38
            }
39
        }
40
        return $formattedString;
41
    }
42
43
    /**
44
     * get and get Thesaurus.com data
45
     */
46 View Code Duplication
    public function getThesaurus($word = NULL) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
47
        $word = !$word ? $this->word : $word;
48
        $service = new Services\Thesaurus();
49
        $this->words = $service->getWords($word);
50
        return $this;
51
    }
52
53 View Code Duplication
    public function getBighugelabs($word = NULL) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
54
        $word = !$word ? $this->word : $word;
55
        $service = new Services\Bighugelabs();
56
        $this->words = $service->getWords($word);
57
        return $this;
58
    }
59
60 View Code Duplication
    public function getTurkishSynonyms($word = NULL) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
61
        $word = !$word ? $this->word : $word;
62
        $service = new Services\TurkishSynonyms();
63
        $this->words = $service->getWords($word);
64
        return $this;
65
    }
66
67
    public function getWordnik($word = NULL) {
0 ignored issues
show
Unused Code introduced by
The parameter $word is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
68
        //https://www.wordnik.com/fragments/tags/test
69
        return NULL;
70
    }
71
72
    /**
73
     * @todo get google suggestions
74
     */
75
    public function getGoogleSuggestions($word = NULL) {
0 ignored issues
show
Unused Code introduced by
The parameter $word is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
76
        return NULL;
77
    }
78
79
}
80