Completed
Push — master ( a71797...df586c )
by Sergey
04:42 queued 02:16
created

Comments   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 65
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 4 1
A createPrivate() 0 4 1
A edit() 0 7 1
A editPrivate() 0 4 1
A delete() 0 4 1
1
<?php
2
3
namespace seregazhuk\HeadHunterApi\EndPoints;
4
5
use seregazhuk\HeadHunterApi\Traits\HasView;
6
7
class Comments extends Endpoint
8
{
9
    use HasView;
10
11
    const RESOURCE = 'applicant_comments';
12
13
    const COMMENT_TYPE_PUBLIC = 'coworkers';
14
    const COMMENT_TYPE_PRIVATE = 'owner';
15
16
    /**
17
     * @param string $applicantId
18
     * @param string $text
19
     * @param string $type
20
     * @return mixed
21
     */
22
    public function create($applicantId, $text, $type = self::COMMENT_TYPE_PUBLIC)
23
    {
24
        return $this->postResource($applicantId, ['text' => $text, 'access_type' => $type]);
25
    }
26
27
    /**
28
     * @param string $applicantId
29
     * @param string $text
30
     * @return mixed
31
     */
32
    public function createPrivate($applicantId, $text)
33
    {
34
        return $this->create($applicantId, $text, self::COMMENT_TYPE_PRIVATE);
35
    }
36
37
    /**
38
     * @param string $applicantId
39
     * @param string $commentId
40
     * @param string $text
41
     * @param string $type
42
     * @return mixed
43
     */
44
    public function edit($applicantId, $commentId, $text, $type = self::COMMENT_TYPE_PUBLIC)
45
    {
46
        return $this->putResource(
47
            "$applicantId/$commentId",
48
            ['text' => $text, 'access_type' => $type]
49
        );
50
    }
51
52
    /**
53
     * @param string $applicantId
54
     * @param string $commentId
55
     * @param string $text
56
     * @return mixed
57
     */
58
    public function editPrivate($applicantId, $commentId, $text)
59
    {
60
        return $this->edit($applicantId, $commentId, $text, self::COMMENT_TYPE_PRIVATE);
61
    }
62
63
    /**
64
     * @param string $applicantId
65
     * @param string $commentId
66
     */
67
    public function delete($applicantId, $commentId)
68
    {
69
        $this->deleteResource("$applicantId/$commentId");
70
    }
71
}