Completed
Branch new-addon-api (b7bde0)
by
unknown
18:29 queued 08:41
created

AddonCollection::addAddon()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace EventEspresso\core\services\addon;
4
5
use EventEspresso\core\exceptions\InvalidInterfaceException;
6
use EventEspresso\core\services\addon\api\AddonApiVersion;
7
use EventEspresso\core\services\collections\Collection;
8
9
/**
10
 * Class AddonCollection
11
 *
12
 * @author  Brent Christensen
13
 * @package EventEspresso\core\services\addon
14
 * @since   $VID:$
15
 */
16
class AddonCollection extends Collection
17
{
18
19
    /**
20
     * @throws InvalidInterfaceException
21
     */
22
    public function __construct()
23
    {
24
        parent::__construct(AddonApiVersion::class);
25
    }
26
27
28
    /**
29
     * @param AddonApiVersion $addon
30
     * @return bool
31
     */
32
    public function addAddon(AddonApiVersion $addon): bool
33
    {
34
        return $this->add($addon, $addon->slug());
35
    }
36
37
38
    /**
39
     * @param string $addon_slug
40
     * @return AddonApiVersion|null
41
     */
42
    public function getAddon(string $addon_slug): ?AddonApiVersion
43
    {
44
        return $this->get($addon_slug);
45
    }
46
47
48
    /**
49
     * @param string $addon_slug
50
     * @return bool
51
     */
52
    public function hasAddon(string $addon_slug): bool
53
    {
54
        return $this->has($addon_slug);
55
    }
56
}
57