Completed
Push — master ( 21003f...1e77f8 )
by Sergey
04:08 queued 01:24
created

Artifacts   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

7 Methods

Rating   Name   Duplication   Size   Complexity  
A portfolio() 0 4 1
A photos() 0 4 1
A editPhoto() 0 4 1
A deletePhoto() 0 4 1
A uploadPhoto() 0 4 1
A uploadPortfolio() 0 4 1
A upload() 0 19 1
1
<?php
2
3
namespace seregazhuk\HeadHunterApi\EndPoints;
4
5
class Artifacts extends Endpoint
6
{
7
    const RESOURCE = 'artifacts';
8
9
    public function photos()
10
    {
11
        return $this->getResource('photo');
12
    }
13
14
    public function portfolio()
15
    {
16
        return $this->getResource('portfolio');
17
    }
18
19
    public function editPhoto($id, $attributes)
20
    {
21
        return $this->putResource($id, $attributes);
22
    }
23
24
    public function deletePhoto($id)
25
    {
26
        $this->deleteResource($id);
27
    }
28
29
    /**
30
     * @param string $file
31
     * @param string $description
32
     * @return array|null
33
     */
34
    public function uploadPhoto($file, $description = '')
35
    {
36
        return $this->upload('photo', $file, $description);
37
    }
38
39
    /**
40
     * @param string $file
41
     * @param string $description
42
     * @return array|null
43
     */
44
    public function uploadPortfolio($file, $description = '')
45
    {
46
        return $this->upload('portfolio', $file, $description);
47
    }
48
49
    /**
50
     * @param string $type
51
     * @param string $description
52
     * @param string $file
53
     * @return array|null
54
     */
55
    public function upload($type, $file, $description = '')
56
    {
57
        $data = [
58
            [
59
                'name' => 'type',
60
                'contents' => $type,
61
            ],
62
            [
63
                'name' => 'description',
64
                'contents' => $description,
65
            ],
66
            [
67
                'name' => 'file',
68
                'contents' => fopen($file, 'r'),
69
            ],
70
        ];
71
72
        return $this->postResourceFile('', $data);
73
    }
74
}