Completed
Push — master ( a81ea2...e23c5c )
by Gabriel
03:24
created

ImageShortcodes::getCovers()   A

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 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
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
 * @method Collection getMedia(string $collectionName = 'default', $filters = []): Collection
12
 */
13
trait ImageShortcodes
14
{
15
    /**
16
     * @return Media
17
     */
18
    public function getImage()
19
    {
20
        return $this->getMedia('images')->getDefaultMedia();
21
    }
22
23
    /**
24
     * @return Collection|Media[]
25
     */
26
    public function getImages()
27
    {
28
        return $this->getMedia('images');
29
    }
30
31
    /**
32
     * @return Media
33
     */
34
    public function getLogo()
35
    {
36
        return $this->getMedia('logos')->getDefaultMedia();
37
    }
38
39
    /**
40
     * @return Collection|Media[]
41
     */
42
    public function getLogos()
43
    {
44
        return $this->getMedia('logos');
45
    }
46
47
    /**
48
     * @return bool
49
     */
50
    public function hasLogo()
51
    {
52
        return $this->getMedia('logos')->count() > 0;
53
    }
54
55
    /**
56
     * @return Media
57
     */
58
    public function getCover()
59
    {
60
        return $this->getMedia('covers')->getDefaultMedia();
61
    }
62
63
    /**
64
     * @return Collection
65
     */
66
    public function getCovers()
67
    {
68
        return $this->getMedia('covers');
69
    }
70
71
    /**
72
     * @return bool
73
     */
74
    public function hasCover()
75
    {
76
        return $this->getMedia('covers')->count() > 0;
77
    }
78
}
79