UpdatedUsersRequestBuilder::addUser()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 3
c 0
b 0
f 0
ccs 3
cts 3
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace SchulIT\IdpExchange\Request\Builder;
4
5
use SchulIT\IdpExchange\Request\UpdatedUsersRequest;
6
7
class UpdatedUsersRequestBuilder {
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class UpdatedUsersRequestBuilder
Loading history...
Coding Style introduced by
Opening brace of a class must be on the line after the definition
Loading history...
8
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
9
     * @var string[]
10
     */
11
    private $usernames = [ ];
0 ignored issues
show
Coding Style introduced by
Private member variable "usernames" must be prefixed with an underscore
Loading history...
12
13
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
14
     * @var \DateTime
15
     */
16
    private $since = null;
0 ignored issues
show
Coding Style introduced by
Private member variable "since" must be prefixed with an underscore
Loading history...
17
18
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
19
     * @param string $username
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
20
     * @return $this
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
21
     */
22 1
    public function addUser(string $username): UpdatedUsersRequestBuilder {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on a new line
Loading history...
23 1
        $this->usernames[] = $username;
24 1
        return $this;
25
    }
26
27
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
28
     * @param string[] $users
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
29
     * @return UpdatedUsersRequestBuilder
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
30
     */
31 2
    public function addUsers(array $users): UpdatedUsersRequestBuilder {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on a new line
Loading history...
32 2
        $this->usernames = array_merge($this->usernames, $users);
33 2
        return $this;
34
    }
35
36
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
37
     * @param \DateTime $dateTime
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
38
     * @return UpdatedUsersRequestBuilder
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
39
     */
40
    public function since(\DateTime $dateTime): UpdatedUsersRequestBuilder {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on a new line
Loading history...
41
        $this->since = $dateTime;
42
        return $this;
43
    }
44
45
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
46
     * @return UpdatedUsersRequest
47
     */
48 3
    public function build(): UpdatedUsersRequest {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on a new line
Loading history...
49 3
        $request = new UpdatedUsersRequest();
50 3
        $request->usernames = $this->usernames;
51 3
        if($this->since !== null) {
0 ignored issues
show
Coding Style introduced by
Expected "if (...) {\n"; found "if(...) {\n"
Loading history...
52
            $request->since = clone $this->since;
53
        }
54
55 3
        return $request;
56
    }
57
}