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

Catalog::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 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
}