LocoProject::getName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 1
cts 1
cp 1
crap 1
rs 10
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
    public function __construct(string $name, array $config)
45
    {
46
        $this->name = $name;
47 1
        $this->apiKey = $config['api_key'] ?? null;
48
        $this->status = $config['status'] ?? null;
49 1
        $this->indexParameter = $config['index_parameter'] ?? null;
50
        $this->domains = empty($config['domains']) ? [$name] : $config['domains'];
51
    }
52
53
    public function getName(): string
54
    {
55 1
        return $this->name;
56
    }
57 1
58
    public function getApiKey(): ?string
59
    {
60
        return $this->apiKey;
61
    }
62
63
    public function getStatus(): ?string
64
    {
65
        return $this->status;
66
    }
67
68
    public function getIndexParameter(): ?string
69
    {
70
        return $this->indexParameter;
71
    }
72
73
    public function getDomains(): array
74
    {
75
        return $this->domains;
76
    }
77
78
    public function hasDomain(string $domain): bool
79
    {
80
        return \in_array($domain, $this->domains);
81
    }
82
83
    /**
84
     * Returning true means that domains are expected to be managed with tags.
85
     */
86
    public function isMultiDomain(): bool
87
    {
88
        return \count($this->domains) > 1;
89
    }
90
}
91