OrganizationOptions::setName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
crap 1
1
<?php
2
3
/**
4
 * Copyright 2017 American Express Travel Related Services Company, Inc.
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 * http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
15
 * or implied. See the License for the specific language governing
16
 * permissions and limitations under the License.
17
 */
18
19
declare(strict_types=1);
20
21
namespace AmericanExpress\HyperledgerFabricClient\Organization;
22
23
use AmericanExpress\HyperledgerFabricClient\Options\AbstractOptions;
24
use AmericanExpress\HyperledgerFabricClient\Peer\PeerOptions;
25
use AmericanExpress\HyperledgerFabricClient\Peer\PeerOptionsInterface;
26
27
class OrganizationOptions extends AbstractOptions implements OrganizationOptionsInterface
28
{
29
    /**
30
     * @var string|null
31
     */
32
    private $name;
33
34
    /**
35
     * @var string|null
36
     */
37
    private $mspId;
38
39
    /**
40
     * @var string[]
41
     */
42
    private $ca = [];
43
44
    /**
45
     * @var string|null
46
     */
47
    private $adminCerts;
48
49
    /**
50
     * @var string|null
51
     */
52
    private $privateKey;
53
54
    /**
55
     * @var PeerOptions[]
56
     */
57
    private $peers = [];
58
59
    /**
60
     * @return string|null
61
     */
62 2
    public function getName(): ?string
63
    {
64 2
        return $this->name;
65
    }
66
67
    /**
68
     * @param string $name
69
     * @return void
70
     */
71 2
    public function setName(string $name): void
72
    {
73 2
        $this->name = $name;
74 2
    }
75
76
    /**
77
     * @return string|null
78
     */
79 2
    public function getMspId(): ?string
80
    {
81 2
        return $this->mspId;
82
    }
83
84
    /**
85
     * @param string $mspId
86
     * @return void
87
     */
88 2
    public function setMspId(string $mspId): void
89
    {
90 2
        $this->mspId = $mspId;
91 2
    }
92
93
    /**
94
     * @return string[]
95
     */
96 2
    public function getCa(): array
97
    {
98 2
        return $this->ca;
99
    }
100
101
    /**
102
     * @param string[] $ca
103
     * @return void
104
     */
105 2
    public function setCa(array $ca): void
106
    {
107 2
        $this->ca = $ca;
108 2
    }
109
110
    /**
111
     * @return string|null
112
     */
113 2
    public function getAdminCerts(): ?string
114
    {
115 2
        return $this->adminCerts;
116
    }
117
118
    /**
119
     * @param string $adminCerts
120
     * @return void
121
     */
122 2
    public function setAdminCerts(string $adminCerts): void
123
    {
124 2
        $this->adminCerts = $adminCerts;
125 2
    }
126
127
    /**
128
     * @return string|null
129
     */
130 2
    public function getPrivateKey(): ?string
131
    {
132 2
        return $this->privateKey;
133
    }
134
135
    /**
136
     * @param string $privateKey
137
     * @return void
138
     */
139 2
    public function setPrivateKey(string $privateKey): void
140
    {
141 2
        $this->privateKey = $privateKey;
142 2
    }
143
144
    /**
145
     * @return PeerOptions[]
146
     */
147 2
    public function getPeers(): array
148
    {
149 2
        return $this->peers;
150
    }
151
152
    /**
153
     * @param array|PeerOptions[] $peers
154
     * @return void
155
     * @throws \AmericanExpress\HyperledgerFabricClient\Exception\BadMethodCallException
156
     */
157
    public function setPeers(array $peers): void
158
    {
159 2
        $this->peers = array_map(function ($peer): PeerOptionsInterface {
160 2
            return $peer instanceof PeerOptionsInterface ? $peer : new PeerOptions($peer);
161 2
        }, $peers);
162 2
    }
163
}
164