Collection::add()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 9
ccs 6
cts 6
cp 1
rs 9.6666
cc 2
eloc 4
nc 2
nop 1
crap 2
1
<?php
2
3
namespace Monolol\Lolifiers\QuoteProviders;
4
5
use Monolol\Lolifiers\QuoteProvider;
6
7
class Collection implements QuoteProvider
8
{
9
    private
10
        $providers;
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $providers.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
11
12 10
    public function __construct()
13
    {
14 10
        $this->providers = array();
15 10
    }
16
17 10
    public function getQuotes()
18
    {
19 10
        $quotes = array();
20
21 10
        foreach($this->providers as $provider)
22
        {
23 10
            $quotes = array_merge($quotes, $provider->getQuotes());
24 10
        }
25
26 10
        return $quotes;
27
    }
28
29 10
    public function add(QuoteProvider $provider)
30
    {
31 10
        if(! in_array($provider, $this->providers))
32 10
        {
33 10
            $this->providers[] = $provider;
34 10
        }
35
36 10
        return $this;
37
    }
38
}
39