Issues (10)

src/Flickr.php (3 issues)

1
<?php
2
3
namespace JeroenG\Flickr;
4
5
class Flickr
6
{
7
    public Api $api;
8
9
    public function __construct(Api $api)
10
    {
11
        $this->api = $api;
12
    }
13
14
    public function request(string $method, ?array $parameters = null): Response
15
    {
16
        return $this->api->request($method, $parameters);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->api->request($method, $parameters) could return the type string which is incompatible with the type-hinted return JeroenG\Flickr\Response. Consider adding an additional type-check to rule them out.
Loading history...
17
    }
18
19
    /**
20
     * Flickr echo request, for testing purposes.
21
     */
22
    public function echoThis(string $string): Response
23
    {
24
        return $this->request('flickr.test.echo', ['this' => $string]);
25
    }
26
27
    /**
28
     * Get a list of photosets.
29
     */
30
    public function listSets(?array $parameters = null): Response
31
    {
32
        return $this->request('flickr.photosets.getList', $parameters);
33
    }
34
35
    /**
36
     * Get all photos in a photoset.
37
     */
38
    public function photosForSet(string $setId, string $userId, ?array $otherParameters = null): Response
39
    {
40
        $parameters['photoset_id'] = $setId;
0 ignored issues
show
Comprehensibility Best Practice introduced by
$parameters was never initialized. Although not strictly required by PHP, it is generally a good practice to add $parameters = array(); before regardless.
Loading history...
41
        $parameters['user_id'] = $userId;
42
43
        if (is_array($otherParameters)) {
44
            $parameters = array_merge($parameters, $otherParameters);
45
        }
46
47
        return $this->request('flickr.photosets.getPhotos', $parameters);
48
    }
49
50
    /**
51
     * Get all info on a photo.
52
     */
53
    public function photoInfo(string $photoId, ?string $secretId = null): Response
54
    {
55
        $parameters['photo_id'] = $photoId;
0 ignored issues
show
Comprehensibility Best Practice introduced by
$parameters was never initialized. Although not strictly required by PHP, it is generally a good practice to add $parameters = array(); before regardless.
Loading history...
56
57
        if (! is_null($secretId)) {
58
            $parameters['secret'] = $secretId;
59
        }
60
61
        return $this->request('flickr.photos.getInfo', $parameters);
62
    }
63
}
64