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

AddonCollection   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 41
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 2

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A addAddon() 0 4 1
A getAddon() 0 4 1
A hasAddon() 0 4 1
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