From 4346a86068781f4acdeb574d7e2af08b77b58ea7 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Sat, 30 May 2015 13:52:26 +0200 Subject: CS --- .../Controller/WallabagRestController.php | 38 +++++++++++++--------- .../DependencyInjection/Configuration.php | 2 +- .../Authentication/Provider/WsseProvider.php | 9 ++--- .../Authentication/Token/WsseUserToken.php | 1 + .../Controller/WallabagRestControllerTest.php | 8 ++--- 5 files changed, 33 insertions(+), 25 deletions(-) (limited to 'src/Wallabag/ApiBundle') diff --git a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php index 21e4552d..2f5923c8 100644 --- a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php +++ b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php @@ -47,6 +47,7 @@ class WallabagRestController extends Controller * {"name"="username", "dataType"="string", "required"=true, "description"="username"} * } * ) + * * @return array */ public function getSaltAction($username) @@ -77,6 +78,7 @@ class WallabagRestController extends Controller * {"name"="tags", "dataType"="string", "required"=false, "format"="api%2Crest", "description"="a list of tags url encoded. Will returns entries that matches ALL tags."}, * } * ) + * * @return Entry */ public function getEntriesAction(Request $request) @@ -109,13 +111,14 @@ class WallabagRestController extends Controller } /** - * Retrieve a single entry + * Retrieve a single entry. * * @ApiDoc( * requirements={ * {"name"="entry", "dataType"="integer", "requirement"="\w+", "description"="The entry ID"} * } * ) + * * @return Entry */ public function getEntryAction(Entry $entry) @@ -128,7 +131,7 @@ class WallabagRestController extends Controller } /** - * Create an entry + * Create an entry. * * @ApiDoc( * parameters={ @@ -137,6 +140,7 @@ class WallabagRestController extends Controller * {"name"="tags", "dataType"="string", "required"=false, "format"="tag1,tag2,tag3", "description"="a comma-separated list of tags."}, * } * ) + * * @return Entry */ public function postEntriesAction(Request $request) @@ -164,7 +168,7 @@ class WallabagRestController extends Controller } /** - * Change several properties of an entry + * Change several properties of an entry. * * @ApiDoc( * requirements={ @@ -177,15 +181,16 @@ class WallabagRestController extends Controller * {"name"="star", "dataType"="boolean", "required"=false, "format"="true or false", "description"="starred the entry."}, * } * ) + * * @return Entry */ public function patchEntriesAction(Entry $entry, Request $request) { $this->validateUserAccess($entry->getUser()->getId(), $this->getUser()->getId()); - $title = $request->request->get("title"); - $isArchived = $request->request->get("archive"); - $isStarred = $request->request->get("star"); + $title = $request->request->get('title'); + $isArchived = $request->request->get('archive'); + $isStarred = $request->request->get('star'); if (!is_null($title)) { $entry->setTitle($title); @@ -213,13 +218,14 @@ class WallabagRestController extends Controller } /** - * Delete **permanently** an entry + * Delete **permanently** an entry. * * @ApiDoc( * requirements={ * {"name"="entry", "dataType"="integer", "requirement"="\w+", "description"="The entry ID"} * } * ) + * * @return Entry */ public function deleteEntriesAction(Entry $entry) @@ -236,7 +242,7 @@ class WallabagRestController extends Controller } /** - * Retrieve all tags for an entry + * Retrieve all tags for an entry. * * @ApiDoc( * requirements={ @@ -254,7 +260,7 @@ class WallabagRestController extends Controller } /** - * Add one or more tags to an entry + * Add one or more tags to an entry. * * @ApiDoc( * requirements={ @@ -284,7 +290,7 @@ class WallabagRestController extends Controller } /** - * Permanently remove one tag for an entry + * Permanently remove one tag for an entry. * * @ApiDoc( * requirements={ @@ -308,7 +314,7 @@ class WallabagRestController extends Controller } /** - * Retrieve all tags + * Retrieve all tags. * * @ApiDoc() */ @@ -320,7 +326,7 @@ class WallabagRestController extends Controller } /** - * Permanently remove one tag from **every** entry + * Permanently remove one tag from **every** entry. * * @ApiDoc( * requirements={ @@ -343,10 +349,10 @@ class WallabagRestController extends Controller /** * Validate that the first id is equal to the second one. - * If not, throw exception. It means a user try to access information from an other user + * If not, throw exception. It means a user try to access information from an other user. * - * @param integer $requestUserId User id from the requested source - * @param integer $currentUserId User id from the retrieved source + * @param int $requestUserId User id from the requested source + * @param int $currentUserId User id from the retrieved source */ private function validateUserAccess($requestUserId, $currentUserId) { @@ -357,7 +363,7 @@ class WallabagRestController extends Controller /** * Send a JSON Response. - * We don't use the Symfony JsonRespone, because it takes an array as parameter instead of a JSON string + * We don't use the Symfony JsonRespone, because it takes an array as parameter instead of a JSON string. * * @param string $json * diff --git a/src/Wallabag/ApiBundle/DependencyInjection/Configuration.php b/src/Wallabag/ApiBundle/DependencyInjection/Configuration.php index 80a07ca2..cec45412 100644 --- a/src/Wallabag/ApiBundle/DependencyInjection/Configuration.php +++ b/src/Wallabag/ApiBundle/DependencyInjection/Configuration.php @@ -6,7 +6,7 @@ use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\ConfigurationInterface; /** - * This is the class that validates and merges configuration from your app/config files + * This is the class that validates and merges configuration from your app/config files. * * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class} */ diff --git a/src/Wallabag/ApiBundle/Security/Authentication/Provider/WsseProvider.php b/src/Wallabag/ApiBundle/Security/Authentication/Provider/WsseProvider.php index 8e49167a..db73ae2a 100644 --- a/src/Wallabag/ApiBundle/Security/Authentication/Provider/WsseProvider.php +++ b/src/Wallabag/ApiBundle/Security/Authentication/Provider/WsseProvider.php @@ -1,4 +1,5 @@ userProvider->loadUserByUsername($token->getUsername()); if (!$user) { - throw new AuthenticationException("Bad credentials. Did you forgot your username?"); + throw new AuthenticationException('Bad credentials. Did you forgot your username?'); } if ($user && $this->validateDigest($token->digest, $token->nonce, $token->created, $user->getPassword())) { @@ -46,12 +47,12 @@ class WsseProvider implements AuthenticationProviderInterface { // Check created time is not in the future if (strtotime($created) > time()) { - throw new AuthenticationException("Back to the future..."); + throw new AuthenticationException('Back to the future...'); } // Expire timestamp after 5 minutes if (time() - strtotime($created) > 300) { - throw new AuthenticationException("Too late for this timestamp... Watch your watch."); + throw new AuthenticationException('Too late for this timestamp... Watch your watch.'); } // Validate nonce is unique within 5 minutes @@ -65,7 +66,7 @@ class WsseProvider implements AuthenticationProviderInterface $expected = base64_encode(sha1(base64_decode($nonce).$created.$secret, true)); if ($digest !== $expected) { - throw new AuthenticationException("Bad credentials ! Digest is not as expected."); + throw new AuthenticationException('Bad credentials ! Digest is not as expected.'); } return $digest === $expected; diff --git a/src/Wallabag/ApiBundle/Security/Authentication/Token/WsseUserToken.php b/src/Wallabag/ApiBundle/Security/Authentication/Token/WsseUserToken.php index aa68dbdc..e6d30224 100644 --- a/src/Wallabag/ApiBundle/Security/Authentication/Token/WsseUserToken.php +++ b/src/Wallabag/ApiBundle/Security/Authentication/Token/WsseUserToken.php @@ -1,4 +1,5 @@ getResponse()->getContent(), true); $this->assertArrayHasKey('tags', $content); - $this->assertEquals($nbTags+3, count($content['tags'])); + $this->assertEquals($nbTags + 3, count($content['tags'])); $entryDB = $client->getContainer() ->get('doctrine.orm.entity_manager') @@ -369,7 +369,7 @@ class WallabagRestControllerTest extends WebTestCase $content = json_decode($client->getResponse()->getContent(), true); $this->assertArrayHasKey('tags', $content); - $this->assertEquals($nbTags-1, count($content['tags'])); + $this->assertEquals($nbTags - 1, count($content['tags'])); } public function testGetUserTags() -- cgit v1.2.3