Message::find()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 6
Ratio 100 %

Importance

Changes 0
Metric Value
dl 6
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
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