@@ -30,14 +30,14 @@ discard block |
||
30 | 30 | * @param array $data Associative list of catalog codes and lists of CSV field indexes and their data |
31 | 31 | * @return array Associative list of CSV field indexes and their converted data |
32 | 32 | */ |
33 | - protected function convertData( array $convlist, array $data ) |
|
33 | + protected function convertData(array $convlist, array $data) |
|
34 | 34 | { |
35 | - foreach( $convlist as $idx => $converter ) |
|
35 | + foreach ($convlist as $idx => $converter) |
|
36 | 36 | { |
37 | - foreach( $data as $code => $list ) |
|
37 | + foreach ($data as $code => $list) |
|
38 | 38 | { |
39 | - if( isset( $list[$idx] ) ) { |
|
40 | - $data[$code][$idx] = $converter->translate( $list[$idx] ); |
|
39 | + if (isset($list[$idx])) { |
|
40 | + $data[$code][$idx] = $converter->translate($list[$idx]); |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | } |
@@ -53,36 +53,36 @@ discard block |
||
53 | 53 | * @param string|null Name of the cache implementation |
54 | 54 | * @return \Aimeos\Controller\Common\Catalog\Import\Csv\Cache\Iface Cache object |
55 | 55 | */ |
56 | - protected function getCache( $type, $name = null ) |
|
56 | + protected function getCache($type, $name = null) |
|
57 | 57 | { |
58 | 58 | $context = $this->getContext(); |
59 | 59 | $config = $context->getConfig(); |
60 | 60 | |
61 | - if( ctype_alnum( $type ) === false ) |
|
61 | + if (ctype_alnum($type) === false) |
|
62 | 62 | { |
63 | 63 | $classname = is_string($name) ? '\\Aimeos\\Controller\\Common\\Catalog\\Import\\Csv\\Cache\\' . $type : '<not a string>'; |
64 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
64 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); |
|
65 | 65 | } |
66 | 66 | |
67 | - if( $name === null ) { |
|
68 | - $name = $config->get( 'controller/common/catalog/import/csv/cache/' . $type . '/name', 'Standard' ); |
|
67 | + if ($name === null) { |
|
68 | + $name = $config->get('controller/common/catalog/import/csv/cache/' . $type . '/name', 'Standard'); |
|
69 | 69 | } |
70 | 70 | |
71 | - if( ctype_alnum( $name ) === false ) |
|
71 | + if (ctype_alnum($name) === false) |
|
72 | 72 | { |
73 | 73 | $classname = is_string($name) ? '\\Aimeos\\Controller\\Common\\Catalog\\Import\\Csv\\Cache\\' . $type . '\\' . $name : '<not a string>'; |
74 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
74 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); |
|
75 | 75 | } |
76 | 76 | |
77 | - $classname = '\\Aimeos\\Controller\\Common\\Catalog\\Import\\Csv\\Cache\\' . ucfirst( $type ) . '\\' . $name; |
|
77 | + $classname = '\\Aimeos\\Controller\\Common\\Catalog\\Import\\Csv\\Cache\\' . ucfirst($type) . '\\' . $name; |
|
78 | 78 | |
79 | - if( class_exists( $classname ) === false ) { |
|
80 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Class "%1$s" not found', $classname ) ); |
|
79 | + if (class_exists($classname) === false) { |
|
80 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Class "%1$s" not found', $classname)); |
|
81 | 81 | } |
82 | 82 | |
83 | - $object = new $classname( $context ); |
|
83 | + $object = new $classname($context); |
|
84 | 84 | |
85 | - \Aimeos\MW\Common\Base::checkClass( '\\Aimeos\\Controller\\Common\\Catalog\\Import\\Csv\\Cache\\Iface', $object ); |
|
85 | + \Aimeos\MW\Common\Base::checkClass('\\Aimeos\\Controller\\Common\\Catalog\\Import\\Csv\\Cache\\Iface', $object); |
|
86 | 86 | |
87 | 87 | return $object; |
88 | 88 | } |
@@ -94,12 +94,12 @@ discard block |
||
94 | 94 | * @param array $convmap List of converter names for the values at the position in the CSV file |
95 | 95 | * @return array Associative list of positions and converter objects |
96 | 96 | */ |
97 | - protected function getConverterList( array $convmap ) |
|
97 | + protected function getConverterList(array $convmap) |
|
98 | 98 | { |
99 | 99 | $convlist = []; |
100 | 100 | |
101 | - foreach( $convmap as $idx => $name ) { |
|
102 | - $convlist[$idx] = \Aimeos\MW\Convert\Factory::createConverter( $name ); |
|
101 | + foreach ($convmap as $idx => $name) { |
|
102 | + $convlist[$idx] = \Aimeos\MW\Convert\Factory::createConverter($name); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | return $convlist; |
@@ -114,15 +114,15 @@ discard block |
||
114 | 114 | * @param integer $codePos Column position which contains the unique catalog code (starting from 0) |
115 | 115 | * @return array List of arrays with catalog codes as keys and list of values from the CSV file |
116 | 116 | */ |
117 | - protected function getData( \Aimeos\MW\Container\Content\Iface $content, $maxcnt, $codePos ) |
|
117 | + protected function getData(\Aimeos\MW\Container\Content\Iface $content, $maxcnt, $codePos) |
|
118 | 118 | { |
119 | 119 | $count = 0; |
120 | 120 | $data = []; |
121 | 121 | |
122 | - while( $content->valid() && $count++ < $maxcnt ) |
|
122 | + while ($content->valid() && $count++ < $maxcnt) |
|
123 | 123 | { |
124 | 124 | $row = $content->current(); |
125 | - $data[ $row[$codePos] ] = $row; |
|
125 | + $data[$row[$codePos]] = $row; |
|
126 | 126 | $content->next(); |
127 | 127 | } |
128 | 128 | |
@@ -178,21 +178,21 @@ discard block |
||
178 | 178 | * @param array $mapping List of domain item keys with the CSV field position as key |
179 | 179 | * @return array List of associative arrays containing the chunked properties |
180 | 180 | */ |
181 | - protected function getMappedChunk( array &$data, array $mapping ) |
|
181 | + protected function getMappedChunk(array &$data, array $mapping) |
|
182 | 182 | { |
183 | 183 | $idx = 0; |
184 | 184 | $map = []; |
185 | 185 | |
186 | - foreach( $mapping as $pos => $key ) |
|
186 | + foreach ($mapping as $pos => $key) |
|
187 | 187 | { |
188 | - if( isset( $map[$idx][$key] ) ) { |
|
188 | + if (isset($map[$idx][$key])) { |
|
189 | 189 | $idx++; |
190 | 190 | } |
191 | 191 | |
192 | - if( isset( $data[$pos] ) ) |
|
192 | + if (isset($data[$pos])) |
|
193 | 193 | { |
194 | 194 | $map[$idx][$key] = $data[$pos]; |
195 | - unset( $data[$pos] ); |
|
195 | + unset($data[$pos]); |
|
196 | 196 | } |
197 | 197 | } |
198 | 198 | |
@@ -206,37 +206,37 @@ discard block |
||
206 | 206 | * @param array $mappings Associative list of processor types as keys and index/data mappings as values |
207 | 207 | * @return \Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Iface Processor object |
208 | 208 | */ |
209 | - protected function getProcessors( array $mappings ) |
|
209 | + protected function getProcessors(array $mappings) |
|
210 | 210 | { |
211 | 211 | $context = $this->getContext(); |
212 | 212 | $config = $context->getConfig(); |
213 | - $object = new \Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Done( $context, [] ); |
|
213 | + $object = new \Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Done($context, []); |
|
214 | 214 | |
215 | - foreach( $mappings as $type => $mapping ) |
|
215 | + foreach ($mappings as $type => $mapping) |
|
216 | 216 | { |
217 | - if( ctype_alnum( $type ) === false ) |
|
217 | + if (ctype_alnum($type) === false) |
|
218 | 218 | { |
219 | 219 | $classname = is_string($type) ? '\\Aimeos\\Controller\\Common\\Catalog\\Import\\Csv\\Processor\\' . $type : '<not a string>'; |
220 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
220 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); |
|
221 | 221 | } |
222 | 222 | |
223 | - $name = $config->get( 'controller/common/catalog/import/csv/processor/' . $type . '/name', 'Standard' ); |
|
223 | + $name = $config->get('controller/common/catalog/import/csv/processor/' . $type . '/name', 'Standard'); |
|
224 | 224 | |
225 | - if( ctype_alnum( $name ) === false ) |
|
225 | + if (ctype_alnum($name) === false) |
|
226 | 226 | { |
227 | 227 | $classname = is_string($name) ? '\\Aimeos\\Controller\\Common\\Catalog\\Import\\Csv\\Processor\\' . $type . '\\' . $name : '<not a string>'; |
228 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
228 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); |
|
229 | 229 | } |
230 | 230 | |
231 | - $classname = '\\Aimeos\\Controller\\Common\\Catalog\\Import\\Csv\\Processor\\' . ucfirst( $type ) . '\\' . $name; |
|
231 | + $classname = '\\Aimeos\\Controller\\Common\\Catalog\\Import\\Csv\\Processor\\' . ucfirst($type) . '\\' . $name; |
|
232 | 232 | |
233 | - if( class_exists( $classname ) === false ) { |
|
234 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Class "%1$s" not found', $classname ) ); |
|
233 | + if (class_exists($classname) === false) { |
|
234 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Class "%1$s" not found', $classname)); |
|
235 | 235 | } |
236 | 236 | |
237 | - $object = new $classname( $context, $mapping, $object ); |
|
237 | + $object = new $classname($context, $mapping, $object); |
|
238 | 238 | |
239 | - \Aimeos\MW\Common\Base::checkClass( '\\Aimeos\\Controller\\Common\\Catalog\\Import\\Csv\\Processor\\Iface', $object ); |
|
239 | + \Aimeos\MW\Common\Base::checkClass('\\Aimeos\\Controller\\Common\\Catalog\\Import\\Csv\\Processor\\Iface', $object); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | return $object; |
@@ -251,23 +251,23 @@ discard block |
||
251 | 251 | * @param string $code Unique code of the type item |
252 | 252 | * @return string Unique ID of the type item |
253 | 253 | */ |
254 | - protected function getTypeId( $path, $domain, $code ) |
|
254 | + protected function getTypeId($path, $domain, $code) |
|
255 | 255 | { |
256 | - if( !isset( self::$types[$path][$domain] ) ) |
|
256 | + if (!isset(self::$types[$path][$domain])) |
|
257 | 257 | { |
258 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $path ); |
|
259 | - $key = str_replace( '/', '.', $path ); |
|
258 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $path); |
|
259 | + $key = str_replace('/', '.', $path); |
|
260 | 260 | |
261 | 261 | $search = $manager->createSearch(); |
262 | - $search->setConditions( $search->compare( '==', $key . '.domain', $domain ) ); |
|
262 | + $search->setConditions($search->compare('==', $key . '.domain', $domain)); |
|
263 | 263 | |
264 | - foreach( $manager->searchItems( $search ) as $id => $item ) { |
|
265 | - self::$types[$path][$domain][ $item->getCode() ] = $id; |
|
264 | + foreach ($manager->searchItems($search) as $id => $item) { |
|
265 | + self::$types[$path][$domain][$item->getCode()] = $id; |
|
266 | 266 | } |
267 | 267 | } |
268 | 268 | |
269 | - if( !isset( self::$types[$path][$domain][$code] ) ) { |
|
270 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'No type item for "%1$s/%2$s" in "%3$s" found', $domain, $code, $path ) ); |
|
269 | + if (!isset(self::$types[$path][$domain][$code])) { |
|
270 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('No type item for "%1$s/%2$s" in "%3$s" found', $domain, $code, $path)); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | return self::$types[$path][$domain][$code]; |
@@ -16,92 +16,92 @@ discard block |
||
16 | 16 | |
17 | 17 | protected function setUp() |
18 | 18 | { |
19 | - \Aimeos\MShop\Factory::setCache( true ); |
|
19 | + \Aimeos\MShop\Factory::setCache(true); |
|
20 | 20 | |
21 | 21 | $context = \TestHelperCntl::getContext(); |
22 | 22 | $aimeos = \TestHelperCntl::getAimeos(); |
23 | 23 | |
24 | - $this->object = new TestAbstract( $context, $aimeos ); |
|
24 | + $this->object = new TestAbstract($context, $aimeos); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | |
28 | 28 | protected function tearDown() |
29 | 29 | { |
30 | - \Aimeos\MShop\Factory::setCache( false ); |
|
30 | + \Aimeos\MShop\Factory::setCache(false); |
|
31 | 31 | \Aimeos\MShop\Factory::clear(); |
32 | 32 | } |
33 | 33 | |
34 | 34 | |
35 | 35 | public function testGetCache() |
36 | 36 | { |
37 | - $cache = $this->object->getCachePublic( 'attribute' ); |
|
37 | + $cache = $this->object->getCachePublic('attribute'); |
|
38 | 38 | |
39 | - $this->assertInstanceOf( '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Cache\\Iface', $cache ); |
|
39 | + $this->assertInstanceOf('\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Cache\\Iface', $cache); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | |
43 | 43 | public function testGetCacheInvalidType() |
44 | 44 | { |
45 | - $this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); |
|
46 | - $this->object->getCachePublic( '$' ); |
|
45 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
46 | + $this->object->getCachePublic('$'); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | |
50 | 50 | public function testGetCacheInvalidClass() |
51 | 51 | { |
52 | - $this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); |
|
53 | - $this->object->getCachePublic( 'unknown' ); |
|
52 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
53 | + $this->object->getCachePublic('unknown'); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | |
57 | 57 | public function testGetCacheInvalidInterface() |
58 | 58 | { |
59 | - $this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); |
|
60 | - $this->object->getCachePublic( 'attribute', 'unknown' ); |
|
59 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
60 | + $this->object->getCachePublic('attribute', 'unknown'); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | |
64 | 64 | public function testGetProcessors() |
65 | 65 | { |
66 | - $processor = $this->object->getProcessorsPublic( array( 'attribute' => [] ) ); |
|
66 | + $processor = $this->object->getProcessorsPublic(array('attribute' => [])); |
|
67 | 67 | |
68 | - $this->assertInstanceOf( '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Processor\\Iface', $processor ); |
|
68 | + $this->assertInstanceOf('\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Processor\\Iface', $processor); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | |
72 | 72 | public function testGetProcessorsInvalidType() |
73 | 73 | { |
74 | - $this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); |
|
75 | - $this->object->getProcessorsPublic( array( '$' => [] ) ); |
|
74 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
75 | + $this->object->getProcessorsPublic(array('$' => [])); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | |
79 | 79 | public function testGetProcessorsInvalidClass() |
80 | 80 | { |
81 | - $this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); |
|
82 | - $this->object->getProcessorsPublic( array( 'unknown' => [] ) ); |
|
81 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
82 | + $this->object->getProcessorsPublic(array('unknown' => [])); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | |
86 | 86 | public function testGetProcessorsInvalidInterface() |
87 | 87 | { |
88 | - $this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); |
|
89 | - $this->object->getProcessorsPublic( array( 'unknown' => [] ) ); |
|
88 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
89 | + $this->object->getProcessorsPublic(array('unknown' => [])); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | |
93 | 93 | public function testGetTypeId() |
94 | 94 | { |
95 | - $typeid = $this->object->getTypeIdPublic( 'attribute/type', 'product', 'color' ); |
|
95 | + $typeid = $this->object->getTypeIdPublic('attribute/type', 'product', 'color'); |
|
96 | 96 | |
97 | - $this->assertNotEquals( null, $typeid ); |
|
97 | + $this->assertNotEquals(null, $typeid); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | |
101 | 101 | public function testGetTypeIdUnknown() |
102 | 102 | { |
103 | - $this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); |
|
104 | - $this->object->getTypeIdPublic( 'attribute/type', 'product', 'unknown' ); |
|
103 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
104 | + $this->object->getTypeIdPublic('attribute/type', 'product', 'unknown'); |
|
105 | 105 | } |
106 | 106 | } |
107 | 107 | |
@@ -115,21 +115,21 @@ discard block |
||
115 | 115 | return \TestHelperCntl::getContext(); |
116 | 116 | } |
117 | 117 | |
118 | - public function getCachePublic( $type, $name = null ) |
|
118 | + public function getCachePublic($type, $name = null) |
|
119 | 119 | { |
120 | - return $this->getCache( $type, $name ); |
|
120 | + return $this->getCache($type, $name); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | |
124 | - public function getProcessorsPublic( array $mappings ) |
|
124 | + public function getProcessorsPublic(array $mappings) |
|
125 | 125 | { |
126 | - return $this->getProcessors( $mappings ); |
|
126 | + return $this->getProcessors($mappings); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | |
130 | - public function getTypeIdPublic( $path, $domain, $code ) |
|
130 | + public function getTypeIdPublic($path, $domain, $code) |
|
131 | 131 | { |
132 | - return $this->getTypeId( $path, $domain, $code ); |
|
132 | + return $this->getTypeId($path, $domain, $code); |
|
133 | 133 | } |
134 | 134 | } |
135 | 135 |