Skip to content

Commit

Permalink
Applied fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad authored and StyleCIBot committed Dec 14, 2015
1 parent 6a8d022 commit b4a6a96
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 24 deletions.
6 changes: 2 additions & 4 deletions src/Responses/CakeResponseFactory.php
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
<?php
namespace ADmad\Glide\Responses;

use Cake\Core\Configure;
use Cake\Network\Response;
use Cake\Utility\Hash;
use League\Flysystem\FilesystemInterface;
use League\Glide\Responses\ResponseFactoryInterface;

class CakeResponseFactory implements ResponseFactoryInterface
{

/**
* Create the response.
*
* @param \League\Flysystem\FilesystemInterface $cache The cache file system.
* @param string $path The cached file path.
*
* @return \Cake\Network\Response The response object.
*/
public function create(FilesystemInterface $cache, $path)
{
$stream = $cache->readStream($path);

$contentType = $cache->getMimetype($path);
$contentLength = (string)$cache->getSize($path);
$contentLength = (string) $cache->getSize($path);

$response = new Response();
$response->type($contentType);
Expand Down
5 changes: 2 additions & 3 deletions src/Routing/Filter/GlideFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@
use Cake\Routing\DispatcherFilter;
use Cake\Utility\Hash;
use Cake\Utility\Security;
use DateTime;
use League\Glide\ServerFactory;
use League\Glide\Signatures\SignatureFactory;

class GlideFilter extends DispatcherFilter
{

/**
* Callback for Routing.beforeDispatch event.
*
* @param \Cake\Event\Event $event The event instance.
*
* @return \Cake\Network\Response Response instance.
*/
public function beforeDispatch(Event $event)
Expand Down Expand Up @@ -47,7 +46,7 @@ public function beforeDispatch(Event $event)
$response = $server->getImageResponse($path, $request->query);
}

$headers = Hash::filter((array)Configure::read('Glide.headers'));
$headers = Hash::filter((array) Configure::read('Glide.headers'));
foreach ($headers as $key => $value) {
$response->header($key, $value);
}
Expand Down
5 changes: 4 additions & 1 deletion src/View/Helper/GlideHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

class GlideHelper extends Helper
{

/**
* Helpers used by this helper.
*
Expand All @@ -29,7 +28,9 @@ class GlideHelper extends Helper
* @param string $path Image path.
* @param array $params Image manipulation parameters.
* @param array $options Array of HTML attributes for image tag.
*
* @return string Complete <img> tag.
*
* @see http://glide.thephpleague.com/1.0/api/quick-reference/
*/
public function image($path, array $params = [], array $options = [])
Expand All @@ -42,7 +43,9 @@ public function image($path, array $params = [], array $options = [])
*
* @param string $path Image path.
* @param array $params Image manipulation parameters.
*
* @return string Image URL.
*
* @see http://glide.thephpleague.com/1.0/api/quick-reference/
*/
public function url($path, array $params = [])
Expand Down
16 changes: 8 additions & 8 deletions tests/TestCase/Routing/Filter/GlideFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ public function setUp()
'base_url' => '/images/',
'source' => PLUGIN_ROOT . '/test_app/webroot/upload',
'cache' => TMP . '/cache',
'response' => new CakeResponseFactory,
]
'response' => new CakeResponseFactory(),
],
]);

$request = new Request;
$request = new Request();
$request->url = 'images/cake-logo.png';
$request->query = ['w' => 100];

$response = new Response;
$response = new Response();
$this->event = new Event(
'Dispatcher.beforeDispatch',
null,
Expand All @@ -45,7 +45,7 @@ public function tearDown()

public function testBeforeDispatch()
{
$response = (new GlideFilter)->beforeDispatch($this->event);
$response = (new GlideFilter())->beforeDispatch($this->event);

$this->assertInstanceOf('Cake\Network\Response', $response);
$this->assertTrue(is_callable($response->body()));
Expand All @@ -64,7 +64,7 @@ public function testSecureUrl()

$this->event->data['request']->url = 'images/cake%20logo.png';
$this->event->data['request']->query = ['w' => 100, 's' => $sig];
$response = (new GlideFilter)->beforeDispatch($this->event);
$response = (new GlideFilter())->beforeDispatch($this->event);

$this->assertInstanceOf('Cake\Network\Response', $response);
}
Expand All @@ -73,7 +73,7 @@ public function testCache()
{
Configure::write('Glide.cache', '+1 days');

$response = (new GlideFilter)->beforeDispatch($this->event);
$response = (new GlideFilter())->beforeDispatch($this->event);
$this->assertTrue(is_dir(TMP . '/cache/cake-logo.png'));

$headers = $response->header();
Expand All @@ -82,7 +82,7 @@ public function testCache()
$this->assertTrue(isset($headers['Expires']));

$this->event->data['request']->env('HTTP_IF_MODIFIED_SINCE', $headers['Last-Modified']);
$response = (new GlideFilter)->beforeDispatch($this->event);
$response = (new GlideFilter())->beforeDispatch($this->event);
$this->assertFalse(is_callable($response->body()));
}
}
12 changes: 6 additions & 6 deletions tests/TestCase/View/Helper/GlideHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ public function setUp()
{
Configure::write('Glide', [
'serverConfig' => [
'base_url' => '/images/'
'base_url' => '/images/',
],
]);

$this->request = new Request;
$this->request = new Request();
$this->request->webroot = '/';
$this->view = new View($this->request);
$this->helper = new GlideHelper($this->view);
Expand Down Expand Up @@ -53,8 +53,8 @@ public function testImage()
'img' => [
'src' => '/images/logo.png?w=100',
'width' => 100,
'alt' => ''
]
'alt' => '',
],
], $result);

$this->helper->request->webroot = '/subfolder/';
Expand All @@ -63,8 +63,8 @@ public function testImage()
'img' => [
'src' => '/subfolder/images/logo.png?w=100',
'width' => 100,
'alt' => ''
]
'alt' => '',
],
], $result);
}
}
4 changes: 2 additions & 2 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
use Cake\Core\Plugin;

/**
/*
* Test suite bootstrap
*
* This function is used to find the location of CakePHP whether CakePHP
Expand All @@ -16,7 +16,7 @@
return $root;
}
} while ($root !== $lastRoot);
throw new Exception("Cannot find the root of the application, unable to run tests");
throw new Exception('Cannot find the root of the application, unable to run tests');
};
$root = $findRoot(__FILE__);
unset($findRoot);
Expand Down

0 comments on commit b4a6a96

Please sign in to comment.