CommentClient::get()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
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
     * User-agent
23
     * @var string
24
     */
25
    private $userAgent;
26
27
    /**
28
     * Comments
29
     * @var string[]
30
     */
31
    private $comments = [];
32
33
    /**
34
     * CommentClient constructor.
35
     *
36
     * @param string $userAgent
37
     * @param array $comments
38
     */
39
    public function __construct($userAgent, array $comments)
40
    {
41
        $this->userAgent = $userAgent;
42
        $this->comments = $comments;
43
    }
44
45
    /**
46
     * Get
47
     *
48
     * @return string[]
49
     */
50
    public function get()
51
    {
52
        return $this->userAgent === self::USER_AGENT ? [] : $this->export();
53
    }
54
55
    /**
56
     * Export
57
     *
58
     * @return string[]
59
     */
60
    public function export()
61
    {
62
        return $this->comments;
63
    }
64
}
65