Completed
Push — master ( 228ec0...89e623 )
by Jan-Petter
04:43
created

CommentClient   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 5
Bugs 1 Features 0
Metric Value
wmc 4
c 5
b 1
f 0
lcom 1
cbo 0
dl 0
loc 54
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A get() 0 4 2
A export() 0 4 1
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\Client\Directives;
10
11
use vipnytt\RobotsTxtParser\RobotsTxtInterface;
12
13
/**
14
 * Class CommentClient
15
 *
16
 * @see https://github.com/VIPnytt/RobotsTxtParser/blob/master/docs/methods/CommentClient.md for documentation
17
 * @package vipnytt\RobotsTxtParser\Client\Directives
18
 */
19
class CommentClient implements ClientInterface, RobotsTxtInterface
20
{
21
    /**
22
     * Base uri
23
     * @var string
24
     */
25
    private $base;
26
27
    /**
28
     * User-agent
29
     * @var string
30
     */
31
    private $userAgent;
32
33
    /**
34
     * Comments
35
     * @var string[]
36
     */
37
    private $comments = [];
38
39
    /**
40
     * CommentClient constructor.
41
     *
42
     * @param string $base
43
     * @param string $userAgent
44
     * @param array $comments
45
     */
46
    public function __construct($base, $userAgent, array $comments)
47
    {
48
        $this->base = $base;
49
        $this->userAgent = $userAgent;
50
        $this->comments = $comments;
51
    }
52
53
    /**
54
     * Get
55
     *
56
     * @return string[]
57
     */
58
    public function get()
59
    {
60
        return $this->userAgent == self::USER_AGENT ? [] : $this->export();
61
    }
62
63
    /**
64
     * Export
65
     *
66
     * @return string[]
67
     */
68
    public function export()
69
    {
70
        return $this->comments;
71
    }
72
}
73