Passed
Push — develop ( b02061...820347 )
by Andreas
03:07
created

Catalog   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 71.43%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 39
ccs 5
cts 7
cp 0.7143
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A count() 0 4 1
A getProducts() 0 4 1
1
<?php
2
3
namespace Wambo\Catalog\Model;
4
5
/**
6
 * Class Catalog contains a list of Product models
7
 *
8
 * @package Wambo\Catalog\Model
9
 */
10
class Catalog implements \Countable
11
{
12
    /**
13
     * @var array
14
     */
15
    private $products;
16
17
    /**
18
     * Creates a new Catalog instance from the given Product models
19
     *
20
     * @param array $products A list of Product models
21
     */
22 3
    public function __construct(array $products)
23
    {
24 3
        $this->products = $products;
25 3
    }
26
27
    /**
28
     * Get a list of all Product models in this catalog
29
     *
30
     * @return array
31
     */
32
    public function getProducts()
33
    {
34
        return $this->products;
35
    }
36
37
    /**
38
     * Get the number of products in this catalog
39
     *
40
     * @see \Countable
41
     *
42
     * @return integer
43
     */
44 1
    public function count()
45
    {
46 1
        return count($this->products);
47
    }
48
}