Message   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 48
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 48
loc 48
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A list() 8 8 1
A find() 6 6 1
A create() 8 8 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Groove\Api;
4
5
use Groove\Api;
6
use Groove\Models\Message as Model;
7
8 View Code Duplication
class Message extends Api
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
9
{
10
    /**
11
     * List messages for a ticket.
12
     *
13
     * @param  int $ticketNumber
14
     * @param  array $params
15
     * @return \Illuminate\Support\Collection
16
     */
17
    public function list($ticketNumber, $params = [])
18
    {
19
        $response = $this->client->get("tickets/$ticketNumber/messages", $params);
20
21
        return collect($response->messages)->transform(function ($ticket) {
22
            return new Model($ticket, $this->client);
23
        });
24
    }
25
26
    /**
27
     * Find a message.
28
     *
29
     * @param  int|string $messageID
30
     * @return Model
31
     */
32
    public function find($messageID)
33
    {
34
        $response = $this->client->get("messages/$messageID");
35
36
        return new Model($response->message, $this->client);
37
    }
38
39
    /**
40
     * Create a message for a ticket.
41
     *
42
     * @param  int $ticketNumber
43
     * @param  string $body
44
     * @param  array $params
45
     * @return Model
46
     */
47
    public function create($ticketNumber, $body, $params = [])
48
    {
49
        $params = array_merge(['body' => $body], $params);
50
51
        $response = $this->client->post("tickets/$ticketNumber/messages", $params);
52
53
        return new Model($response->message, $this->client);
54
    }
55
}
56