Skip to content

Commit

Permalink
CS fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jsor committed Oct 11, 2014
1 parent dd7b7af commit f8cffc8
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/Configurator/LaravelConfigurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Jsor\Stack\Hal\Configurator;

use Illuminate\Routing\Route;
use Illuminate\Routing\Router;
use Jsor\Stack\Hal\Response\HalResponse;
use Jsor\Stack\Hal\ResponseConverter;
use Nocarrier\Hal;
use Symfony\Component\HttpKernel\HttpKernelInterface;

Expand All @@ -13,14 +13,14 @@ class LaravelConfigurator implements ConfiguratorInterface
public function configureResponseConversion(HttpKernelInterface $app, $prettyPrint = false)
{
$app->extend('router', function (Router $router) use ($prettyPrint) {
$router->filter('JsorStackHalResponseConverter', function ($route, $request) use ($prettyPrint) {
$router->filter('JsorStackHalResponseConverter', function (Route $route, $request) use ($prettyPrint) {
$hal = $route->run($request);

if (!$hal instanceof Hal) {
return $hal;
}

return HalResponse::create($hal, 200, [], $prettyPrint);
return new HalResponse($hal, 200, [], $prettyPrint);
});

$router->when('*', 'JsorStackHalResponseConverter');
Expand Down
6 changes: 3 additions & 3 deletions src/Exception/ValidationErrorException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

use Nocarrier\Hal;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Symfony\Component\Validator\ConstraintViolationList;
use Symfony\Component\Validator\ConstraintViolationListInterface;

class ValidationErrorException extends BadRequestHttpException implements HalException
{
private $violationList;
private $logref;

public function __construct(ConstraintViolationList $violationList,
public function __construct(ConstraintViolationListInterface $violationList,
$message = null,
$logref = null,
\Exception $previous = null,
Expand All @@ -35,7 +35,7 @@ public function getHal()

$hal = new Hal(null, $data);

foreach ($this->violationList as $violation){
foreach ($this->violationList as $violation) {
$path = str_replace('][', '/', $violation->getPropertyPath());
$path = '/' . trim($path, '[]');

Expand Down
2 changes: 1 addition & 1 deletion src/Response/VndErrorResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static function fromException(\Exception $exception, $prettyPrint = false
$hal->setData($data);
}

return static::create($hal, $statusCode, $headers, $prettyPrint);
return new static($hal, $statusCode, $headers, $prettyPrint);
}

public function prepare(Request $request)
Expand Down
2 changes: 1 addition & 1 deletion src/ResponseConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQ
return $hal;
}

return HalResponse::create($hal, 200, [], $this->prettyPrint);
return new HalResponse($hal, 200, [], $this->prettyPrint);
}
}
4 changes: 0 additions & 4 deletions tests/Exception/ValidationErrorExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@

namespace Jsor\Stack\Hal\Exception;

use Jsor\Stack\Hal\Fixtures\Form\FormType;
use Symfony\Component\Form\Extension\Validator\ValidatorExtension;
use Symfony\Component\Form\Forms;
use Symfony\Component\Validator\Constraints\Collection;
use Symfony\Component\Validator\Constraints\Date;
use Symfony\Component\Validator\Constraints\Email;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Validation;
use Symfony\Component\Validator\ValidatorBuilder;

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/Form/PersonType.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ public function getName()
{
return 'person';
}
}
}

0 comments on commit f8cffc8

Please sign in to comment.