Company::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 1
rs 9.4285
1
<?php
2
3
namespace Manavo\DoneDone;
4
5
class Company
6
{
7
8
    /**
9
     * @var Client
10
     */
11
    private $client;
12
13
    /**
14
     * @var int
15
     */
16
    private $id;
17
18
    /**
19
     * @var string
20
     */
21
    private $name = null;
22
23
    /**
24
     * @param Client $client
25
     * @param int $id
26
     */
27 12
    function __construct($client = null, $id = null)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
28
    {
29 12
        $this->client = $client;
30 12
        $this->id = $id;
31 12
    }
32
33
    /**
34
     * @param string $name
35
     */
36 3
    public function setName($name)
37
    {
38 3
        $this->name = $name;
39 3
    }
40
41
    /**
42
     * Update the name of a company
43
     *
44
     * @param string $newName
45
     * @return array
46
     */
47 3
    public function updateName($newName)
48
    {
49 3
        return $this->client->put('companies/'.$this->id, [
50
            'company_name' => $newName
51 3
        ]);
52
    }
53
54
    /**
55
     * @return array
56
     */
57 9
    public function toArray()
58
    {
59
        $data = [
60 9
            'company_name' => $this->name,
61 9
        ];
62
63 9
        return $data;
64
    }
65
66
}
67