ImageShortcodes::getImage()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 1
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace ByTIC\MediaLibrary\HasMedia\StandardCollections;
4
5
use ByTIC\MediaLibrary\Collections\Collection;
6
use ByTIC\MediaLibrary\Media\Media;
7
8
/**
9
 * Trait StandardCollectionsShortcodes.
10
 */
11
trait ImageShortcodes
12
{
13
    /**
14
     * @return Media
15
     */
16
    public function getImage()
17
    {
18
        return $this->getMedia('images')->getDefaultMedia();
19
    }
20
21
    /**
22
     * @return Collection|Media[]
23
     */
24
    public function getImages()
25
    {
26
        return $this->getMedia('images');
27
    }
28
29
    /**
30
     * @return Media
31
     */
32
    public function getLogo()
33
    {
34
        return $this->getMedia('logos')->getDefaultMedia();
35
    }
36
37
    /**
38
     * @return Collection|Media[]
39
     */
40
    public function getLogos()
41
    {
42
        return $this->getMedia('logos');
43
    }
44
45
    /**
46
     * @return bool
47
     */
48
    public function hasLogo()
49
    {
50
        return $this->getMedia('logos')->count() > 0;
51
    }
52
53
    /**
54
     * @return Media
55
     */
56
    public function getCover()
57
    {
58
        return $this->getMedia('covers')->getDefaultMedia();
59
    }
60
61
    /**
62
     * @return Collection
63
     */
64
    public function getCovers()
65
    {
66
        return $this->getMedia('covers');
67
    }
68
69
    /**
70
     * @return bool
71
     */
72
    public function hasCover()
73
    {
74
        return $this->getMedia('covers')->count() > 0;
75
    }
76
77
    /**
78
     * @param string $collectionName
79
     * @param array  $filters
80
     *
81
     * @return Collection
82
     */
83
    abstract public function getMedia(string $collectionName = 'default', $filters = []): Collection;
84
}
85