Photos   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 78
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 78
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A photos() 0 7 1
A photo() 0 7 1
A randomPhoto() 0 7 1
A photosStatistics() 0 7 1
A trackPhotoDownload() 0 7 1
1
<?php
2
3
namespace MarkSitko\LaravelUnsplash\Endpoints;
4
5
trait Photos
6
{
7
    /**
8
     * List photos
9
     * Get a single page from the list of all photos.
10
     * @link https://unsplash.com/documentation#list-photos
11
     *
12
     * @return MarkSitko\LaravelUnsplash\Endpoints\Photos
13
     */
14
    public function photos()
15
    {
16
        $this->apiCall = [
0 ignored issues
show
Bug introduced by
The property apiCall does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
17
            'endpoint' => 'photos',
18
        ];
19
        return $this;
20
    }
21
22
    /**
23
     * Get a photo
24
     * Retrieve a single photo.
25
     * @link https://unsplash.com/documentation#get-a-photo
26
     *
27
     * @param string $id
28
     * @return MarkSitko\LaravelUnsplash\Endpoints\Photos
29
     */
30
    public function photo( $id )
31
    {
32
        $this->apiCall = [
33
            'endpoint' => "photos/{$id}",
34
        ];
35
        return $this;
36
    }
37
38
    /**
39
     * Get a random photo
40
     * @link https://unsplash.com/documentation#get-a-random-photo
41
     *
42
     * @return MarkSitko\LaravelUnsplash\Endpoints\Photos
43
     */
44
    public function randomPhoto()
45
    {
46
        $this->apiCall = [
47
            'endpoint' => 'photos/random',
48
        ];
49
        return $this;
50
    }
51
52
    /**
53
     * Get a photo’s statistics
54
     * @link https://unsplash.com/documentation#get-a-photos-statistics
55
     *
56
     * @param string $id
57
     * @return MarkSitko\LaravelUnsplash\Endpoints\Photos
58
     */
59
    public function photosStatistics($id)
60
    {
61
        $this->apiCall = [
62
            'endpoint' => "photos/{$id}/statistics",
63
        ];
64
        return $this;
65
    }
66
67
    /**
68
     * Track a photo download
69
     * @link https://unsplash.com/documentation#track-a-photo-download
70
     *
71
     * @param string $id
72
     * @return MarkSitko\LaravelUnsplash\Endpoints\Photos
73
     */
74
    public function trackPhotoDownload($id)
75
    {
76
        $this->apiCall = [
77
            'endpoint' => "photos/{$id}/download"
78
        ];
79
        return $this;
80
    }
81
82
}
83