@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @return boolean |
32 | 32 | */ |
33 | 33 | protected function isActive() { |
34 | - if ( ! isset($this->active) ) { |
|
34 | + if ( ! isset($this->active)) { |
|
35 | 35 | $this->active = $this->scopeConfig->getValue(self::XML_PATH_CUSTOMER_USE_PSEUDO); |
36 | 36 | } |
37 | 37 | return $this->active; |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * @return \Faker\Generator |
43 | 43 | */ |
44 | 44 | protected function getFaker() { |
45 | - if ( ! isset($this->faker) ) { |
|
45 | + if ( ! isset($this->faker)) { |
|
46 | 46 | $om = \Magento\Framework\App\ObjectManager::getInstance(); |
47 | 47 | $resolver = $om->get('Magento\Framework\Locale\Resolver'); |
48 | 48 | $this->faker = Factory::create($resolver->getLocale()); |
@@ -56,9 +56,9 @@ discard block |
||
56 | 56 | * @param string $nickname |
57 | 57 | * @return string |
58 | 58 | */ |
59 | - public function aroundGetData( Review $review, callable $proceed, $key = '', $index = null) { |
|
59 | + public function aroundGetData(Review $review, callable $proceed, $key = '', $index = null) { |
|
60 | 60 | $result = $proceed($key, $index); |
61 | - if ( $this->isActive() && $key== 'nickname') { |
|
61 | + if ($this->isActive() && $key == 'nickname') { |
|
62 | 62 | $faker = $this->getFaker(); |
63 | 63 | return $faker->firstName; |
64 | 64 | } |
@@ -15,7 +15,7 @@ |
||
15 | 15 | { |
16 | 16 | if (in_array('email', $this->fields)) { |
17 | 17 | return [ |
18 | - $this->cipher->cipher( $this->format('email', $email) ) |
|
18 | + $this->cipher->cipher($this->format('email', $email)) |
|
19 | 19 | ]; |
20 | 20 | } |
21 | 21 | return [ |
@@ -15,11 +15,11 @@ discard block |
||
15 | 15 | * @param callable $proceed |
16 | 16 | * @return AbstractModel |
17 | 17 | */ |
18 | - public function aroundSave( AbstractResource $resource, callable $proceed, AbstractModel $object ) { |
|
18 | + public function aroundSave(AbstractResource $resource, callable $proceed, AbstractModel $object) { |
|
19 | 19 | $this->decipher($object); |
20 | 20 | if ( |
21 | - ( $object instanceof \Magento\Customer\Model\Customer ) || |
|
22 | - ( $object instanceof \Magento\Customer\Model\Address ) |
|
21 | + ($object instanceof \Magento\Customer\Model\Customer) || |
|
22 | + ($object instanceof \Magento\Customer\Model\Address) |
|
23 | 23 | ) { |
24 | 24 | $this->formatDataObject($object); |
25 | 25 | } |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * @param unknown $field |
39 | 39 | * @return unknown |
40 | 40 | */ |
41 | - public function aroundLoad( AbstractResource $resource, callable $proceed, AbstractModel $object, $value, $field = null) { |
|
41 | + public function aroundLoad(AbstractResource $resource, callable $proceed, AbstractModel $object, $value, $field = null) { |
|
42 | 42 | $return = $proceed($object, $value, $field); |
43 | 43 | $this->decipher($object); |
44 | 44 | return $return; |
@@ -23,7 +23,7 @@ |
||
23 | 23 | } |
24 | 24 | $this->isRunning = true; |
25 | 25 | foreach( $collection->getItems() as $item ) { |
26 | - $this->decipher($item); |
|
26 | + $this->decipher($item); |
|
27 | 27 | } |
28 | 28 | $this->isRunning = false; |
29 | 29 | return $result; |
@@ -17,12 +17,12 @@ |
||
17 | 17 | * @param DataObject $item |
18 | 18 | * @return DataObject |
19 | 19 | */ |
20 | - public function afterLoad( SourceProviderInterface $collection, $result ) { |
|
21 | - if ( $this->cipher->getIsIndexing() || $this->isRunning ) { |
|
20 | + public function afterLoad(SourceProviderInterface $collection, $result) { |
|
21 | + if ($this->cipher->getIsIndexing() || $this->isRunning) { |
|
22 | 22 | return $result; |
23 | 23 | } |
24 | 24 | $this->isRunning = true; |
25 | - foreach( $collection->getItems() as $item ) { |
|
25 | + foreach ($collection->getItems() as $item) { |
|
26 | 26 | $this->decipher($item); |
27 | 27 | } |
28 | 28 | $this->isRunning = false; |
@@ -97,8 +97,8 @@ discard block |
||
97 | 97 | * @return string |
98 | 98 | */ |
99 | 99 | protected function format($field, $string) { |
100 | - $string = mb_strtolower( $string ); |
|
101 | - if ( strpos( $field, 'email' ) === false ) { |
|
100 | + $string = mb_strtolower($string); |
|
101 | + if (strpos($field, 'email') === false) { |
|
102 | 102 | $string = $this->multibyteCapitalizeWords($string); |
103 | 103 | } |
104 | 104 | return $string; |
@@ -111,10 +111,10 @@ discard block |
||
111 | 111 | */ |
112 | 112 | protected function multibyteCapitalizeWords($string) { |
113 | 113 | $parts = []; |
114 | - foreach( explode(' ', $string) as $part ) { |
|
114 | + foreach (explode(' ', $string) as $part) { |
|
115 | 115 | $firstChar = mb_substr($part, 0, 1); |
116 | 116 | $then = mb_substr($part, 1); |
117 | - $parts[] = mb_strtoupper($firstChar) . $then; |
|
117 | + $parts[] = mb_strtoupper($firstChar).$then; |
|
118 | 118 | } |
119 | 119 | return implode(' ', $parts); |
120 | 120 | } |
@@ -124,13 +124,13 @@ discard block |
||
124 | 124 | * |
125 | 125 | * @param DataObject $object |
126 | 126 | */ |
127 | - protected function formatDataObject( DataObject $object ) { |
|
128 | - if ( $object->hasData('is_ciphered') ) { |
|
129 | - return ; |
|
127 | + protected function formatDataObject(DataObject $object) { |
|
128 | + if ($object->hasData('is_ciphered')) { |
|
129 | + return; |
|
130 | 130 | } |
131 | - foreach( $object->getData() as $field => $value ) { |
|
132 | - if ( in_array( $field, $this->formatFields ) ) { |
|
133 | - $object->setData( $field, $this->format($field, $value )); |
|
131 | + foreach ($object->getData() as $field => $value) { |
|
132 | + if (in_array($field, $this->formatFields)) { |
|
133 | + $object->setData($field, $this->format($field, $value)); |
|
134 | 134 | } |
135 | 135 | } |
136 | 136 | } |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | * |
140 | 140 | * @param Cipher $cipher |
141 | 141 | */ |
142 | - public function __construct( Cipher $cipher ) { |
|
142 | + public function __construct(Cipher $cipher) { |
|
143 | 143 | $this->cipher = $cipher; |
144 | 144 | } |
145 | 145 | |
@@ -147,19 +147,19 @@ discard block |
||
147 | 147 | * |
148 | 148 | * @param DataObject $object |
149 | 149 | */ |
150 | - protected function cipher( DataObject $object ) { |
|
151 | - if ( $object->hasData('is_ciphered') ) { |
|
152 | - return ; |
|
150 | + protected function cipher(DataObject $object) { |
|
151 | + if ($object->hasData('is_ciphered')) { |
|
152 | + return; |
|
153 | 153 | } |
154 | - $this->decipher( $object ); |
|
154 | + $this->decipher($object); |
|
155 | 155 | $ciphered = false; |
156 | - foreach( $object->getData() as $key => & $value ) { |
|
157 | - if ( in_array( $key, $this->fields ) && ( $value !== '' ) ) { |
|
158 | - $object->setData($key, $this->cipher->cipher( $value ) ); |
|
156 | + foreach ($object->getData() as $key => & $value) { |
|
157 | + if (in_array($key, $this->fields) && ($value !== '')) { |
|
158 | + $object->setData($key, $this->cipher->cipher($value)); |
|
159 | 159 | $ciphered = true; |
160 | 160 | } |
161 | 161 | } |
162 | - if ( $ciphered ) { |
|
162 | + if ($ciphered) { |
|
163 | 163 | $object->setData('is_ciphered', true); |
164 | 164 | } |
165 | 165 | } |
@@ -168,20 +168,20 @@ discard block |
||
168 | 168 | * |
169 | 169 | * @param DataObject $object |
170 | 170 | */ |
171 | - protected function decipher( DataObject $object ) { |
|
172 | - foreach( $object->getData() as $key => & $value ) { |
|
173 | - if ( in_array( $key, $this->fields ) ) { |
|
174 | - $object->setData($key, $this->cipher->decipher( $value ) ); |
|
171 | + protected function decipher(DataObject $object) { |
|
172 | + foreach ($object->getData() as $key => & $value) { |
|
173 | + if (in_array($key, $this->fields)) { |
|
174 | + $object->setData($key, $this->cipher->decipher($value)); |
|
175 | 175 | } |
176 | - else if ( in_array( $key, $this->specialFields ) ) { |
|
177 | - $parts = explode(' ', $object->getData( $key) ); |
|
178 | - foreach( $parts as & $part ) { |
|
176 | + else if (in_array($key, $this->specialFields)) { |
|
177 | + $parts = explode(' ', $object->getData($key)); |
|
178 | + foreach ($parts as & $part) { |
|
179 | 179 | $clear = $this->cipher->decipher($part); |
180 | - if ( strlen( $clear ) ) { |
|
180 | + if (strlen($clear)) { |
|
181 | 181 | $part = $clear; |
182 | 182 | } |
183 | 183 | } |
184 | - $object->setData($key, implode(' ',$parts) ); |
|
184 | + $object->setData($key, implode(' ', $parts)); |
|
185 | 185 | } |
186 | 186 | } |
187 | 187 | $object->unsetData('is_ciphered'); |
@@ -172,8 +172,7 @@ |
||
172 | 172 | foreach( $object->getData() as $key => & $value ) { |
173 | 173 | if ( in_array( $key, $this->fields ) ) { |
174 | 174 | $object->setData($key, $this->cipher->decipher( $value ) ); |
175 | - } |
|
176 | - else if ( in_array( $key, $this->specialFields ) ) { |
|
175 | + } else if ( in_array( $key, $this->specialFields ) ) { |
|
177 | 176 | $parts = explode(' ', $object->getData( $key) ); |
178 | 177 | foreach( $parts as & $part ) { |
179 | 178 | $clear = $this->cipher->decipher($part); |
@@ -17,15 +17,15 @@ |
||
17 | 17 | * @param callable $proceed |
18 | 18 | * @return void |
19 | 19 | */ |
20 | - public function aroundApply( FilterApplierInterface $filterApplier, callable $proceed, Collection $collection, Filter $filter ) { |
|
20 | + public function aroundApply(FilterApplierInterface $filterApplier, callable $proceed, Collection $collection, Filter $filter) { |
|
21 | 21 | $return = $proceed($collection, $filter); |
22 | 22 | $match = []; |
23 | - if ( ! preg_match( '/MATCH\([^\)]+\) AGAINST/ims', $collection->getSelect()->__toString(), $match ) ) { |
|
23 | + if ( ! preg_match('/MATCH\([^\)]+\) AGAINST/ims', $collection->getSelect()->__toString(), $match)) { |
|
24 | 24 | return $return; |
25 | 25 | } |
26 | 26 | $collection->getSelect()->orWhere( |
27 | 27 | $match[0].'(?)', |
28 | - $this->cipher->cipher( $filter->getValue() ) |
|
28 | + $this->cipher->cipher($filter->getValue()) |
|
29 | 29 | ); |
30 | 30 | return $return; |
31 | 31 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | * @param AbstractModel $value |
15 | 15 | * @return unknown |
16 | 16 | */ |
17 | - public function aroundIsValid( AbstractValidator $validator, callable $proceed, $value ) { |
|
17 | + public function aroundIsValid(AbstractValidator $validator, callable $proceed, $value) { |
|
18 | 18 | return $this->processValidation($validator, $proceed, $value); |
19 | 19 | } |
20 | 20 | |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * @param AbstractModel $value |
26 | 26 | * @return unknown |
27 | 27 | */ |
28 | - public function aroundValidate( OrderAddressValidator $validator, callable $proceed, AbstractModel $value ) { |
|
28 | + public function aroundValidate(OrderAddressValidator $validator, callable $proceed, AbstractModel $value) { |
|
29 | 29 | return $this->processValidation($validator, $proceed, $value); |
30 | 30 | } |
31 | 31 | |
@@ -36,15 +36,15 @@ discard block |
||
36 | 36 | * @param unknown $value |
37 | 37 | * @return unknown |
38 | 38 | */ |
39 | - protected function processValidation( $validator, callable $proceed, $value ) { |
|
39 | + protected function processValidation($validator, callable $proceed, $value) { |
|
40 | 40 | $objectsToProcess = []; |
41 | 41 | if ( |
42 | 42 | ( |
43 | - ( $value instanceof \Magento\Customer\Model\Customer ) || |
|
44 | - ( $value instanceof \Magento\Quote\Model\Quote ) || |
|
45 | - ( $value instanceof \Magento\Sales\Model\Order ) || |
|
46 | - ( $value instanceof \Magento\Quote\Model\Quote\Address ) || |
|
47 | - ( $value instanceof \Magento\Sales\Model\Order\Address ) |
|
43 | + ($value instanceof \Magento\Customer\Model\Customer) || |
|
44 | + ($value instanceof \Magento\Quote\Model\Quote) || |
|
45 | + ($value instanceof \Magento\Sales\Model\Order) || |
|
46 | + ($value instanceof \Magento\Quote\Model\Quote\Address) || |
|
47 | + ($value instanceof \Magento\Sales\Model\Order\Address) |
|
48 | 48 | ) && |
49 | 49 | $value->hasData('is_ciphered') |
50 | 50 | ) { |
@@ -52,41 +52,41 @@ discard block |
||
52 | 52 | $objectsToProcess[] = $value; |
53 | 53 | } |
54 | 54 | if ( |
55 | - ( $value instanceof \Magento\Quote\Model\Quote ) || |
|
56 | - ( $value instanceof \Magento\Sales\Model\Order ) |
|
55 | + ($value instanceof \Magento\Quote\Model\Quote) || |
|
56 | + ($value instanceof \Magento\Sales\Model\Order) |
|
57 | 57 | ) { |
58 | - foreach( $value->getAddressesCollection() as $address ) { |
|
59 | - if ( $address->hasData('is_ciphered') ) { |
|
58 | + foreach ($value->getAddressesCollection() as $address) { |
|
59 | + if ($address->hasData('is_ciphered')) { |
|
60 | 60 | $this->decipher($address); |
61 | 61 | $objectsToProcess[] = $address; |
62 | 62 | } |
63 | 63 | } |
64 | 64 | } |
65 | 65 | else if ( |
66 | - ( $value instanceof \Magento\Quote\Model\Quote\Address ) && |
|
66 | + ($value instanceof \Magento\Quote\Model\Quote\Address) && |
|
67 | 67 | $value->getQuote()->hasData('is_ciphered') |
68 | 68 | ) { |
69 | 69 | $quote = $value->getQuote(); |
70 | 70 | $this->decipher($quote); |
71 | - if ( empty($objectsToProcess) ) { |
|
71 | + if (empty($objectsToProcess)) { |
|
72 | 72 | $objectsToProcess[] = $value; |
73 | 73 | } |
74 | 74 | $objectsToProcess[] = $quote; |
75 | 75 | } |
76 | 76 | else if ( |
77 | - ( $value instanceof \Magento\Sales\Model\Order\Address ) && |
|
77 | + ($value instanceof \Magento\Sales\Model\Order\Address) && |
|
78 | 78 | $value->getOrder()->hasData('is_ciphered') |
79 | 79 | ) { |
80 | 80 | $order = $value->getOrder(); |
81 | 81 | $this->decipher($order); |
82 | - if ( empty($objectsToProcess) ) { |
|
82 | + if (empty($objectsToProcess)) { |
|
83 | 83 | $objectsToProcess[] = $value; |
84 | 84 | } |
85 | 85 | $objectsToProcess[] = $order; |
86 | 86 | } |
87 | 87 | $return = $proceed($value); |
88 | - if ( !empty($objectsToProcess) ) { |
|
89 | - foreach( $objectsToProcess as $object ) { |
|
88 | + if ( ! empty($objectsToProcess)) { |
|
89 | + foreach ($objectsToProcess as $object) { |
|
90 | 90 | $this->cipher($object); |
91 | 91 | } |
92 | 92 | } |
@@ -61,8 +61,7 @@ discard block |
||
61 | 61 | $objectsToProcess[] = $address; |
62 | 62 | } |
63 | 63 | } |
64 | - } |
|
65 | - else if ( |
|
64 | + } else if ( |
|
66 | 65 | ( $value instanceof \Magento\Quote\Model\Quote\Address ) && |
67 | 66 | $value->getQuote()->hasData('is_ciphered') |
68 | 67 | ) { |
@@ -72,8 +71,7 @@ discard block |
||
72 | 71 | $objectsToProcess[] = $value; |
73 | 72 | } |
74 | 73 | $objectsToProcess[] = $quote; |
75 | - } |
|
76 | - else if ( |
|
74 | + } else if ( |
|
77 | 75 | ( $value instanceof \Magento\Sales\Model\Order\Address ) && |
78 | 76 | $value->getOrder()->hasData('is_ciphered') |
79 | 77 | ) { |
@@ -27,8 +27,8 @@ |
||
27 | 27 | * |
28 | 28 | * @param Cipher $cipher |
29 | 29 | */ |
30 | - public function __construct( Cipher $cipher ) { |
|
31 | - $this->cipher= $cipher; |
|
30 | + public function __construct(Cipher $cipher) { |
|
31 | + $this->cipher = $cipher; |
|
32 | 32 | parent::__construct(); |
33 | 33 | } |
34 | 34 |
@@ -24,7 +24,7 @@ |
||
24 | 24 | InputInterface $input, |
25 | 25 | OutputInterface $output |
26 | 26 | ) { |
27 | - foreach ( [] as $collection ) { |
|
27 | + foreach ([] as $collection) { |
|
28 | 28 | $collection->save(); |
29 | 29 | } |
30 | 30 | } |