HostParser   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 3
dl 0
loc 37
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A client() 0 4 2
A render() 0 7 2
1
<?php
2
/**
3
 * vipnytt/RobotsTxtParser
4
 *
5
 * @link https://github.com/VIPnytt/RobotsTxtParser
6
 * @license https://github.com/VIPnytt/RobotsTxtParser/blob/master/LICENSE The MIT License (MIT)
7
 */
8
9
namespace vipnytt\RobotsTxtParser\Parser\Directives;
10
11
use vipnytt\RobotsTxtParser\Client\Directives\HostClient;
12
use vipnytt\RobotsTxtParser\Handler\RenderHandler;
13
14
/**
15
 * Class HostParser
16
 *
17
 * @package vipnytt\RobotsTxtParser\Parser\Directives
18
 */
19
class HostParser extends HostParserCore
20
{
21
    /**
22
     * HostParser constructor.
23
     *
24
     * @param string $base
25
     * @param string $effective
26
     */
27
    public function __construct($base, $effective)
28
    {
29
        parent::__construct($base, $effective);
30
    }
31
32
    /**
33
     * Client
34
     *
35
     * @return HostClient
36
     */
37
    public function client()
38
    {
39
        return new HostClient($this->base, $this->effective, isset($this->host[0]) ? [$this->host[0]] : []);
40
    }
41
42
    /**
43
     * Render
44
     *
45
     * @param RenderHandler $handler
46
     * @return bool
47
     */
48
    public function render(RenderHandler $handler)
49
    {
50
        if (isset($this->host[0])) {
51
            $handler->add(self::DIRECTIVE_HOST, $this->host[0]);
52
        }
53
        return true;
54
    }
55
}
56