Completed
Push — master ( 2ed909...2757c2 )
by Seth
03:44
created

SearchSource::getIcon()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace smtech\StMarksSearch;
4
5
/**
6
 * An object representing a simplified description of a search result's source
7
 * search domain
8
 *
9
 * @author Seth Battis <[email protected]>
10
 */
11
class SearchSource extends ParameterArrayConstructor
12
{
13
    /**
14
     * Human-readable name
15
     * @var string
16
     */
17
    private $name;
18
19
    /**
20
     * URL to source home page
21
     * @var string
22
     */
23
    private $url;
24
25
    private $icon;
26
27
    /**
28
     * Construct a SearchSource from a search domain
29
     *
30
     * @param AbstractSearchDomain $domain
31
     */
32
    public function __construct(AbstractSearchDomain $domain)
33
    {
34
        $this->name = $domain->getName();
1 ignored issue
show
Documentation Bug introduced by
The method getName does not exist on object<smtech\StMarksSearch\AbstractSearchDomain>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
35
        $this->url = $domain->getUrl();
1 ignored issue
show
Documentation Bug introduced by
The method getUrl does not exist on object<smtech\StMarksSearch\AbstractSearchDomain>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
36
        $this->icon = $domain->getIcon();
1 ignored issue
show
Documentation Bug introduced by
The method getIcon does not exist on object<smtech\StMarksSearch\AbstractSearchDomain>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
37
    }
38
39
    /**
40
     * Human-readable name of the source search domain
41
     *
42
     * @return string
43
     */
44
    public function getName()
45
    {
46
        return $this->name;
47
    }
48
49
    /**
50
     * URL of the source search domain's home page
51
     *
52
     * @return string
53
     */
54
    public function getUrl()
55
    {
56
        return $this->url;
57
    }
58
59
    public function getIcon()
60
    {
61
        return $this->icon;
62
    }
63
}
64