Skip to content

Commit e60b895

Browse files
author
Mitch
committed
Method braces on next line - PSR-2
1 parent 25c95ca commit e60b895

File tree

2 files changed

+62
-31
lines changed

2 files changed

+62
-31
lines changed

src/ImageResize.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ class ImageResize
4545
* @return ImageResize
4646
* @throws \exception
4747
*/
48-
public static function createFromString($imageData) {
48+
public static function createFromString($imageData)
49+
{
4950
$s = new self();
5051
$s->loadFromString($imageData);
5152
return $s;
@@ -233,7 +234,8 @@ public function save($filename, $image_type = null, $quality = null, $permission
233234
* @param int $quality
234235
* @return string
235236
*/
236-
public function getImageAsString($image_type = null, $quality = null) {
237+
public function getImageAsString($image_type = null, $quality = null)
238+
{
237239
$string_temp = tempnam('', '');
238240

239241
$this->save($string_temp, $image_type, $quality);
@@ -250,7 +252,8 @@ public function getImageAsString($image_type = null, $quality = null) {
250252
*
251253
* @return string
252254
*/
253-
public function __toString() {
255+
public function __toString()
256+
{
254257
return $this->getImageAsString();
255258
}
256259

test/Test.php

Lines changed: 56 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -21,31 +21,35 @@ class ImageResizeTest extends PHPUnit_Framework_TestCase
2121
* Loading tests
2222
*/
2323

24-
public function testLoadGif() {
24+
public function testLoadGif()
25+
{
2526
$image = $this->createImage(1, 1, 'gif');
2627
$resize = ImageResize::createFromFile($image);
2728

2829
$this->assertEquals(IMAGETYPE_GIF, $resize->source_type);
2930
$this->assertInstanceOf('\Eventviva\ImageResize', $resize);
3031
}
3132

32-
public function testLoadJpg() {
33+
public function testLoadJpg()
34+
{
3335
$image = $this->createImage(1, 1, 'jpeg');
3436
$resize = ImageResize::createFromFile($image);
3537

3638
$this->assertEquals(IMAGETYPE_JPEG, $resize->source_type);
3739
$this->assertInstanceOf('\Eventviva\ImageResize', $resize);
3840
}
3941

40-
public function testLoadPng() {
42+
public function testLoadPng()
43+
{
4144
$image = $this->createImage(1, 1, 'png');
4245
$resize = ImageResize::createFromFile($image);
4346

4447
$this->assertEquals(IMAGETYPE_PNG, $resize->source_type);
4548
$this->assertInstanceOf('\Eventviva\ImageResize', $resize);
4649
}
4750

48-
public function testLoadString() {
51+
public function testLoadString()
52+
{
4953
$resize = ImageResize::createFromString(base64_decode($this->image_string));
5054

5155
$this->assertEquals(IMAGETYPE_GIF, $resize->source_type);
@@ -61,31 +65,35 @@ public function testLoadString() {
6165
* @expectedException Exception
6266
* @expectedExceptionMessage No image provided
6367
*/
64-
public function testLoadNoFile() {
68+
public function testLoadNoFile()
69+
{
6570
new ImageResize(null);
6671
}
6772

6873
/**
6974
* @expectedException Exception
7075
* @expectedExceptionMessage Could not read
7176
*/
72-
public function testLoadUnsupportedFile() {
77+
public function testLoadUnsupportedFile()
78+
{
7379
new ImageResize(__FILE__);
7480
}
7581

7682
/**
7783
* @expectedException Exception
7884
* @expectedExceptionMessage Could not load
7985
*/
80-
public function testLoadUnsupportedFileString() {
86+
public function testLoadUnsupportedFileString()
87+
{
8188
ImageResize::createFromString('');
8289
}
8390

8491
/**
8592
* @expectedException Exception
8693
* @expectedExceptionMessage Unsupported image type
8794
*/
88-
public function testLoadUnsupportedImage() {
95+
public function testLoadUnsupportedImage()
96+
{
8997
$filename = $this->getTempFile();
9098

9199
$image = fopen($filename, 'w');
@@ -99,7 +107,8 @@ public function testLoadUnsupportedImage() {
99107
* @expectedException Exception
100108
* @expectedExceptionMessage Unsupported image type
101109
*/
102-
public function testInvalidString() {
110+
public function testInvalidString()
111+
{
103112
ImageResize::createFromString(base64_decode($this->unsupported_image));
104113
}
105114

@@ -108,7 +117,8 @@ public function testInvalidString() {
108117
* Resize tests
109118
*/
110119

111-
public function testResizeToHeight() {
120+
public function testResizeToHeight()
121+
{
112122
$image = $this->createImage(200, 100, 'png');
113123
$resize = new ImageResize($image);
114124

@@ -118,7 +128,8 @@ public function testResizeToHeight() {
118128
$this->assertEquals(50, $resize->getDestHeight());
119129
}
120130

121-
public function testResizeToWidth() {
131+
public function testResizeToWidth()
132+
{
122133
$image = $this->createImage(200, 100, 'png');
123134
$resize = new ImageResize($image);
124135

@@ -128,7 +139,8 @@ public function testResizeToWidth() {
128139
$this->assertEquals(50, $resize->getDestHeight());
129140
}
130141

131-
public function testScale() {
142+
public function testScale()
143+
{
132144
$image = $this->createImage(200, 100, 'png');
133145
$resize = new ImageResize($image);
134146

@@ -138,7 +150,8 @@ public function testScale() {
138150
$this->assertEquals(50, $resize->getDestHeight());
139151
}
140152

141-
public function testResize() {
153+
public function testResize()
154+
{
142155
$image = $this->createImage(200, 100, 'png');
143156
$resize = new ImageResize($image);
144157

@@ -148,7 +161,8 @@ public function testResize() {
148161
$this->assertEquals(50, $resize->getDestHeight());
149162
}
150163

151-
public function testResizeLargerNotAllowed() {
164+
public function testResizeLargerNotAllowed()
165+
{
152166
$image = $this->createImage(200, 100, 'png');
153167
$resize = new ImageResize($image);
154168

@@ -163,7 +177,8 @@ public function testResizeLargerNotAllowed() {
163177
* Crop tests
164178
*/
165179

166-
public function testCrop() {
180+
public function testCrop()
181+
{
167182
$image = $this->createImage(200, 100, 'png');
168183
$resize = new ImageResize($image);
169184

@@ -173,7 +188,8 @@ public function testCrop() {
173188
$this->assertEquals(50, $resize->getDestHeight());
174189
}
175190

176-
public function testCropPosition() {
191+
public function testCropPosition()
192+
{
177193
$image = $this->createImage(200, 100, 'png');
178194
$resize = new ImageResize($image);
179195

@@ -186,7 +202,8 @@ public function testCropPosition() {
186202
$this->assertEquals(100, $source_x->getValue($resize));
187203
}
188204

189-
public function testCropLargerNotAllowed() {
205+
public function testCropLargerNotAllowed()
206+
{
190207
$image = $this->createImage(200, 100, 'png');
191208
$resize = new ImageResize($image);
192209

@@ -201,7 +218,8 @@ public function testCropLargerNotAllowed() {
201218
* Save tests
202219
*/
203220

204-
public function testSaveGif() {
221+
public function testSaveGif()
222+
{
205223
$image = $this->createImage(200, 100, 'gif');
206224

207225
$resize = new ImageResize($image);
@@ -213,7 +231,8 @@ public function testSaveGif() {
213231
$this->assertEquals(IMAGETYPE_GIF, exif_imagetype($filename));
214232
}
215233

216-
public function testSaveJpg() {
234+
public function testSaveJpg()
235+
{
217236
$image = $this->createImage(200, 100, 'jpeg');
218237

219238
$resize = new ImageResize($image);
@@ -225,7 +244,8 @@ public function testSaveJpg() {
225244
$this->assertEquals(IMAGETYPE_JPEG, exif_imagetype($filename));
226245
}
227246

228-
public function testSavePng() {
247+
public function testSavePng()
248+
{
229249
$image = $this->createImage(200, 100, 'png');
230250

231251
$resize = new ImageResize($image);
@@ -237,7 +257,8 @@ public function testSavePng() {
237257
$this->assertEquals(IMAGETYPE_PNG, exif_imagetype($filename));
238258
}
239259

240-
public function testSaveChmod() {
260+
public function testSaveChmod()
261+
{
241262
$image = $this->createImage(200, 100, 'png');
242263

243264
$resize = new ImageResize($image);
@@ -254,13 +275,15 @@ public function testSaveChmod() {
254275
* String test
255276
*/
256277

257-
public function testGetImageAsString() {
278+
public function testGetImageAsString()
279+
{
258280
$resize = ImageResize::createFromString(base64_decode($this->image_string));
259281
$image = $resize->getImageAsString();
260282
$this->assertEquals(43, strlen($image));
261283
}
262284

263-
public function testToString() {
285+
public function testToString()
286+
{
264287
$resize = ImageResize::createFromString(base64_decode($this->image_string));
265288
$image = (string)$resize;
266289
$this->assertEquals(43, strlen($image));
@@ -271,7 +294,8 @@ public function testToString() {
271294
* Output tests
272295
*/
273296

274-
public function testOutputGif() {
297+
public function testOutputGif()
298+
{
275299
$image = $this->createImage(200, 100, 'gif');
276300

277301
$resize = new ImageResize($image);
@@ -290,7 +314,8 @@ public function testOutputGif() {
290314
$this->assertEquals('image/gif', $type);
291315
}
292316

293-
public function testOutputJpg() {
317+
public function testOutputJpg()
318+
{
294319
$image = $this->createImage(200, 100, 'jpeg');
295320

296321
$resize = new ImageResize($image);
@@ -309,7 +334,8 @@ public function testOutputJpg() {
309334
$this->assertEquals('image/jpeg', $type);
310335
}
311336

312-
public function testOutputPng() {
337+
public function testOutputPng()
338+
{
313339
$image = $this->createImage(200, 100, 'png');
314340

315341
$resize = new ImageResize($image);
@@ -333,7 +359,8 @@ public function testOutputPng() {
333359
* Helpers
334360
*/
335361

336-
private function createImage($width, $height, $type) {
362+
private function createImage($width, $height, $type)
363+
{
337364
if (!in_array($type, $this->image_types)) {
338365
throw new \Exception('Unsupported image type');
339366
}
@@ -348,7 +375,8 @@ private function createImage($width, $height, $type) {
348375
return $filename;
349376
}
350377

351-
private function getTempFile() {
378+
private function getTempFile()
379+
{
352380
return tempnam(sys_get_temp_dir(), 'resize_test_image');
353381
}
354382

0 commit comments

Comments
 (0)