Skip to content
This repository has been archived by the owner on Jun 30, 2020. It is now read-only.

Commit

Permalink
bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarotero committed Dec 17, 2015
1 parent 6875ae2 commit 89cb460
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
5 changes: 5 additions & 0 deletions src/Middleware/Cors.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Neomerx\Cors\Analyzer;
use Neomerx\Cors\Contracts\AnalysisResultInterface;
use Neomerx\Cors\Contracts\Strategies\SettingsStrategyInterface;
use RuntimeException;

/**
* Middleware to implement Cors.
Expand Down Expand Up @@ -55,6 +56,10 @@ public function settings(SettingsStrategyInterface $settings)
*/
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next)
{
if (empty($this->settings)) {
throw new RuntimeException('No SettingsStrategyInterface instance has been provided');
}

$cors = Analyzer::instance($this->settings)->analyze($request);

switch ($cors->getRequestType()) {
Expand Down
3 changes: 1 addition & 2 deletions src/Middleware/Geolocate.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ public function __invoke(ServerRequestInterface $request, ResponseInterface $res
$geocoder = $this->geocoder ?: $this->getGeocoder();
$ip = ClientIp::getIp($request);

if ($ip) {
$ip = '123.9.34.23';
if ($ip !== null) {
$request = Middleware::setAttribute($request, self::KEY, $geocoder->geocode($ip));
}

Expand Down
10 changes: 5 additions & 5 deletions src/Middleware/ImageTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Psr7Middlewares\Utils;
use Psr7Middlewares\Middleware;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\ResponseInterface;
use Imagecow\Image;
use RuntimeException;
Expand Down Expand Up @@ -39,13 +39,13 @@ public function sizes(array $sizes)
/**
* Execute the middleware.
*
* @param RequestInterface $request
* @param ResponseInterface $response
* @param callable $next
* @param ServerRequestInterface $request
* @param ResponseInterface $response
* @param callable $next
*
* @return ResponseInterface
*/
public function __invoke(RequestInterface $request, ResponseInterface $response, callable $next)
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next)
{
if (!Middleware::hasAttribute($request, FormatNegotiator::KEY)) {
throw new RuntimeException('ResponsiveImage middleware needs FormatNegotiator executed before');
Expand Down
2 changes: 1 addition & 1 deletion src/Utils/FormTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function ($match) use ($input) {
$count
);

if ($count) {
if (!empty($count)) {
$body = Middleware::createStream();
$body->write($html);

Expand Down
5 changes: 2 additions & 3 deletions src/Utils/Path.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ public static function fix($path)
/**
* Join several pieces into a path.
*
* @param string $piece1
* @param string $piece2
* ...
* @param string
* ...
*
* @return string
*/
Expand Down

0 comments on commit 89cb460

Please sign in to comment.