Code Duplication    Length = 75-76 lines in 2 locations

src/Resources/Comment.php 1 location

@@ 21-95 (lines=75) @@
18
 * @internal
19
 * @package Freshdesk\Resources
20
 */
21
class Comment extends AbstractResource
22
{
23
24
    use ViewTrait, UpdateTrait, DeleteTrait;
25
26
    /**
27
     * The topic resource endpoint
28
     *
29
     * @var string
30
     */
31
    protected $endpoint ='/discussions/comments' ;
32
33
    /**
34
     * The forums resource endpoint
35
     *
36
     * @var string
37
     */
38
    private $topicsEndpoint = '/discussions/topics';
39
40
    /**
41
     * Creates the forums endpoint
42
     * @param null $id
43
     * @return string
44
     */
45
    protected function topicsEndpoint($id = null)
46
    {
47
        return $id == null ? $this->topicsEndpoint : $this->topicsEndpoint . '/' . $id;
48
    }
49
50
    /**
51
     *
52
     * Create a topic for a forum
53
     *
54
     * @param int $id
55
     * @param array $data
56
     * @return array|null
57
     * @throws \Freshdesk\Exceptions\AccessDeniedException
58
     * @throws \Freshdesk\Exceptions\ApiException
59
     * @throws \Freshdesk\Exceptions\AuthenticationException
60
     * @throws \Freshdesk\Exceptions\ConflictingStateException
61
     * @throws \Freshdesk\Exceptions\NotFoundException
62
     * @throws \Freshdesk\Exceptions\RateLimitExceededException
63
     * @throws \Freshdesk\Exceptions\UnsupportedContentTypeException
64
     * @throws \Freshdesk\Exceptions\MethodNotAllowedException
65
     * @throws \Freshdesk\Exceptions\UnsupportedAcceptHeaderException
66
     * @throws \Freshdesk\Exceptions\ValidationException
67
     */
68
    public function create($id, array $data)
69
    {
70
        return $this->api()->request('POST', $this->topicsEndpoint($id . '/topics'), $data);
71
    }
72
73
    /**
74
     *
75
     * List comments in a topic
76
     *
77
     * @param int $id
78
     * @param array $query
79
     * @return array|null
80
     * @throws \Freshdesk\Exceptions\AccessDeniedException
81
     * @throws \Freshdesk\Exceptions\ApiException
82
     * @throws \Freshdesk\Exceptions\AuthenticationException
83
     * @throws \Freshdesk\Exceptions\ConflictingStateException
84
     * @throws \Freshdesk\Exceptions\NotFoundException
85
     * @throws \Freshdesk\Exceptions\RateLimitExceededException
86
     * @throws \Freshdesk\Exceptions\UnsupportedContentTypeException
87
     * @throws \Freshdesk\Exceptions\MethodNotAllowedException
88
     * @throws \Freshdesk\Exceptions\UnsupportedAcceptHeaderException
89
     * @throws \Freshdesk\Exceptions\ValidationException
90
     */
91
    public function all($id, array $query = null)
92
    {
93
        return $this->api()->request('GET', $this->topicsEndpoint($id . '/comments'), null, $query);
94
    }
95
}
96

src/Resources/Topic.php 1 location

@@ 21-96 (lines=76) @@
18
 * @internal
19
 * @package Freshdesk\Resources
20
 */
21
class Topic extends AbstractResource
22
{
23
24
    use ViewTrait, UpdateTrait, DeleteTrait, MonitorTrait;
25
26
    /**
27
     * The topic resource endpoint
28
     *
29
     * @var string
30
     */
31
    protected $endpoint = '/discussions/topics';
32
33
    /**
34
     * The forums resource endpoint
35
     *
36
     * @var string
37
     */
38
    private $forumsEndpoint = '/discussions/forums';
39
40
    /**
41
     * Creates the forums endpoint
42
     * @param null $id
43
     * @return string
44
     */
45
    protected function forumsEndpoint($id = null)
46
    {
47
        return $id == null ? $this->forumsEndpoint : $this->forumsEndpoint . '/' . $id;
48
    }
49
50
    /**
51
     *
52
     * Create a topic for a forum
53
     *
54
     * @param int $id
55
     * @param array $data
56
     * @return array|null
57
     * @throws \Freshdesk\Exceptions\AccessDeniedException
58
     * @throws \Freshdesk\Exceptions\ApiException
59
     * @throws \Freshdesk\Exceptions\AuthenticationException
60
     * @throws \Freshdesk\Exceptions\ConflictingStateException
61
     * @throws \Freshdesk\Exceptions\NotFoundException
62
     * @throws \Freshdesk\Exceptions\RateLimitExceededException
63
     * @throws \Freshdesk\Exceptions\UnsupportedContentTypeException
64
     * @throws \Freshdesk\Exceptions\MethodNotAllowedException
65
     * @throws \Freshdesk\Exceptions\UnsupportedAcceptHeaderException
66
     * @throws \Freshdesk\Exceptions\ValidationException
67
     */
68
    public function create($id, array $data)
69
    {
70
        return $this->api()->request('POST', $this->forumsEndpoint($id . '/topics'), $data);
71
    }
72
73
    /**
74
     *
75
     * List topics in a forum
76
     *
77
     * @param int $id
78
     * @param array|null $query
79
     * @return array|null
80
     * @throws \Freshdesk\Exceptions\AccessDeniedException
81
     * @throws \Freshdesk\Exceptions\ApiException
82
     * @throws \Freshdesk\Exceptions\AuthenticationException
83
     * @throws \Freshdesk\Exceptions\ConflictingStateException
84
     * @throws \Freshdesk\Exceptions\NotFoundException
85
     * @throws \Freshdesk\Exceptions\RateLimitExceededException
86
     * @throws \Freshdesk\Exceptions\UnsupportedContentTypeException
87
     * @throws \Freshdesk\Exceptions\MethodNotAllowedException
88
     * @throws \Freshdesk\Exceptions\UnsupportedAcceptHeaderException
89
     * @throws \Freshdesk\Exceptions\ValidationException
90
     */
91
    public function all($id, array $query = null)
92
    {
93
        return $this->api()->request('GET', $this->forumsEndpoint($id . '/topics'), null, $query);
94
    }
95
96
}
97