@@ -164,8 +164,7 @@ |
||
164 | 164 | $newMedia->image->cropThumbnailImage( (int) $width, (int) $height ); |
165 | 165 | // see https://www.php.net/manual/en/imagick.cropthumbnailimage.php#106710 |
166 | 166 | $newMedia->image->setImagePage( 0, 0, 0, 0 ); |
167 | - } |
|
168 | - else |
|
167 | + } else |
|
169 | 168 | { |
170 | 169 | $newMedia->image->resizeImage( $width, $height, \Imagick::FILTER_CUBIC, 0.8 ); |
171 | 170 | } |
@@ -202,8 +202,8 @@ |
||
202 | 202 | $wh = self::$watermark->getImageWidth(); |
203 | 203 | |
204 | 204 | $ratio = min( $this->getWidth() / $ww, $this->getHeight() / $wh ); |
205 | - $newHeight = (int) ($wh * $ratio); |
|
206 | - $newWidth = (int) ($ww * $ratio); |
|
205 | + $newHeight = (int) ( $wh * $ratio ); |
|
206 | + $newWidth = (int) ( $ww * $ratio ); |
|
207 | 207 | |
208 | 208 | $dx = (int) ( $this->getWidth() - $newWidth ) / 2; |
209 | 209 | $dy = (int) ( $this->getHeight() - $newHeight ) / 2; |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | public function testGetImage() |
16 | 16 | { |
17 | 17 | $ds = DIRECTORY_SEPARATOR; |
18 | - $object = \Aimeos\MW\Media\Factory::get( __DIR__ . $ds .'_testfiles' . $ds . 'image.png' ); |
|
18 | + $object = \Aimeos\MW\Media\Factory::get( __DIR__ . $ds . '_testfiles' . $ds . 'image.png' ); |
|
19 | 19 | |
20 | 20 | $this->assertInstanceOf( \Aimeos\MW\Media\Iface::class, $object ); |
21 | 21 | $this->assertInstanceOf( \Aimeos\MW\Media\Image\Iface::class, $object ); |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | public function testGetImageAsResource() |
27 | 27 | { |
28 | 28 | $ds = DIRECTORY_SEPARATOR; |
29 | - if( ( $resource = fopen( __DIR__ . $ds .'_testfiles' . $ds . 'image.png', 'rw' ) ) === false ) { |
|
30 | - throw new \RuntimeException( 'Failed to open ' . __DIR__ . $ds .'_testfiles' . $ds . 'image.png' ); |
|
29 | + if( ( $resource = fopen( __DIR__ . $ds . '_testfiles' . $ds . 'image.png', 'rw' ) ) === false ) { |
|
30 | + throw new \RuntimeException( 'Failed to open ' . __DIR__ . $ds . '_testfiles' . $ds . 'image.png' ); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | $object = \Aimeos\MW\Media\Factory::get( $resource ); |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | public function testGetImageAsString() |
42 | 42 | { |
43 | 43 | $ds = DIRECTORY_SEPARATOR; |
44 | - $content = file_get_contents( __DIR__ . $ds .'_testfiles' . $ds . 'image.png' ); |
|
44 | + $content = file_get_contents( __DIR__ . $ds . '_testfiles' . $ds . 'image.png' ); |
|
45 | 45 | $object = \Aimeos\MW\Media\Factory::get( $content ); |
46 | 46 | |
47 | 47 | $this->assertInstanceOf( \Aimeos\MW\Media\Iface::class, $object ); |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | public function testGetSvg() |
65 | 65 | { |
66 | 66 | $ds = DIRECTORY_SEPARATOR; |
67 | - $object = \Aimeos\MW\Media\Factory::get( __DIR__ . $ds .'_testfiles' . $ds . 'image.svgz' ); |
|
67 | + $object = \Aimeos\MW\Media\Factory::get( __DIR__ . $ds . '_testfiles' . $ds . 'image.svgz' ); |
|
68 | 68 | |
69 | 69 | $this->assertInstanceOf( \Aimeos\MW\Media\Iface::class, $object ); |
70 | 70 | $this->assertInstanceOf( \Aimeos\MW\Media\Image\Iface::class, $object ); |
@@ -49,7 +49,7 @@ |
||
49 | 49 | $mime = explode( '/', $mimetype ); |
50 | 50 | |
51 | 51 | $type = ( $mime[0] === 'image' ? 'Image' : 'Application' ); |
52 | - $name = ( isset( $options[ $mime[0] ]['name'] ) ? ucfirst( $options[ $mime[0] ]['name'] ) : 'Standard' ); |
|
52 | + $name = ( isset( $options[$mime[0]]['name'] ) ? ucfirst( $options[$mime[0]]['name'] ) : 'Standard' ); |
|
53 | 53 | |
54 | 54 | if( $mimetype === 'image/svg+xml' |
55 | 55 | || in_array( $mimetype, ['application/gzip', 'application/x-gzip'] ) |
@@ -176,8 +176,7 @@ discard block |
||
176 | 176 | if( $w <= $newWidth && $h <= $newHeight ) { |
177 | 177 | return $this; |
178 | 178 | } |
179 | - } |
|
180 | - elseif( $width && $height ) |
|
179 | + } elseif( $width && $height ) |
|
181 | 180 | { |
182 | 181 | $ratio = ( $w < $h ? $width / $w : $height / $h ); |
183 | 182 | $newHeight = (int) $h * $ratio; |
@@ -224,8 +223,7 @@ discard block |
||
224 | 223 | |
225 | 224 | imagedestroy( $result ); |
226 | 225 | $newMedia->image = $newImage; |
227 | - } |
|
228 | - else |
|
226 | + } else |
|
229 | 227 | { |
230 | 228 | $newMedia->image = $result; |
231 | 229 | } |
@@ -49,18 +49,18 @@ discard block |
||
49 | 49 | } |
50 | 50 | |
51 | 51 | if( ( $image = @imagecreatefromstring( $watermark ) ) === false ) { |
52 | - throw new \Aimeos\MW\Media\Exception( sprintf( 'The watermark image isn\'t supported by GDlib') ); |
|
52 | + throw new \Aimeos\MW\Media\Exception( sprintf( 'The watermark image isn\'t supported by GDlib' ) ); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | self::$watermark = $image; |
56 | 56 | } |
57 | 57 | |
58 | 58 | if( ( $this->image = @imagecreatefromstring( $content ) ) === false ) { |
59 | - throw new \Aimeos\MW\Media\Exception( sprintf( 'The image type isn\'t supported by GDlib') ); |
|
59 | + throw new \Aimeos\MW\Media\Exception( sprintf( 'The image type isn\'t supported by GDlib' ) ); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | if( imagealphablending( $this->image, true ) === false ) { |
63 | - throw new \Aimeos\MW\Media\Exception( sprintf( 'GD library failed (imagealphablending)') ); |
|
63 | + throw new \Aimeos\MW\Media\Exception( sprintf( 'GD library failed (imagealphablending)' ) ); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | $this->options = $options; |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | case 'image/png': |
149 | 149 | |
150 | 150 | if( imagesavealpha( $this->image, true ) === false ) { |
151 | - throw new \Aimeos\MW\Media\Exception( sprintf( 'GD library failed (imagesavealpha)') ); |
|
151 | + throw new \Aimeos\MW\Media\Exception( sprintf( 'GD library failed (imagesavealpha)' ) ); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | if( @imagepng( $this->image, $filename, (int) 10 - $quality / 10 ) === false ) { |
@@ -264,8 +264,8 @@ discard block |
||
264 | 264 | $wh = imagesy( self::$watermark ); |
265 | 265 | |
266 | 266 | $ratio = min( $this->getWidth() / $ww, $this->getHeight() / $wh ); |
267 | - $newHeight = (int) ($wh * $ratio); |
|
268 | - $newWidth = (int) ($ww * $ratio); |
|
267 | + $newHeight = (int) ( $wh * $ratio ); |
|
268 | + $newWidth = (int) ( $ww * $ratio ); |
|
269 | 269 | |
270 | 270 | if( ( $wimage = imagescale( self::$watermark, $newWidth, $newHeight, IMG_BICUBIC ) ) === false ) { |
271 | 271 | throw new \Aimeos\MW\Media\Exception( 'Unable to scale image' ); |
@@ -19,13 +19,13 @@ discard block |
||
19 | 19 | { |
20 | 20 | $this->editor = \TestHelperMShop::getContext()->getEditor(); |
21 | 21 | $manager = \Aimeos\MShop\Price\Manager\Factory::create( \TestHelperMShop::getContext() ); |
22 | - $this->object = $manager->getSubManager( 'property' )->getSubManager('type'); |
|
22 | + $this->object = $manager->getSubManager( 'property' )->getSubManager( 'type' ); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | |
26 | 26 | protected function tearDown() |
27 | 27 | { |
28 | - unset($this->object); |
|
28 | + unset( $this->object ); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | |
69 | 69 | $results = $this->object->searchItems( $search ); |
70 | 70 | |
71 | - if( ($expected = reset($results) ) === false ) |
|
71 | + if( ( $expected = reset( $results ) ) === false ) |
|
72 | 72 | { |
73 | 73 | throw new \RuntimeException( 'No property type item found.' ); |
74 | 74 | } |
@@ -90,13 +90,13 @@ discard block |
||
90 | 90 | { |
91 | 91 | $search = $this->object->createSearch(); |
92 | 92 | $search->setConditions( $search->compare( '==', 'price.property.type.editor', $this->editor ) ); |
93 | - $results = $this->object->searchItems($search); |
|
93 | + $results = $this->object->searchItems( $search ); |
|
94 | 94 | |
95 | - if( ( $item = reset($results) ) === false ) { |
|
95 | + if( ( $item = reset( $results ) ) === false ) { |
|
96 | 96 | throw new \RuntimeException( 'No type item found' ); |
97 | 97 | } |
98 | 98 | |
99 | - $item->setId(null); |
|
99 | + $item->setId( null ); |
|
100 | 100 | $item->setCode( 'unitTestSave' ); |
101 | 101 | $resultSaved = $this->object->saveItem( $item ); |
102 | 102 | $itemSaved = $this->object->getItem( $item->getId() ); |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | $expr[] = $search->compare( '>=', 'price.property.type.ctime', '1970-01-01 00:00:00' ); |
158 | 158 | $expr[] = $search->compare( '==', 'price.property.type.editor', $this->editor ); |
159 | 159 | |
160 | - $search->setConditions( $search->combine('&&', $expr) ); |
|
160 | + $search->setConditions( $search->combine( '&&', $expr ) ); |
|
161 | 161 | $results = $this->object->searchItems( $search, [], $total ); |
162 | 162 | |
163 | 163 | $this->assertEquals( 1, count( $results ) ); |
@@ -167,6 +167,6 @@ discard block |
||
167 | 167 | public function testGetSubManager() |
168 | 168 | { |
169 | 169 | $this->setExpectedException( \Aimeos\MShop\Exception::class ); |
170 | - $this->object->getSubManager('unknown'); |
|
170 | + $this->object->getSubManager( 'unknown' ); |
|
171 | 171 | } |
172 | 172 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | |
9 | 9 | return array( |
10 | 10 | 'table' => array( |
11 | - 'mshop_price_type' => function ( \Doctrine\DBAL\Schema\Schema $schema ) { |
|
11 | + 'mshop_price_type' => function( \Doctrine\DBAL\Schema\Schema $schema ) { |
|
12 | 12 | |
13 | 13 | $table = $schema->createTable( 'mshop_price_type' ); |
14 | 14 | |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | return $schema; |
33 | 33 | }, |
34 | 34 | |
35 | - 'mshop_price' => function ( \Doctrine\DBAL\Schema\Schema $schema ) { |
|
35 | + 'mshop_price' => function( \Doctrine\DBAL\Schema\Schema $schema ) { |
|
36 | 36 | |
37 | 37 | $table = $schema->createTable( 'mshop_price' ); |
38 | 38 | |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | $table->addColumn( 'status', 'smallint', [] ); |
51 | 51 | $table->addColumn( 'mtime', 'datetime', [] ); |
52 | 52 | $table->addColumn( 'ctime', 'datetime', [] ); |
53 | - $table->addColumn( 'editor', 'string', array('length' => 255 ) ); |
|
53 | + $table->addColumn( 'editor', 'string', array( 'length' => 255 ) ); |
|
54 | 54 | |
55 | 55 | $table->setPrimaryKey( array( 'id' ), 'pk_mspri_id' ); |
56 | 56 | $table->addIndex( array( 'siteid', 'domain', 'currencyid' ), 'idx_mspri_sid_dom_currid' ); |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | return $schema; |
64 | 64 | }, |
65 | 65 | |
66 | - 'mshop_price_list_type' => function ( \Doctrine\DBAL\Schema\Schema $schema ) { |
|
66 | + 'mshop_price_list_type' => function( \Doctrine\DBAL\Schema\Schema $schema ) { |
|
67 | 67 | |
68 | 68 | $table = $schema->createTable( 'mshop_price_list_type' ); |
69 | 69 | |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | return $schema; |
88 | 88 | }, |
89 | 89 | |
90 | - 'mshop_price_list' => function ( \Doctrine\DBAL\Schema\Schema $schema ) { |
|
90 | + 'mshop_price_list' => function( \Doctrine\DBAL\Schema\Schema $schema ) { |
|
91 | 91 | |
92 | 92 | $table = $schema->createTable( 'mshop_price_list' ); |
93 | 93 | |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | return $schema; |
119 | 119 | }, |
120 | 120 | |
121 | - 'mshop_price_property_type' => function ( \Doctrine\DBAL\Schema\Schema $schema ) { |
|
121 | + 'mshop_price_property_type' => function( \Doctrine\DBAL\Schema\Schema $schema ) { |
|
122 | 122 | |
123 | 123 | $table = $schema->createTable( 'mshop_price_property_type' ); |
124 | 124 | |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | return $schema; |
143 | 143 | }, |
144 | 144 | |
145 | - 'mshop_price_property' => function ( \Doctrine\DBAL\Schema\Schema $schema ) { |
|
145 | + 'mshop_price_property' => function( \Doctrine\DBAL\Schema\Schema $schema ) { |
|
146 | 146 | |
147 | 147 | $table = $schema->createTable( 'mshop_price_property' ); |
148 | 148 |
@@ -147,7 +147,7 @@ |
||
147 | 147 | $fs->rm( $preview ); |
148 | 148 | } |
149 | 149 | } |
150 | - catch( \Exception $e ) { ; } // Can be a mime icon with relative path |
|
150 | + catch( \Exception $e ) {; } // Can be a mime icon with relative path |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | return $item->setUrl( '' )->setPreviews( [] )->deletePropertyItems( $item->getPropertyItems() ); |
@@ -53,8 +53,7 @@ discard block |
||
53 | 53 | if( $media instanceof \Aimeos\MW\Media\Image\Iface ) |
54 | 54 | { |
55 | 55 | $item = $this->addImages( $item, $media, md5( $file->getClientFilename() ), $fsname ); |
56 | - } |
|
57 | - else |
|
56 | + } else |
|
58 | 57 | { |
59 | 58 | $mimetype = $media->getMimeType(); |
60 | 59 | $filepath = $this->getFilePath( $file->getClientFilename(), 'files', $mimetype ); |
@@ -106,7 +105,9 @@ discard block |
||
106 | 105 | $fs->copy( $preview, $newPath ); |
107 | 106 | $previews[$size] = $newPath; |
108 | 107 | } |
109 | - catch( \Aimeos\MW\Filesystem\Exception $e ) {} // mime icons can't be copied |
|
108 | + catch( \Aimeos\MW\Filesystem\Exception $e ) |
|
109 | + { |
|
110 | +} // mime icons can't be copied |
|
110 | 111 | } |
111 | 112 | } |
112 | 113 | |
@@ -147,7 +148,9 @@ discard block |
||
147 | 148 | $fs->rm( $preview ); |
148 | 149 | } |
149 | 150 | } |
150 | - catch( \Exception $e ) { ; } // Can be a mime icon with relative path |
|
151 | + catch( \Exception $e ) |
|
152 | + { |
|
153 | +; } // Can be a mime icon with relative path |
|
151 | 154 | } |
152 | 155 | |
153 | 156 | return $item->setUrl( '' )->setPreviews( [] )->deletePropertyItems( $item->getPropertyItems() ); |
@@ -665,7 +668,9 @@ discard block |
||
665 | 668 | $fs->rm( $oldpath ); |
666 | 669 | } |
667 | 670 | } |
668 | - catch( \Aimeos\MW\Filesystem\Exception $e ) {} // continue if removing file fails |
|
671 | + catch( \Aimeos\MW\Filesystem\Exception $e ) |
|
672 | + { |
|
673 | +} // continue if removing file fails |
|
669 | 674 | |
670 | 675 | $fs->write( $filepath, $content ); |
671 | 676 | } |
@@ -83,8 +83,7 @@ discard block |
||
83 | 83 | $this->release( $conn, $dbdomain ); |
84 | 84 | |
85 | 85 | $this->status( 'done' ); |
86 | - } |
|
87 | - else |
|
86 | + } else |
|
88 | 87 | { |
89 | 88 | $this->status( 'OK' ); |
90 | 89 | } |
@@ -129,8 +128,7 @@ discard block |
||
129 | 128 | $this->release( $conn, $dbdomain ); |
130 | 129 | |
131 | 130 | $this->status( 'done' ); |
132 | - } |
|
133 | - else |
|
131 | + } else |
|
134 | 132 | { |
135 | 133 | $this->status( 'OK' ); |
136 | 134 | } |
@@ -54,11 +54,11 @@ discard block |
||
54 | 54 | $search->setConditions( $search->compare( '==', 'price.property.editor', $this->editor ) ); |
55 | 55 | $results = $this->object->searchItems( $search ); |
56 | 56 | |
57 | - if( ( $item = reset($results) ) === false ) { |
|
57 | + if( ( $item = reset( $results ) ) === false ) { |
|
58 | 58 | throw new \RuntimeException( 'No property item found' ); |
59 | 59 | } |
60 | 60 | |
61 | - $item->setId(null); |
|
61 | + $item->setId( null ); |
|
62 | 62 | $item->setLanguageId( 'en' ); |
63 | 63 | $resultSaved = $this->object->saveItem( $item ); |
64 | 64 | $itemSaved = $this->object->getItem( $item->getId() ); |
@@ -109,13 +109,13 @@ discard block |
||
109 | 109 | { |
110 | 110 | $search = $this->object->createSearch()->setSlice( 0, 1 ); |
111 | 111 | $conditions = array( |
112 | - $search->compare( '~=', 'price.property.value', 'NY'), |
|
112 | + $search->compare( '~=', 'price.property.value', 'NY' ), |
|
113 | 113 | $search->compare( '==', 'price.property.editor', $this->editor ) |
114 | 114 | ); |
115 | 115 | $search->setConditions( $search->combine( '&&', $conditions ) ); |
116 | 116 | $results = $this->object->searchItems( $search ); |
117 | 117 | |
118 | - if( ($expected = reset($results)) === false ) { |
|
118 | + if( ( $expected = reset( $results ) ) === false ) { |
|
119 | 119 | throw new \RuntimeException( sprintf( 'No price property item found for value "%1$s".', 'NY' ) ); |
120 | 120 | } |
121 | 121 | |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | $expr[] = $search->compare( '==', 'price.property.value', 'NY' ); |
155 | 155 | $expr[] = $search->compare( '==', 'price.property.editor', $this->editor ); |
156 | 156 | |
157 | - $search->setConditions( $search->combine('&&', $expr) ); |
|
157 | + $search->setConditions( $search->combine( '&&', $expr ) ); |
|
158 | 158 | $results = $this->object->searchItems( $search, [], $total ); |
159 | 159 | $this->assertEquals( 2, count( $results ) ); |
160 | 160 | } |
@@ -162,17 +162,17 @@ discard block |
||
162 | 162 | |
163 | 163 | public function testGetSubManager() |
164 | 164 | { |
165 | - $this->assertInstanceOf( \Aimeos\MShop\Common\Manager\Iface::class, $this->object->getSubManager('type') ); |
|
166 | - $this->assertInstanceOf( \Aimeos\MShop\Common\Manager\Iface::class, $this->object->getSubManager('type', 'Standard') ); |
|
165 | + $this->assertInstanceOf( \Aimeos\MShop\Common\Manager\Iface::class, $this->object->getSubManager( 'type' ) ); |
|
166 | + $this->assertInstanceOf( \Aimeos\MShop\Common\Manager\Iface::class, $this->object->getSubManager( 'type', 'Standard' ) ); |
|
167 | 167 | |
168 | 168 | $this->setExpectedException( \Aimeos\MShop\Exception::class ); |
169 | - $this->object->getSubManager('unknown'); |
|
169 | + $this->object->getSubManager( 'unknown' ); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | |
173 | 173 | public function testGetSubManagerInvalidName() |
174 | 174 | { |
175 | 175 | $this->setExpectedException( \Aimeos\MShop\Exception::class ); |
176 | - $this->object->getSubManager('type', 'unknown'); |
|
176 | + $this->object->getSubManager( 'type', 'unknown' ); |
|
177 | 177 | } |
178 | 178 | } |