Issues (12)

src/Builder/ServiceProviderConfigBuilder.php (1 issue)

1
<?php
2
3
/*
4
 * This file is part of the tmilos/scim-schema package.
5
 *
6
 * (c) Milos Tomic <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Tmilos\ScimSchema\Builder;
13
14
use Tmilos\ScimSchema\Model\ServiceProviderConfig;
15
use Tmilos\ScimSchema\Model\SPC\AuthenticationScheme;
16
17
abstract class ServiceProviderConfigBuilder
18
{
19
    /** @var string */
20
    private $locationBase = 'http://localhost';
21
22
    /** @var string */
23
    protected $documentationUri;
24
25
    /** @var bool */
26
    protected $patchSupported = false;
27
28
    /** @var bool */
29
    protected $bulkSupported = false;
30
31
    /** @var int */
32
    protected $bulkMaxOperations = 100;
33
34
    /** @var int */
35
    protected $bulkMaxPayloadSize = 1048576;
36
37
    /** @var false */
38
    protected $filterSupported = false;
39
40
    /** @var int */
41
    protected $filterMaxResults = 100;
42
43
    /** @var bool */
44
    protected $eTagSupported = false;
45
46
    /** @var bool */
47
    protected $changePasswordSupported = false;
48
49
    /** @var bool */
50
    protected $sortSupported = false;
51
52
    /** @var array */
53
    protected $authenticationSchemes = [];
54
55
    /**
56
     /**
57
     * @param string $locationBase
58
     */
59
    public function __construct($locationBase = 'http://localhost')
60
    {
61
        $this->setLocationBase($locationBase);
62
    }
63
64
    /**
65
     * @param string $locationBase
66
     */
67
    public function setLocationBase($locationBase)
68
    {
69
        $this->locationBase = rtrim($locationBase, '/');
70
    }
71
72
    /**
73
     * @return ServiceProviderConfig
74
     */
75
    abstract public function buildServiceProviderConfig();
76
77
    /**
78
     * @param string $documentationUri
79
     *
80
     * @return ServiceProviderConfigBuilder
81
     */
82
    public function setDocumentationUri($documentationUri)
83
    {
84
        $this->documentationUri = $documentationUri;
85
86
        return $this;
87
    }
88
89
    /**
90
     * @param bool $patchSupported
91
     *
92
     * @return ServiceProviderConfigBuilder
93
     */
94
    public function setPatchSupported($patchSupported)
95
    {
96
        $this->patchSupported = (bool) $patchSupported;
97
98
        return $this;
99
    }
100
101
    /**
102
     * @param bool $bulkSupported
103
     *
104
     * @return ServiceProviderConfigBuilder
105
     */
106
    public function setBulkSupported($bulkSupported)
107
    {
108
        $this->bulkSupported = (bool) $bulkSupported;
109
110
        return $this;
111
    }
112
113
    /**
114
     * @param int $bulkMaxOperations
115
     *
116
     * @return ServiceProviderConfigBuilder
117
     */
118
    public function setBulkMaxOperations($bulkMaxOperations)
119
    {
120
        $this->bulkMaxOperations = (int) $bulkMaxOperations;
121
122
        return $this;
123
    }
124
125
    /**
126
     * @param int $bulkMaxPayloadSize
127
     *
128
     * @return ServiceProviderConfigBuilder
129
     */
130
    public function setBulkMaxPayloadSize($bulkMaxPayloadSize)
131
    {
132
        $this->bulkMaxPayloadSize = (int) $bulkMaxPayloadSize;
133
134
        return $this;
135
    }
136
137
    /**
138
     * @param false $filterSupported
139
     *
140
     * @return ServiceProviderConfigBuilder
141
     */
142
    public function setFilterSupported($filterSupported)
143
    {
144
        $this->filterSupported = (bool) $filterSupported;
0 ignored issues
show
Documentation Bug introduced by
The property $filterSupported was declared of type false, but (bool)$filterSupported is of type boolean. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
145
146
        return $this;
147
    }
148
149
    /**
150
     * @param int $filterMaxResults
151
     *
152
     * @return ServiceProviderConfigBuilder
153
     */
154
    public function setFilterMaxResults($filterMaxResults)
155
    {
156
        $this->filterMaxResults = (int) $filterMaxResults;
157
158
        return $this;
159
    }
160
161
    /**
162
     * @param bool $eTagSupported
163
     *
164
     * @return ServiceProviderConfigBuilder
165
     */
166
    public function setETagSupported($eTagSupported)
167
    {
168
        $this->eTagSupported = (bool) $eTagSupported;
169
170
        return $this;
171
    }
172
173
    /**
174
     * @param bool $changePasswordSupported
175
     *
176
     * @return ServiceProviderConfigBuilder
177
     */
178
    public function setChangePasswordSupported($changePasswordSupported)
179
    {
180
        $this->changePasswordSupported = (bool) $changePasswordSupported;
181
182
        return $this;
183
    }
184
185
    /**
186
     * @param bool $sortSupported
187
     *
188
     * @return ServiceProviderConfigBuilder
189
     */
190
    public function setSortSupported($sortSupported)
191
    {
192
        $this->sortSupported = (bool) $sortSupported;
193
194
        return $this;
195
    }
196
197
    /**
198
     * @param AuthenticationScheme $authenticationScheme
199
     *
200
     * @return ServiceProviderConfigBuilder
201
     */
202
    public function addAuthenticationScheme(AuthenticationScheme $authenticationScheme)
203
    {
204
        $this->authenticationSchemes[] = $authenticationScheme;
205
206
        return $this;
207
    }
208
}
209