Code Duplication    Length = 75-76 lines in 2 locations

src/Resources/Comment.php 1 location

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

src/Resources/Topic.php 1 location

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