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\Dashboard; |
13
|
|
|
|
14
|
|
|
use Webmozart\Assert\Assert; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @author Paweł Jędrzejewski <[email protected]> |
18
|
|
|
*/ |
19
|
|
|
class DashboardStatistics |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @var int |
23
|
|
|
*/ |
24
|
|
|
private $totalSales; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var int |
28
|
|
|
*/ |
29
|
|
|
private $numberOfNewOrders; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var int |
33
|
|
|
*/ |
34
|
|
|
private $numberOfNewCustomers; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var int |
38
|
|
|
*/ |
39
|
|
|
private $averageOrderValue; |
|
|
|
|
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @param int $totalSales |
43
|
|
|
* @param int $numberOfNewOrders |
44
|
|
|
* @param int $numberOfNewCustomers |
45
|
|
|
*/ |
46
|
|
|
public function __construct($totalSales, $numberOfNewOrders, $numberOfNewCustomers) |
47
|
|
|
{ |
48
|
|
|
Assert::allInteger([$totalSales, $numberOfNewCustomers, $numberOfNewOrders]); |
49
|
|
|
|
50
|
|
|
$this->totalSales = $totalSales; |
51
|
|
|
$this->numberOfNewOrders = $numberOfNewOrders; |
52
|
|
|
$this->numberOfNewCustomers = $numberOfNewCustomers; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @return int |
57
|
|
|
*/ |
58
|
|
|
public function getTotalSales() |
59
|
|
|
{ |
60
|
|
|
return $this->totalSales; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @return int |
65
|
|
|
*/ |
66
|
|
|
public function getNumberOfNewOrders() |
67
|
|
|
{ |
68
|
|
|
return $this->numberOfNewOrders; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @return int |
73
|
|
|
*/ |
74
|
|
|
public function getNumberOfNewCustomers() |
75
|
|
|
{ |
76
|
|
|
return $this->numberOfNewCustomers; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @return int |
81
|
|
|
*/ |
82
|
|
|
public function getAverageOrderValue() |
83
|
|
|
{ |
84
|
|
|
if (0 === $this->numberOfNewOrders) { |
85
|
|
|
return 0; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
return (int) round($this->totalSales / $this->numberOfNewOrders); |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|
This check marks private properties in classes that are never used. Those properties can be removed.