Completed
Push — wtf-removal ( 4585f3 )
by Kamil
18:08
created

CustomerStatistics   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 35
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getAllOrdersCount() 0 6 1
A getPerChannelsStatistics() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
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 Sylius\Component\Core\Customer\Statistics;
13
14
use Webmozart\Assert\Assert;
15
16
/**
17
 * @author Jan Góralski <[email protected]>
18
 */
19
final class CustomerStatistics
20
{
21
    /**
22
     * @var PerChannelCustomerStatistics[]
23
     */
24
    private $perChannelsStatistics;
25
26
    /**
27
     * @param PerChannelCustomerStatistics[] $perChannelStatistics
28
     */
29
    public function __construct(array $perChannelStatistics)
30
    {
31
        Assert::allIsInstanceOf($perChannelStatistics, PerChannelCustomerStatistics::class);
32
33
        $this->perChannelsStatistics = $perChannelStatistics;
34
    }
35
36
    /**
37
     * @return int
0 ignored issues
show
Documentation introduced by
Should the return type not be integer|double?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
38
     */
39
    public function getAllOrdersCount()
40
    {
41
        return array_sum(array_map(function (PerChannelCustomerStatistics $statistics) {
42
            return $statistics->getOrdersCount();
43
        }, $this->perChannelsStatistics));
44
    }
45
46
    /**
47
     * @return PerChannelCustomerStatistics[]
48
     */
49
    public function getPerChannelsStatistics()
50
    {
51
        return $this->perChannelsStatistics;
52
    }
53
}
54