Completed
Push — master ( 029d2f...81ffde )
by Tobias
08:28
created

LocoProject::getIndexParameter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 0
cp 0
crap 2
rs 10
c 0
b 0
f 0
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 $status;
33 3
34 3
    /**
35
     * @var string
36
     */
37
    private $indexParameter;
38
39 1
    /**
40
     * @var array
41 1
     */
42
    private $domains;
43
44
    /**
45
     * @param string $name
46
     * @param array  $config
47 1
     */
48
    public function __construct(string $name, array $config)
49 1
    {
50
        $this->name = $name;
51
        $this->apiKey = $config['api_key'] ?? null;
52
        $this->status = $config['status'] ?? null;
53
        $this->indexParameter = $config['index_parameter'] ?? null;
54
        $this->domains = empty($config['domains']) ? [$name] : $config['domains'];
55 1
    }
56
57 1
    /**
58
     * @return string
59
     */
60
    public function getName()
61
    {
62
        return $this->name;
63
    }
64
65
    /**
66
     * @return string|null
67
     */
68
    public function getApiKey()
69
    {
70
        return $this->apiKey;
71
    }
72
73
    /**
74
     * @return string|null
75
     */
76
    public function getStatus()
77
    {
78
        return $this->status;
79
    }
80
81
    /**
82
     * @return string|null
83
     */
84
    public function getIndexParameter()
85
    {
86
        return $this->indexParameter;
87
    }
88
89
    /**
90
     * @return array
91
     */
92
    public function getDomains()
93
    {
94
        return $this->domains;
95
    }
96
97
    /**
98
     * @param string $domain
99
     *
100
     * @return bool
101
     */
102
    public function hasDomain(string $domain)
103
    {
104
        return in_array($domain, $this->domains);
105
    }
106
107
    /**
108
     * @return bool Returning true means that domains are expected to be managed with tags.
109
     */
110
    public function isMultiDomain()
111
    {
112
        return count($this->domains) > 1;
113
    }
114
}
115