1
1
<?php
2
+ declare (strict_types=1 );
2
3
/**
3
4
* (c) shopware AG <[email protected] >
4
5
*
14
15
use Shopware \Components \Model \ModelManager ;
15
16
use Shopware_Components_Config as Config ;
16
17
use SwagUserPrice \Bundle \StoreFrontBundle \Service \DependencyProvider ;
17
- use Symfony \Component \HttpFoundation \Session \Session ;
18
18
19
19
/**
20
20
* Plugin ServiceHelper class.
@@ -34,7 +34,7 @@ class ServiceHelper
34
34
private $ config ;
35
35
36
36
/**
37
- * @var Session
37
+ * @var DependencyProvider
38
38
*/
39
39
private $ dependencyProvider ;
40
40
@@ -51,15 +51,15 @@ public function __construct(
51
51
/**
52
52
* Get the prices for a product.
53
53
*/
54
- public function getPrices (string $ number ): ? array
54
+ public function getPrices (string $ number ): array
55
55
{
56
56
$ result = $ this ->getPricesQueryBuilder ($ number )
57
57
->orderBy ('prices.from ' , 'ASC ' )
58
58
->execute ()
59
59
->fetchAll ();
60
60
61
- if ($ result === false ) {
62
- return null ;
61
+ if (empty ( $ result) ) {
62
+ return [] ;
63
63
}
64
64
65
65
return $ result ;
@@ -68,7 +68,7 @@ public function getPrices(string $number): ?array
68
68
/**
69
69
* Get a single price for a product.
70
70
*/
71
- public function getPrice (string $ number ): ? array
71
+ public function getPrice (string $ number ): array
72
72
{
73
73
$ builder = $ this ->getPricesQueryBuilder ($ number );
74
74
if ($ this ->config ->get ('useLastGraduationForCheapestPrice ' )) {
@@ -79,8 +79,8 @@ public function getPrice(string $number): ?array
79
79
->execute ()
80
80
->fetch ();
81
81
82
- if ($ result === false ) {
83
- return null ;
82
+ if (! \is_array ( $ result) ) {
83
+ return [] ;
84
84
}
85
85
86
86
return $ result ;
@@ -101,7 +101,7 @@ public function getPriceForQuantity(string $number, int $quantity): ?array
101
101
->execute ()
102
102
->fetch ();
103
103
104
- if ($ result === false ) {
104
+ if (! \is_array ( $ result) ) {
105
105
return null ;
106
106
}
107
107
@@ -114,7 +114,7 @@ public function buildRule(array $price): PriceRule
114
114
$ priceRuleStruct ->setPrice ((float ) $ price ['price ' ]);
115
115
$ priceRuleStruct ->setFrom ((int ) $ price ['from ' ]);
116
116
$ priceRuleStruct ->setTo ((int ) $ price ['to ' ] > 0 ? (int ) $ price ['to ' ] : null );
117
- $ priceRuleStruct ->setPseudoPrice (( float ) 0 );
117
+ $ priceRuleStruct ->setPseudoPrice (0. 0 );
118
118
119
119
return $ priceRuleStruct ;
120
120
}
@@ -158,17 +158,15 @@ private function getPricesQueryBuilder(string $number): QueryBuilder
158
158
159
159
private function getDetailIdByNumber (string $ number ): ?int
160
160
{
161
- $ result = $ this ->modelManager ->getDBALQueryBuilder ()
161
+ $ result = ( int ) $ this ->modelManager ->getDBALQueryBuilder ()
162
162
->select ('detail.id ' )
163
- ->from (
164
- 's_articles_details ' ,
165
- 'detail '
166
- )->where ('detail.ordernumber = :number ' )
163
+ ->from ('s_articles_details ' , 'detail ' )
164
+ ->where ('detail.ordernumber = :number ' )
167
165
->setParameter ('number ' , $ number )
168
166
->execute ()
169
167
->fetchColumn ();
170
168
171
- if ($ result === false ) {
169
+ if ($ result === 0 ) {
172
170
return null ;
173
171
}
174
172
0 commit comments