TagQuery::findTopPosts()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 2
c 1
b 0
f 1
dl 0
loc 5
rs 10
cc 1
nc 1
nop 2
1
<?php
2
/**
3
 * Created for IG Client.
4
 * User: jakim <[email protected]>
5
 * Date: 16.03.2018
6
 */
7
8
namespace Jakim\Query;
9
10
11
use Jakim\Base\Query;
12
use jakim\ig\Endpoint;
13
use Jakim\Mapper\EdgeMedia;
14
use Jakim\Mapper\ExploreTags;
15
use Jakim\Model\MediaCollection;
16
use Jakim\Model\Tag;
17
18
class TagQuery extends Query
19
{
20
    protected $findOneByName;
21
    protected $findLatestMedia;
22
    protected $findTopPosts;
23
24
    public function __construct(
25
        $httpClient,
26
        ExploreTags $findOneByName = null,
27
        EdgeMedia $findLatestMedia = null,
28
        EdgeMedia $findTopPosts = null
29
    )
30
    {
31
        parent::__construct($httpClient);
32
        $this->findOneByName = $findOneByName;
33
        $this->findLatestMedia = $findLatestMedia;
34
        $this->findTopPosts = $findTopPosts;
35
    }
36
37
    public function findOneByName(string $tagName): Tag
38
    {
39
        $url = Endpoint::exploreTags($tagName);
40
41
        return $this->createResult($url, $this->findOneByName, false);
0 ignored issues
show
Bug introduced by
It seems like $this->findOneByName can also be of type null; however, parameter $mapper of Jakim\Base\Query::createResult() does only seem to accept Jakim\Base\Mapper, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

41
        return $this->createResult($url, /** @scrutinizer ignore-type */ $this->findOneByName, false);
Loading history...
42
    }
43
44
    public function findLatestMedia(string $tagName, bool $relations = false): MediaCollection
45
    {
46
        $url = Endpoint::exploreTags($tagName);
47
48
        return $this->createResult($url, $this->findLatestMedia, $relations);
0 ignored issues
show
Bug introduced by
It seems like $this->findLatestMedia can also be of type null; however, parameter $mapper of Jakim\Base\Query::createResult() does only seem to accept Jakim\Base\Mapper, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

48
        return $this->createResult($url, /** @scrutinizer ignore-type */ $this->findLatestMedia, $relations);
Loading history...
49
    }
50
51
    public function findTopPosts(string $tagName, bool $relations = false): MediaCollection
52
    {
53
        $url = Endpoint::exploreTags($tagName);
54
55
        return $this->createResult($url, $this->findTopPosts, $relations);
0 ignored issues
show
Bug introduced by
It seems like $this->findTopPosts can also be of type null; however, parameter $mapper of Jakim\Base\Query::createResult() does only seem to accept Jakim\Base\Mapper, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

55
        return $this->createResult($url, /** @scrutinizer ignore-type */ $this->findTopPosts, $relations);
Loading history...
56
    }
57
}