Completed
Push — master ( a378ab...305f92 )
by Philip
08:21 queued 05:36
created

Company   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Test Coverage

Coverage 78.56%

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 11
cts 14
cp 0.7856
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setName() 0 4 1
A __construct() 0 5 1
A toArray() 0 8 1
A updateName() 0 6 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 9
    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 9
        $this->client = $client;
30 9
        $this->id = $id;
31 9
    }
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
    public function updateName($newName)
48
    {
49
        return $this->client->put('companies/'.$this->id, [
50
            'company_name' => $newName
51
        ]);
52
    }
53
54
    /**
55
     * @return array
56
     */
57 6
    public function toArray()
58
    {
59
        $data = [
60 6
            'company_name' => $this->name,
61 6
        ];
62
63 6
        return $data;
64
    }
65
66
}
67