Options::getApiVersion()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * FreeIPA library for PHP
5
 * Copyright (C) 2015-2019 Tobias Sette <[email protected]>
6
 *
7
 * This program is free software: you can redistribute it and/or modify
8
 * it under the terms of the GNU Lesser General Public License as published by
9
 * the Free Software Foundation, either version 3 of the License, or
10
 * (at your option) any later version.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 * GNU Lesser General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU Lesser General Public License
18
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
 */
20
declare(strict_types=1);
21
22
namespace Gnumoksha\FreeIpa;
23
24
class Options
25
{
26
    private $host;
27
    private $certificatePath;
28
    private $primaryUrl;
29
    private $apiVersion;
30
31
    public function __construct(
32
        string $host,
33
        string $certificatePath,
34
        string $primaryUrl = null,
35
        string $apiVersion = null
36
    ) {
37
        if ($primaryUrl === null) {
38
            $primaryUrl = sprintf('https://%s/ipa', $host);
39
        }
40
        if ($apiVersion === null) {
41
            $apiVersion = '2.233';
42
        }
43
44
        $this->host            = $host;
45
        $this->certificatePath = $certificatePath;
46
        $this->primaryUrl      = $primaryUrl;
47
        $this->apiVersion      = $apiVersion;
48
    }
49
50
    public function getHost(): string
51
    {
52
        return $this->host;
53
    }
54
55
    public function getCertificatePath(): string
56
    {
57
        return $this->certificatePath;
58
    }
59
60
    public function getPrimaryUrl(): string
61
    {
62
        return $this->primaryUrl;
63
    }
64
65
    public function getApiVersion(): ?string
66
    {
67
        return $this->apiVersion;
68
    }
69
}
70