Completed
Push — master ( db64b9...ae7f64 )
by WEBEWEB
01:40
created

AbstractManager::size()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * This file is part of the core-bundle package.
5
 *
6
 * (c) 2018 WEBEWEB
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace WBW\Bundle\CoreBundle\Manager;
13
14
use WBW\Bundle\CoreBundle\Provider\ProviderInterface;
15
16
/**
17
 * Abstract manager.
18
 *
19
 * @author webeweb <https://github.com/webeweb/>
20
 * @package WBW\Bundle\CoreBundle\Manager
21
 * @abstract
22
 */
23
abstract class AbstractManager implements ManagerInterface {
24
25
    /**
26
     * Providers.
27
     *
28
     * @var ProviderInterface[]
29
     */
30
    private $providers;
31
32
    /**
33
     * Constructor.
34
     */
35
    protected function __construct() {
36
        $this->setProviders([]);
37
    }
38
39
    /**
40
     * Add a provider.
41
     *
42
     * @param ProviderInterface $provider The provider.
43
     * @return ManagerInterface Returns this manager.
44
     */
45
    public function addProvider(ProviderInterface $provider) {
46
        $this->providers[] = $provider;
47
        return $this;
48
    }
49
50
    /**
51
     * Get the providers.
52
     *
53
     * @return ProviderInterface[] Returns the provider.
54
     */
55
    public function &getProviders() {
56
        return $this->providers;
57
    }
58
59
    /**
60
     * {@inheritdoc}
61
     */
62
    public function hasProviders() {
63
        return 0 < count($this->providers);
64
    }
65
66
    /**
67
     * {@inheritdoc}
68
     */
69
    public function registerProvider(ProviderInterface $provider) {
70
        return $this->addProvider($provider);
71
    }
72
73
    /**
74
     * Set the providers.
75
     *
76
     * @param ProviderInterface $providers The providers.
77
     * @return ManagerInterface Returns this manager.
78
     */
79
    protected function setProviders(array $providers) {
80
        $this->providers = $providers;
81
        return $this;
82
    }
83
84
    /**
85
     * {@inheritdoc}
86
     */
87
    public function size() {
88
        return count($this->providers);
89
    }
90
91
}
92