@@ -2,9 +2,7 @@ |
||
| 2 | 2 | use DavidePastore\CodiceFiscale\Calculator; |
| 3 | 3 | use DavidePastore\CodiceFiscale\Checker; |
| 4 | 4 | use DavidePastore\CodiceFiscale\Subject; |
| 5 | - |
|
| 6 | 5 | use Symfony\Component\HttpFoundation\Request; |
| 7 | -use Symfony\Component\HttpFoundation\Response; |
|
| 8 | 6 | use Symfony\Component\HttpFoundation\JsonResponse; |
| 9 | 7 | use Symfony\Component\PropertyAccess\PropertyAccess; |
| 10 | 8 | use Symfony\Component\Validator\Constraints as Assert; |
@@ -146,8 +146,8 @@ |
||
| 146 | 146 | $subject = new Subject($data); |
| 147 | 147 | |
| 148 | 148 | $checker = new Checker($subject, array( |
| 149 | - 'codiceFiscaleToCheck' => $data['codiceFiscale'], |
|
| 150 | - 'omocodiaLevel' => $data['omocodiaLevel'] |
|
| 149 | + 'codiceFiscaleToCheck' => $data['codiceFiscale'], |
|
| 150 | + 'omocodiaLevel' => $data['omocodiaLevel'] |
|
| 151 | 151 | )); |
| 152 | 152 | |
| 153 | 153 | if ($checker->check()) { |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | $api = $app['controllers_factory']; |
| 14 | 14 | |
| 15 | 15 | //Calculate the codice fiscale by the given parameters. |
| 16 | -$api->get('/calculate', function (Silex\Application $app, Request $request) { |
|
| 16 | +$api->get('/calculate', function(Silex\Application $app, Request $request) { |
|
| 17 | 17 | $constraint = new Assert\Collection(array( |
| 18 | 18 | 'name' => $app['codice-fiscale-rest.constraints']['name'], |
| 19 | 19 | 'surname' => $app['codice-fiscale-rest.constraints']['surname'], |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | |
| 65 | 65 | //Calculate all the codice fiscale by the given parameters. |
| 66 | -$api->get('/calculateAll', function (Silex\Application $app, Request $request) { |
|
| 66 | +$api->get('/calculateAll', function(Silex\Application $app, Request $request) { |
|
| 67 | 67 | $constraint = new Assert\Collection(array( |
| 68 | 68 | 'name' => $app['codice-fiscale-rest.constraints']['name'], |
| 69 | 69 | 'surname' => $app['codice-fiscale-rest.constraints']['surname'], |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | ->bind('apiCalculateAll'); |
| 109 | 109 | |
| 110 | 110 | //Check if the given parameters are ok for the given parameters. |
| 111 | -$api->get('/check', function (Silex\Application $app, Request $request) { |
|
| 111 | +$api->get('/check', function(Silex\Application $app, Request $request) { |
|
| 112 | 112 | $constraint = new Assert\Collection(array( |
| 113 | 113 | 'name' => $app['codice-fiscale-rest.constraints']['name'], |
| 114 | 114 | 'surname' => $app['codice-fiscale-rest.constraints']['surname'], |
@@ -153,8 +153,7 @@ |
||
| 153 | 153 | if ($checker->check()) { |
| 154 | 154 | $response->status = true; |
| 155 | 155 | $response->message = 'Valid codice fiscale'; |
| 156 | - } |
|
| 157 | - else { |
|
| 156 | + } else { |
|
| 158 | 157 | $response->status = false; |
| 159 | 158 | $response->message = 'Invalid codice fiscale'; |
| 160 | 159 | } |
@@ -36,24 +36,24 @@ discard block |
||
| 36 | 36 | ); |
| 37 | 37 | |
| 38 | 38 | //Home page |
| 39 | -$app->get('/', function (Silex\Application $app) { |
|
| 39 | +$app->get('/', function(Silex\Application $app) { |
|
| 40 | 40 | return $app['twig']->render('index.twig'); |
| 41 | 41 | }) |
| 42 | 42 | ->bind('homepage'); |
| 43 | 43 | |
| 44 | 44 | //Documentazione |
| 45 | -$app->get('/documentazione', function (Silex\Application $app) { |
|
| 45 | +$app->get('/documentazione', function(Silex\Application $app) { |
|
| 46 | 46 | return $app['twig']->render('documentazione.twig'); |
| 47 | 47 | }) |
| 48 | 48 | ->bind('documentazione'); |
| 49 | 49 | |
| 50 | 50 | //Prova |
| 51 | -$app->get('/prova', function (Silex\Application $app) { |
|
| 51 | +$app->get('/prova', function(Silex\Application $app) { |
|
| 52 | 52 | return $app['twig']->render('prova.twig'); |
| 53 | 53 | }) |
| 54 | 54 | ->bind('prova'); |
| 55 | 55 | |
| 56 | -$app->error(function (\Exception $e, $code) { |
|
| 56 | +$app->error(function(\Exception $e, $code) { |
|
| 57 | 57 | switch ($code) { |
| 58 | 58 | case 404: |
| 59 | 59 | $message = 'The requested page could not be found.'; |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | $app->mount('/api/codiceFiscale', require 'api.php'); |
| 70 | 70 | |
| 71 | -$app->after(function (Request $request, Response $response) { |
|
| 71 | +$app->after(function(Request $request, Response $response) { |
|
| 72 | 72 | $response->headers->set('Access-Control-Allow-Origin', '*'); |
| 73 | 73 | }); |
| 74 | 74 | |