Completed
Push — master ( 992188...6b183b )
by Tobias
06:43
created

LocoProject::isMultiDomain()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 0
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
/*
4
 * This file is part of the PHP Translation package.
5
 *
6
 * (c) PHP Translation team <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Translation\PlatformAdapter\Loco\Model;
13
14
/**
15
 * Represents a project from loco.
16
 */
17
final class LocoProject
18
{
19
    /**
20
     * @var string
21
     */
22
    private $name;
23
24
    /**
25
     * @var string
26
     */
27
    private $apiKey;
28
29 3
    /**
30
     * @var string
31 3
     */
32 3
    private $indexParameter;
33 3
34 3
    /**
35
     * @var array
36
     */
37
    private $domains;
38
39 1
    /**
40
     * @param string $name
41 1
     * @param array  $config
42
     */
43
    public function __construct(string $name, array $config)
44
    {
45
        $this->name = $name;
46
        $this->apiKey = $config['api_key'] ?? null;
47 1
        $this->indexParameter = $config['index_parameter'] ?? null;
48
        $this->domains = empty($config['domains']) ? [$name] : $config['domains'];
49 1
    }
50
51
    /**
52
     * @return string
53
     */
54
    public function getName()
55 1
    {
56
        return $this->name;
57 1
    }
58
59
    /**
60
     * @return string|null
61
     */
62
    public function getApiKey()
63
    {
64
        return $this->apiKey;
65
    }
66
67
    /**
68
     * @return string|null
69
     */
70
    public function getIndexParameter()
71
    {
72
        return $this->indexParameter;
73
    }
74
75
    /**
76
     * @return array
77
     */
78
    public function getDomains()
79
    {
80
        return $this->domains;
81
    }
82
83
    /**
84
     * @param string $domain
85
     *
86
     * @return bool
87
     */
88
    public function hasDomain(string $domain)
89
    {
90
        return in_array($domain, $this->domains);
91
    }
92
93
    /**
94
     * @return bool Returning true means that domains are expected to be managed with tags.
95
     */
96
    public function isMultiDomain()
97
    {
98
        return count($this->domains) > 1;
99
    }
100
}
101