@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | $this->image->resize( |
| 99 | 99 | $width, |
| 100 | 100 | $height, |
| 101 | - function ($constraint) { |
|
| 101 | + function($constraint) { |
|
| 102 | 102 | $constraint->aspectRatio(); |
| 103 | 103 | } |
| 104 | 104 | ); |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | $this->image->fit( |
| 178 | 178 | $this->styleData['width'], |
| 179 | 179 | $this->styleData['height'], |
| 180 | - function ($constraint) { |
|
| 180 | + function($constraint) { |
|
| 181 | 181 | $constraint->upsize(); |
| 182 | 182 | } |
| 183 | 183 | ); |
@@ -153,8 +153,7 @@ |
||
| 153 | 153 | // just cut out the crop rectangle. |
| 154 | 154 | if (empty($this->getCoordinates('focus'))) { |
| 155 | 155 | $this->doCropRectangle(); |
| 156 | - } |
|
| 157 | - else { |
|
| 156 | + } else { |
|
| 158 | 157 | |
| 159 | 158 | $focusOffsetFinder = new FocusCropDataCalculator( |
| 160 | 159 | $this->getCoordinates('crop'), |
@@ -120,8 +120,8 @@ discard block |
||
| 120 | 120 | * Performs the image manipulation using current style information |
| 121 | 121 | * and user defined crop and focus rectangles. |
| 122 | 122 | * |
| 123 | - * @param $source |
|
| 124 | - * @param $destination |
|
| 123 | + * @param string $source |
|
| 124 | + * @param string $destination |
|
| 125 | 125 | * @param array $style |
| 126 | 126 | * @param null $cropFocusCoords |
| 127 | 127 | * |
@@ -177,6 +177,10 @@ discard block |
||
| 177 | 177 | $this->image->fit( |
| 178 | 178 | $this->styleData['width'], |
| 179 | 179 | $this->styleData['height'], |
| 180 | + |
|
| 181 | + /** |
|
| 182 | + * @param string $constraint |
|
| 183 | + */ |
|
| 180 | 184 | function ($constraint) { |
| 181 | 185 | $constraint->upsize(); |
| 182 | 186 | } |
@@ -161,10 +161,10 @@ |
||
| 161 | 161 | $focusY2 = $this->focusCoordinates[3]; |
| 162 | 162 | |
| 163 | 163 | if ($type == 'near') { |
| 164 | - $point = ${'focus' . $axis . '1'} - ${'crop' . $axis . '1'}; |
|
| 164 | + $point = ${'focus' . $axis . '1'} -${'crop' . $axis . '1'}; |
|
| 165 | 165 | } |
| 166 | 166 | else { |
| 167 | - $point = ${'focus' . $axis . '2'} - ${'crop' . $axis . '1'}; |
|
| 167 | + $point = ${'focus' . $axis . '2'} -${'crop' . $axis . '1'}; |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | return $point; |
@@ -97,8 +97,8 @@ discard block |
||
| 97 | 97 | * @param string $axis |
| 98 | 98 | * @param $cropCoordinates |
| 99 | 99 | * @param $aspectRatio |
| 100 | - * @param $newWidth |
|
| 101 | - * @param $newHeight |
|
| 100 | + * @param integer $newWidth |
|
| 101 | + * @param integer $newHeight |
|
| 102 | 102 | * |
| 103 | 103 | * @return array |
| 104 | 104 | */ |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | /** |
| 162 | - * @param $axis |
|
| 162 | + * @param string $axis |
|
| 163 | 163 | * @param string $type |
| 164 | 164 | * |
| 165 | 165 | * @return mixed |
@@ -255,10 +255,10 @@ discard block |
||
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | /** |
| 258 | - * @param $focusNear |
|
| 258 | + * @param double $focusNear |
|
| 259 | 259 | * @param $focusFar |
| 260 | 260 | * @param $cropLength |
| 261 | - * @param $imageLength |
|
| 261 | + * @param integer $imageLength |
|
| 262 | 262 | * |
| 263 | 263 | * @return array |
| 264 | 264 | */ |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | * Tests if a given offset is valid. |
| 297 | 297 | * Valid offsets cropped images will include the focus rectangle and will not fall outside of the original image. |
| 298 | 298 | * |
| 299 | - * @param $point |
|
| 299 | + * @param integer $point |
|
| 300 | 300 | * @param $cropLength |
| 301 | 301 | * @param $imageLength |
| 302 | 302 | * @param $focusNear |
@@ -77,11 +77,9 @@ discard block |
||
| 77 | 77 | |
| 78 | 78 | if ($imageAspectRatio > $styleAspectRatio) { |
| 79 | 79 | $axis = 'x'; |
| 80 | - } |
|
| 81 | - else if ($imageAspectRatio < $styleAspectRatio) { |
|
| 80 | + } else if ($imageAspectRatio < $styleAspectRatio) { |
|
| 82 | 81 | $axis = 'y'; |
| 83 | - } |
|
| 84 | - else { |
|
| 82 | + } else { |
|
| 85 | 83 | return [ |
| 86 | 84 | 'width' => $newWidth, |
| 87 | 85 | 'height' => $newHeight, |
@@ -114,8 +112,7 @@ discard block |
||
| 114 | 112 | // How many times the style height goes into the new height |
| 115 | 113 | $scaleFactor = $newHeight / $this->styleHeight; |
| 116 | 114 | $cropWidth = $this->styleWidth * $scaleFactor; |
| 117 | - } |
|
| 118 | - else { |
|
| 115 | + } else { |
|
| 119 | 116 | $cropWidth = $newWidth; |
| 120 | 117 | |
| 121 | 118 | // How many times the style height goes into the new height |
@@ -178,8 +175,7 @@ discard block |
||
| 178 | 175 | |
| 179 | 176 | if ($type == 'near') { |
| 180 | 177 | $point = ${'focus' . $axis . '1'} - ${'crop' . $axis . '1'}; |
| 181 | - } |
|
| 182 | - else { |
|
| 178 | + } else { |
|
| 183 | 179 | $point = ${'focus' . $axis . '2'} - ${'crop' . $axis . '1'}; |
| 184 | 180 | } |
| 185 | 181 | |
@@ -51,7 +51,7 @@ |
||
| 51 | 51 | $size->resize( |
| 52 | 52 | $scaleX, |
| 53 | 53 | $scaleY, |
| 54 | - function ($constraint) { |
|
| 54 | + function($constraint) { |
|
| 55 | 55 | $constraint->aspectRatio(); |
| 56 | 56 | } |
| 57 | 57 | ); |
@@ -80,8 +80,7 @@ |
||
| 80 | 80 | $axis = strtolower($axis); |
| 81 | 81 | if ($axis == 'x') { |
| 82 | 82 | return $this->x2 - $this->x1; |
| 83 | - } |
|
| 84 | - else { |
|
| 83 | + } else { |
|
| 85 | 84 | return $this->y2 - $this->y1; |
| 86 | 85 | } |
| 87 | 86 | } |
@@ -149,8 +149,7 @@ |
||
| 149 | 149 | if ($urlBits[0] == 'http' || $urlBits[0] == 'https') { |
| 150 | 150 | $urlPrefix = $urlBits[0] . '://'; |
| 151 | 151 | $urlPath = $urlBits[1]; |
| 152 | - } |
|
| 153 | - else { |
|
| 152 | + } else { |
|
| 154 | 153 | $urlPrefix = '/'; |
| 155 | 154 | $urlPath = $url; |
| 156 | 155 | } |
@@ -45,21 +45,21 @@ |
||
| 45 | 45 | |
| 46 | 46 | // Mock the EntityManager to return the mock of the repository |
| 47 | 47 | $entityManager = $this->getMockBuilder(EntityManager::class) |
| 48 | - ->disableOriginalConstructor() |
|
| 49 | - ->getMock(); |
|
| 48 | + ->disableOriginalConstructor() |
|
| 49 | + ->getMock(); |
|
| 50 | 50 | |
| 51 | 51 | $entityManager->expects($this->any()) |
| 52 | - ->method('getRepository') |
|
| 53 | - ->will($this->returnValue($imageRepository)); |
|
| 52 | + ->method('getRepository') |
|
| 53 | + ->will($this->returnValue($imageRepository)); |
|
| 54 | 54 | |
| 55 | 55 | // The mock the ImageEntityName |
| 56 | 56 | $nameResolver = $this->getMockBuilder(ImageEntityNameResolver::class) |
| 57 | - ->disableOriginalConstructor() |
|
| 58 | - ->getMock(); |
|
| 57 | + ->disableOriginalConstructor() |
|
| 58 | + ->getMock(); |
|
| 59 | 59 | |
| 60 | 60 | $nameResolver->expects($this->once()) |
| 61 | - ->method('getClassName') |
|
| 62 | - ->will($this->returnValue('ResponsiveImage')); |
|
| 61 | + ->method('getClassName') |
|
| 62 | + ->will($this->returnValue('ResponsiveImage')); |
|
| 63 | 63 | |
| 64 | 64 | $fileToObject = new FileToObject($entityManager, $nameResolver); |
| 65 | 65 | |
@@ -31,7 +31,7 @@ |
||
| 31 | 31 | ->method('findImageFromFilename') |
| 32 | 32 | ->will( |
| 33 | 33 | $this->returnCallback( |
| 34 | - function ($filename) { |
|
| 34 | + function($filename) { |
|
| 35 | 35 | $image = new TestImage(); |
| 36 | 36 | if ($filename === $image->getPath()) { |
| 37 | 37 | return $image; |
@@ -35,8 +35,7 @@ |
||
| 35 | 35 | $image = new TestImage(); |
| 36 | 36 | if ($filename === $image->getPath()) { |
| 37 | 37 | return $image; |
| 38 | - } |
|
| 39 | - else { |
|
| 38 | + } else { |
|
| 40 | 39 | return null; |
| 41 | 40 | } |
| 42 | 41 | } |
@@ -20,29 +20,29 @@ |
||
| 20 | 20 | { |
| 21 | 21 | // Mock the repository so it returns the mock of the Image repository. |
| 22 | 22 | $fileToObject = $this->getMockBuilder(FileToObject::class) |
| 23 | - ->disableOriginalConstructor() |
|
| 24 | - ->getMock(); |
|
| 23 | + ->disableOriginalConstructor() |
|
| 24 | + ->getMock(); |
|
| 25 | 25 | |
| 26 | 26 | $fileToObject->expects($this->any()) |
| 27 | - ->method('getObjectFromFilename') |
|
| 28 | - ->will( |
|
| 29 | - $this->returnCallback( |
|
| 30 | - function ($filename) { |
|
| 31 | - $existingFilenames = [ |
|
| 32 | - 'test.jpg', |
|
| 33 | - 'test_1.jpg', |
|
| 34 | - ]; |
|
| 35 | - if (in_array($filename, $existingFilenames)) { |
|
| 36 | - $image = new TestImage(); |
|
| 37 | - |
|
| 38 | - return $image; |
|
| 39 | - } |
|
| 40 | - else { |
|
| 41 | - return null; |
|
| 42 | - } |
|
| 43 | - } |
|
| 44 | - ) |
|
| 45 | - ); |
|
| 27 | + ->method('getObjectFromFilename') |
|
| 28 | + ->will( |
|
| 29 | + $this->returnCallback( |
|
| 30 | + function ($filename) { |
|
| 31 | + $existingFilenames = [ |
|
| 32 | + 'test.jpg', |
|
| 33 | + 'test_1.jpg', |
|
| 34 | + ]; |
|
| 35 | + if (in_array($filename, $existingFilenames)) { |
|
| 36 | + $image = new TestImage(); |
|
| 37 | + |
|
| 38 | + return $image; |
|
| 39 | + } |
|
| 40 | + else { |
|
| 41 | + return null; |
|
| 42 | + } |
|
| 43 | + } |
|
| 44 | + ) |
|
| 45 | + ); |
|
| 46 | 46 | |
| 47 | 47 | $transliterator = new FilenameTransliterator($fileToObject); |
| 48 | 48 | |
@@ -27,7 +27,7 @@ |
||
| 27 | 27 | ->method('getObjectFromFilename') |
| 28 | 28 | ->will( |
| 29 | 29 | $this->returnCallback( |
| 30 | - function ($filename) { |
|
| 30 | + function($filename) { |
|
| 31 | 31 | $existingFilenames = [ |
| 32 | 32 | 'test.jpg', |
| 33 | 33 | 'test_1.jpg', |
@@ -36,8 +36,7 @@ |
||
| 36 | 36 | $image = new TestImage(); |
| 37 | 37 | |
| 38 | 38 | return $image; |
| 39 | - } |
|
| 40 | - else { |
|
| 39 | + } else { |
|
| 41 | 40 | return null; |
| 42 | 41 | } |
| 43 | 42 | } |
@@ -53,8 +53,8 @@ |
||
| 53 | 53 | |
| 54 | 54 | if (!$valid) { |
| 55 | 55 | $this->context->buildViolation($constraint->message) |
| 56 | - ->setParameter('{{ string }}', $value) |
|
| 57 | - ->addViolation() |
|
| 56 | + ->setParameter('{{ string }}', $value) |
|
| 57 | + ->addViolation() |
|
| 58 | 58 | ; |
| 59 | 59 | } |
| 60 | 60 | } |
@@ -36,8 +36,7 @@ |
||
| 36 | 36 | $testValue = str_replace(' ', '', $value); |
| 37 | 37 | if (!preg_match('/^(\d+),(\d+),(\d+),(\d+):(\d+),(\d+),(\d+),(\d+)$/', $testValue, $matches)) { |
| 38 | 38 | $valid = false; |
| 39 | - } |
|
| 40 | - else { |
|
| 39 | + } else { |
|
| 41 | 40 | // Check the focus rectangle is inside the crop rectangle. |
| 42 | 41 | $cropFocusCoordinates = explode(':', $testValue); |
| 43 | 42 | $crop = explode(',', $cropFocusCoordinates[0]); |
@@ -114,8 +114,7 @@ |
||
| 114 | 114 | if (!empty($uploaderEvent)) { |
| 115 | 115 | $this->eventDispatcher->dispatch(UploaderEvents::UPLOADER_UPLOADED, $uploaderEvent); |
| 116 | 116 | } |
| 117 | - } |
|
| 118 | - else { |
|
| 117 | + } else { |
|
| 119 | 118 | $error = empty($this->error) ? $this->file->getErrorMessage() : $this->error; |
| 120 | 119 | throw new FileException( |
| 121 | 120 | $error |
@@ -14,7 +14,6 @@ |
||
| 14 | 14 | use IrishDan\ResponsiveImageBundle\Event\ImageEvent; |
| 15 | 15 | use IrishDan\ResponsiveImageBundle\Event\ImageEvents; |
| 16 | 16 | use IrishDan\ResponsiveImageBundle\ImageProcessing\ImageManager; |
| 17 | - |
|
| 18 | 17 | use Symfony\Component\EventDispatcher\EventSubscriberInterface; |
| 19 | 18 | |
| 20 | 19 | /** |