Company   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
c 2
b 0
f 0
lcom 2
cbo 1
dl 0
loc 62
ccs 14
cts 14
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setName() 0 4 1
A __construct() 0 5 1
A updateName() 0 6 1
A toArray() 0 8 1
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