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

PerChannelCustomerStatistics::getChannel()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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 Sylius\Component\Core\Model\ChannelInterface;
15
use Webmozart\Assert\Assert;
16
17
/**
18
 * @author Jan Góralski <[email protected]>
19
 */
20
final class PerChannelCustomerStatistics
21
{
22
    /**
23
     * @var int
24
     */
25
    private $ordersCount;
26
27
    /**
28
     * @var int
29
     */
30
    private $ordersValue;
31
32
    /**
33
     * @var ChannelInterface
34
     */
35
    private $channel;
36
37
    /**
38
     * @param int $ordersCount
39
     * @param int $ordersValue
40
     * @param ChannelInterface $channel
41
     *
42
     * @throws \InvalidArgumentException
43
     */
44
    public function __construct($ordersCount, $ordersValue, ChannelInterface $channel)
45
    {
46
        Assert::allInteger([$ordersCount, $ordersValue]);
47
48
        $this->ordersCount = $ordersCount;
49
        $this->ordersValue = $ordersValue;
50
        $this->channel = $channel;
51
    }
52
53
    /**
54
     * @return int
55
     */
56
    public function getOrdersCount()
57
    {
58
        return $this->ordersCount;
59
    }
60
61
    /**
62
     * @return int
63
     */
64
    public function getOrdersValue()
65
    {
66
        return $this->ordersValue;
67
    }
68
69
    /**
70
     * @return ChannelInterface
71
     */
72
    public function getChannel()
73
    {
74
        return $this->channel;
75
    }
76
77
    /**
78
     * @return int
79
     */
80
    public function getAverageOrderValue()
81
    {
82
        return (int) round($this->ordersValue / $this->ordersCount);
83
    }
84
}
85