From c9f9256aa0c13ce1de8b5099e090bfa397df6d84 Mon Sep 17 00:00:00 2001 From: Kapil Date: Tue, 9 Feb 2016 08:57:22 -0500 Subject: [PATCH] Applied fixes from StyleCI --- .../Admin/CategoriesController.php | 16 +- app/Controllers/Admin/TagsController.php | 16 +- app/Controllers/Admin/UsersController.php | 3 +- app/Controllers/AuthController.php | 25 +- app/Controllers/BaseController.php | 24 +- app/Controllers/BrowseController.php | 33 ++- app/Controllers/FeedsController.php | 3 +- app/Controllers/HomeController.php | 3 +- app/Controllers/RemindersController.php | 9 +- app/Controllers/SearchController.php | 7 +- app/Controllers/SitemapController.php | 3 +- app/Controllers/TricksController.php | 20 +- app/Controllers/UserController.php | 21 +- app/Controllers/UserTricksController.php | 52 ++-- app/Tricks/Category.php | 8 +- app/Tricks/Events/ViewTrickHandler.php | 20 +- .../Exceptions/AbstractNotFoundException.php | 1 - .../Exceptions/CategoryNotFoundException.php | 1 - .../Exceptions/GithubEmailAccessException.php | 1 - .../GithubEmailNotVerifiedException.php | 1 - .../Exceptions/TagNotFoundException.php | 1 - .../Exceptions/UserNotFoundException.php | 1 - app/Tricks/Filters/TrickOwnerFilter.php | 21 +- app/Tricks/Filters/ViewThrottleFilter.php | 17 +- app/Tricks/Presenters/TrickPresenter.php | 38 +-- app/Tricks/Presenters/UserPresenter.php | 12 +- app/Tricks/Profile.php | 3 +- app/Tricks/Providers/EventServiceProvider.php | 1 - .../Providers/SitemapServiceProvider.php | 2 - .../Providers/SocialServiceProvider.php | 10 +- .../CategoryRepositoryInterface.php | 22 +- .../Eloquent/AbstractRepository.php | 5 +- .../Eloquent/CategoryRepository.php | 50 ++-- .../Eloquent/ProfileRepository.php | 42 +-- .../Repositories/Eloquent/TagRepository.php | 33 ++- .../Repositories/Eloquent/TrickRepository.php | 126 ++++---- .../Repositories/Eloquent/UserRepository.php | 60 ++-- .../ProfileRepositoryInterface.php | 19 +- .../Repositories/TagRepositoryInterface.php | 19 +- .../Repositories/TrickRepositoryInterface.php | 70 +++-- .../Repositories/UserRepositoryInterface.php | 26 +- app/Tricks/Services/Feeds/Builder.php | 18 +- app/Tricks/Services/Forms/CategoryForm.php | 2 +- .../Services/Forms/RegistrationForm.php | 9 +- app/Tricks/Services/Forms/SettingsForm.php | 15 +- app/Tricks/Services/Forms/TagForm.php | 2 +- app/Tricks/Services/Forms/TrickEditForm.php | 6 +- app/Tricks/Services/Forms/TrickForm.php | 4 +- app/Tricks/Services/Navigation/Builder.php | 43 +-- app/Tricks/Services/Sitemap/Builder.php | 39 ++- app/Tricks/Services/Sitemap/DataProvider.php | 27 +- app/Tricks/Services/Social/Disqus.php | 59 ++-- app/Tricks/Services/Social/Github.php | 55 ++-- .../Services/Upload/ImageUploadService.php | 58 ++-- app/Tricks/Tag.php | 8 +- app/Tricks/Trick.php | 80 ++--- app/Tricks/User.php | 276 +++++++++--------- app/config/app.php | 12 +- app/config/auth.php | 112 +++---- app/config/cache.php | 174 +++++------ app/config/compile.php | 26 +- app/config/config.php | 72 ++--- app/config/database.php | 244 ++++++++-------- app/config/local/app.php | 6 +- app/config/local/cache.php | 6 +- app/config/local/queue.php | 6 +- app/config/local/session.php | 6 +- app/config/mail.php | 244 ++++++++-------- app/config/navigation.php | 84 +++--- .../packages/itsgoingd/clockwork/config.php | 8 +- .../thomaswelton/laravel-gravatar/config.php | 8 +- app/config/queue.php | 116 ++++---- app/config/remote.php | 18 +- app/config/session.php | 248 ++++++++-------- app/config/sitemap.php | 16 +- app/config/social.php | 20 +- app/config/testing/cache.php | 30 +- app/config/testing/session.php | 32 +- app/config/view.php | 48 +-- app/config/workbench.php | 48 +-- .../2013_11_13_222806_create_users_table.php | 40 ++- .../2013_11_13_222807_create_tricks_table.php | 13 +- .../2013_11_13_222808_create_tags_table.php | 13 +- ...3_11_13_222809_create_categories_table.php | 10 +- .../2013_11_13_222810_create_votes_table.php | 11 +- ...13_11_13_222811_create_tag_trick_table.php | 11 +- ..._13_222812_create_category_trick_table.php | 11 +- ...013_11_13_222813_create_profiles_table.php | 31 +- ..._20_072925_add_order_to_category_table.php | 51 ++-- ..._11_22_072925_add_spam_to_tricks_table.php | 51 ++-- ...202456_create_password_reminders_table.php | 54 ++-- ...4_17_181442_add_remember_to_user_table.php | 52 ++-- app/database/seeds/CategoriesTableSeeder.php | 12 +- app/database/seeds/DatabaseSeeder.php | 31 +- app/database/seeds/TagsTableSeeder.php | 12 +- app/database/seeds/TricksTableSeeder.php | 68 +++-- app/database/seeds/UsersTableSeeder.php | 13 +- app/filters.php | 35 +-- app/lang/en/admin.php | 83 +++--- app/lang/en/browse.php | 35 +-- app/lang/en/emails.php | 13 +- app/lang/en/feeds.php | 16 +- app/lang/en/home.php | 84 +++--- app/lang/en/layouts.php | 13 +- app/lang/en/pagination.php | 31 +- app/lang/en/partials.php | 34 +-- app/lang/en/password.php | 32 +- app/lang/en/reminders.php | 16 +- app/lang/en/search.php | 12 +- app/lang/en/tricks.php | 49 ++-- app/lang/en/user.php | 67 ++--- app/lang/en/user_tricks.php | 15 +- app/lang/en/validation.php | 178 +++++------ app/routes.php | 95 +++--- app/start/artisan.php | 1 - app/start/global.php | 10 +- app/start/local.php | 2 +- app/tests/TestCase.php | 45 ++- app/tests/Tricks/CategoryTest.php | 17 +- .../Tricks/Events/ViewTrickHandlerTest.php | 93 +++--- .../Tricks/Filters/TrickOwnerFilterTest.php | 93 +++--- .../Tricks/Filters/ViewThrottleFilterTest.php | 113 ++++--- .../Tricks/Presenters/TrickPresenterTest.php | 191 ++++++------ .../Tricks/Presenters/UserPresenterTest.php | 84 +++--- app/tests/Tricks/ProfileTest.php | 17 +- .../Providers/EventServiceProviderTest.php | 23 +- .../NavigationServiceProviderTest.php | 23 +- .../RepositoryServiceProviderTest.php | 27 +- .../Providers/SitemapServiceProviderTest.php | 19 +- .../Providers/SocialServiceProviderTest.php | 69 +++-- .../Providers/UploadServiceProviderTest.php | 23 +- .../Eloquent/AbstractRepositoryTest.php | 33 +-- .../Eloquent/CategoryRepositoryTest.php | 162 +++++----- .../Eloquent/ProfileRepositoryTest.php | 79 +++-- .../Tricks/Services/Feeds/BuilderTest.php | 120 ++++---- .../Services/Forms/AbstractFormTest.php | 75 +++-- .../Services/Forms/RegistrationFormTest.php | 35 ++- .../Services/Forms/SettingsFormTest.php | 59 ++-- .../Services/Forms/TrickEditFormTest.php | 41 ++- .../Tricks/Services/Forms/TrickFormTest.php | 25 +- .../Upload/ImageUploadServiceTest.php | 130 ++++----- app/tests/Tricks/TagTest.php | 17 +- app/tests/Tricks/TrickTest.php | 35 ++- app/tests/Tricks/UserTest.php | 85 +++--- bootstrap/autoload.php | 5 +- bootstrap/paths.php | 110 +++---- bootstrap/start.php | 8 +- bootstrap/testing.php | 6 +- public/img/avatar/index.php | 2 +- public/img/avatar/temp/index.php | 2 +- public/img/index.php | 2 +- public/index.php | 3 +- server.php | 5 +- 153 files changed, 3198 insertions(+), 3113 deletions(-) diff --git a/app/Controllers/Admin/CategoriesController.php b/app/Controllers/Admin/CategoriesController.php index 66b3b0a..b0899fe 100644 --- a/app/Controllers/Admin/CategoriesController.php +++ b/app/Controllers/Admin/CategoriesController.php @@ -18,7 +18,8 @@ class CategoriesController extends BaseController /** * Create a new CategoriesController instance. * - * @param \Tricks\Repositories\CategoryRepositoryInterface $categories + * @param \Tricks\Repositories\CategoryRepositoryInterface $categories + * * @return void */ public function __construct(CategoryRepositoryInterface $categories) @@ -49,7 +50,7 @@ public function postIndex() { $form = $this->categories->getForm(); - if (! $form->isValid()) { + if (!$form->isValid()) { return $this->redirectRoute('admin.categories.index') ->withErrors($form->getErrors()) ->withInput(); @@ -79,7 +80,8 @@ public function postArrange() /** * Show the category edit form. * - * @param mixed $id + * @param mixed $id + * * @return \Response */ public function getView($id) @@ -92,14 +94,15 @@ public function getView($id) /** * Handle the editing of a category. * - * @param mixed $id + * @param mixed $id + * * @return \Illuminate\Http\RedirectResponse */ public function postView($id) { $form = $this->categories->getForm(); - if (! $form->isValid()) { + if (!$form->isValid()) { return $this->redirectRoute('admin.categories.view', $id) ->withErrors($form->getErrors()) ->withInput(); @@ -113,7 +116,8 @@ public function postView($id) /** * Delete a category from the database. * - * @param mixed $id + * @param mixed $id + * * @return \Illuminate\Http\RedirectResponse */ public function getDelete($id) diff --git a/app/Controllers/Admin/TagsController.php b/app/Controllers/Admin/TagsController.php index ddf2b99..c70e7bf 100644 --- a/app/Controllers/Admin/TagsController.php +++ b/app/Controllers/Admin/TagsController.php @@ -17,7 +17,8 @@ class TagsController extends BaseController /** * Create a new TagsController instance. * - * @param \Tricks\Repositories\TagRepositoryInterface $tags + * @param \Tricks\Repositories\TagRepositoryInterface $tags + * * @return void */ public function __construct(TagRepositoryInterface $tags) @@ -42,7 +43,8 @@ public function getIndex() /** * Delete a tag from the database. * - * @param mixed $id + * @param mixed $id + * * @return \Illuminate\Http\RedirectResponse */ public function getDelete($id) @@ -55,7 +57,8 @@ public function getDelete($id) /** * Show the tag edit form. * - * @param mixed $id + * @param mixed $id + * * @return \Response */ public function getView($id) @@ -74,7 +77,7 @@ public function postIndex() { $form = $this->tags->getForm(); - if (! $form->isValid()) { + if (!$form->isValid()) { return $this->redirectRoute('admin.tags.index') ->withErrors($form->getErrors()) ->withInput(); @@ -88,14 +91,15 @@ public function postIndex() /** * Handle the editing of a tag. * - * @param mixed $id + * @param mixed $id + * * @return \Illuminate\Http\RedirectResponse */ public function postView($id) { $form = $this->tags->getForm(); - if (! $form->isValid()) { + if (!$form->isValid()) { return $this->redirectRoute('admin.tags.view', $id) ->withErrors($form->getErrors()) ->withInput(); diff --git a/app/Controllers/Admin/UsersController.php b/app/Controllers/Admin/UsersController.php index cba8176..07e4a9f 100644 --- a/app/Controllers/Admin/UsersController.php +++ b/app/Controllers/Admin/UsersController.php @@ -17,7 +17,8 @@ class UsersController extends BaseController /** * Create a new UsersController instance. * - * @param \Tricks\Repositories\UserRepositoryInterface $users + * @param \Tricks\Repositories\UserRepositoryInterface $users + * * @return void */ public function __construct(UserRepositoryInterface $users) diff --git a/app/Controllers/AuthController.php b/app/Controllers/AuthController.php index ea77ca0..d534627 100644 --- a/app/Controllers/AuthController.php +++ b/app/Controllers/AuthController.php @@ -21,7 +21,8 @@ class AuthController extends BaseController /** * Create a new AuthController instance. * - * @param \Tricks\Repositories\UserRepositoryInterface $users + * @param \Tricks\Repositories\UserRepositoryInterface $users + * * @return void */ public function __construct(UserRepositoryInterface $users) @@ -48,8 +49,8 @@ public function getLogin() */ public function postLogin() { - $credentials = Input::only([ 'username', 'password' ]); - $remember = Input::get('remember', false); + $credentials = Input::only(['username', 'password']); + $remember = Input::get('remember', false); if (str_contains($credentials['username'], '@')) { $credentials['email'] = $credentials['username']; @@ -60,7 +61,7 @@ public function postLogin() return $this->redirectIntended(route('user.index')); } - return $this->redirectBack([ 'login_errors' => true ]); + return $this->redirectBack(['login_errors' => true]); } /** @@ -82,14 +83,14 @@ public function postRegister() { $form = $this->users->getRegistrationForm(); - if (! $form->isValid()) { - return $this->redirectBack([ 'errors' => $form->getErrors() ]); + if (!$form->isValid()) { + return $this->redirectBack(['errors' => $form->getErrors()]); } if ($user = $this->users->create($form->getInputData())) { Auth::login($user); - return $this->redirectRoute('user.index', [], [ 'first_use' => true ]); + return $this->redirectRoute('user.index', [], ['first_use' => true]); } return $this->redirectRoute('home'); @@ -102,8 +103,8 @@ public function postRegister() */ public function getLoginWithGithub() { - if (! Input::has('code')) { - Session::keep([ 'url' ]); + if (!Input::has('code')) { + Session::keep(['url']); GithubProvider::authorize(); } else { try { @@ -112,14 +113,14 @@ public function getLoginWithGithub() if (Session::get('password_required')) { return $this->redirectRoute('user.settings', [], [ - 'update_password' => true + 'update_password' => true, ]); } return $this->redirectIntended(route('user.index')); } catch (GithubEmailNotVerifiedException $e) { return $this->redirectRoute('auth.register', [ - 'github_email_not_verified' => true + 'github_email_not_verified' => true, ]); } } @@ -134,6 +135,6 @@ public function getLogout() { Auth::logout(); - return $this->redirectRoute('auth.login', [], [ 'logout_message' => true ]); + return $this->redirectRoute('auth.login', [], ['logout_message' => true]); } } diff --git a/app/Controllers/BaseController.php b/app/Controllers/BaseController.php index 39da53a..cf6a44e 100644 --- a/app/Controllers/BaseController.php +++ b/app/Controllers/BaseController.php @@ -3,8 +3,8 @@ namespace Controllers; use Illuminate\Routing\Controller; -use Illuminate\Support\Facades\View; use Illuminate\Support\Facades\Redirect; +use Illuminate\Support\Facades\View; class BaseController extends Controller { @@ -22,7 +22,7 @@ class BaseController extends Controller */ public function __construct() { - $this->beforeFilter('csrf', [ 'on' => 'post' ]); + $this->beforeFilter('csrf', ['on' => 'post']); } /** @@ -32,7 +32,7 @@ public function __construct() */ protected function setupLayout() { - if (! is_null($this->layout)) { + if (!is_null($this->layout)) { $this->layout = View::make($this->layout); } } @@ -40,8 +40,9 @@ protected function setupLayout() /** * Set the specified view as content on the layout. * - * @param string $path - * @param array $data + * @param string $path + * @param array $data + * * @return void */ protected function view($path, $data = []) @@ -52,9 +53,10 @@ protected function view($path, $data = []) /** * Redirect to the specified named route. * - * @param string $route - * @param array $params - * @param array $data + * @param string $route + * @param array $params + * @param array $data + * * @return \Illuminate\Http\RedirectResponse */ protected function redirectRoute($route, $params = [], $data = []) @@ -65,7 +67,8 @@ protected function redirectRoute($route, $params = [], $data = []) /** * Redirect back with old input and the specified data. * - * @param array $data + * @param array $data + * * @return \Illuminate\Http\RedirectResponse */ protected function redirectBack($data = []) @@ -76,7 +79,8 @@ protected function redirectBack($data = []) /** * Redirect a logged in user to the previously intended url. * - * @param mixed $default + * @param mixed $default + * * @return \Illuminate\Http\RedirectResponse */ protected function redirectIntended($default = null) diff --git a/app/Controllers/BrowseController.php b/app/Controllers/BrowseController.php index b41a4ac..250e321 100644 --- a/app/Controllers/BrowseController.php +++ b/app/Controllers/BrowseController.php @@ -2,9 +2,9 @@ namespace Controllers; +use Tricks\Repositories\CategoryRepositoryInterface; use Tricks\Repositories\TagRepositoryInterface; use Tricks\Repositories\TrickRepositoryInterface; -use Tricks\Repositories\CategoryRepositoryInterface; class BrowseController extends BaseController { @@ -32,9 +32,10 @@ class BrowseController extends BaseController /** * Create a new BrowseController instance. * - * @param \Tricks\Repositories\CategoryRepositoryInterface $categories - * @param \Tricks\Repositories\TagRepositoryInterface $tags - * @param \Tricks\Repositories\TrickRepositoryInterface $tricks + * @param \Tricks\Repositories\CategoryRepositoryInterface $categories + * @param \Tricks\Repositories\TagRepositoryInterface $tags + * @param \Tricks\Repositories\TrickRepositoryInterface $tricks + * * @return void */ public function __construct( @@ -45,8 +46,8 @@ public function __construct( parent::__construct(); $this->categories = $categories; - $this->tags = $tags; - $this->tricks = $tricks; + $this->tags = $tags; + $this->tricks = $tricks; } /** @@ -64,15 +65,16 @@ public function getCategoryIndex() /** * Show the browse by category page. * - * @param string $category + * @param string $category + * * @return \Response */ public function getBrowseCategory($category) { list($category, $tricks) = $this->tricks->findByCategory($category); - $type = \Lang::get('browse.category', array('category' => $category->name)); - $pageTitle = \Lang::get('browse.browsing_category', array('category' => $category->name)); + $type = \Lang::get('browse.category', ['category' => $category->name]); + $pageTitle = \Lang::get('browse.browsing_category', ['category' => $category->name]); $this->view('browse.index', compact('tricks', 'type', 'pageTitle')); } @@ -92,15 +94,16 @@ public function getTagIndex() /** * Show the browse by tag page. * - * @param string $tag + * @param string $tag + * * @return \Response */ public function getBrowseTag($tag) { list($tag, $tricks) = $this->tricks->findByTag($tag); - $type = \Lang::get('browse.tag', array('tag' => $tag->name)); - $pageTitle = \Lang::get('browse.browsing_tag', array('tag' => $tag->name)); + $type = \Lang::get('browse.tag', ['tag' => $tag->name]); + $pageTitle = \Lang::get('browse.browsing_tag', ['tag' => $tag->name]); $this->view('browse.index', compact('tricks', 'type', 'pageTitle')); } @@ -114,7 +117,7 @@ public function getBrowseRecent() { $tricks = $this->tricks->findMostRecent(); - $type = \Lang::get('browse.recent'); + $type = \Lang::get('browse.recent'); $pageTitle = \Lang::get('browse.browsing_most_recent_tricks'); $this->view('browse.index', compact('tricks', 'type', 'pageTitle')); @@ -129,7 +132,7 @@ public function getBrowsePopular() { $tricks = $this->tricks->findMostPopular(); - $type = \Lang::get('browse.popular'); + $type = \Lang::get('browse.popular'); $pageTitle = \Lang::get('browse.browsing_most_popular_tricks'); $this->view('browse.index', compact('tricks', 'type', 'pageTitle')); @@ -144,7 +147,7 @@ public function getBrowseComments() { $tricks = $this->tricks->findMostCommented(); - $type = \Lang::get('browse.most_commented'); + $type = \Lang::get('browse.most_commented'); $pageTitle = \Lang::get('browse.browsing_most_commented_tricks'); $this->view('browse.index', compact('tricks', 'type', 'pageTitle')); diff --git a/app/Controllers/FeedsController.php b/app/Controllers/FeedsController.php index cad52b0..c958bb0 100644 --- a/app/Controllers/FeedsController.php +++ b/app/Controllers/FeedsController.php @@ -16,7 +16,8 @@ class FeedsController extends BaseController /** * Create a new FeedsController instance. * - * @param \Tricks\Services\Feeds\Builder $builder + * @param \Tricks\Services\Feeds\Builder $builder + * * @return void */ public function __construct(Builder $builder) diff --git a/app/Controllers/HomeController.php b/app/Controllers/HomeController.php index 35009bf..9de6cc2 100644 --- a/app/Controllers/HomeController.php +++ b/app/Controllers/HomeController.php @@ -16,7 +16,8 @@ class HomeController extends BaseController /** * Create a new HomeController instance. * - * @param \Tricks\Repositories\TrickRepositoryInterface $tricks + * @param \Tricks\Repositories\TrickRepositoryInterface $tricks + * * @return void */ public function __construct(TrickRepositoryInterface $tricks) diff --git a/app/Controllers/RemindersController.php b/app/Controllers/RemindersController.php index b10b1bb..9ad93ae 100644 --- a/app/Controllers/RemindersController.php +++ b/app/Controllers/RemindersController.php @@ -4,8 +4,8 @@ use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\Hash; -use Illuminate\Support\Facades\Lang; use Illuminate\Support\Facades\Input; +use Illuminate\Support\Facades\Lang; use Illuminate\Support\Facades\Password; use Illuminate\Support\Facades\Redirect; @@ -44,7 +44,8 @@ public function postRemind() /** * Display the password reset view for the given token. * - * @param string $token + * @param string $token + * * @return \Response */ public function getReset($token = null) @@ -53,7 +54,7 @@ public function getReset($token = null) App::abort(404); } - $this->view('password.reset', [ 'token' => $token ]); + $this->view('password.reset', ['token' => $token]); } /** @@ -67,7 +68,7 @@ public function postReset() 'email', 'password', 'password_confirmation', - 'token' + 'token', ]); $response = Password::reset($credentials, function ($user, $password) { diff --git a/app/Controllers/SearchController.php b/app/Controllers/SearchController.php index 10392e2..a72cc3e 100644 --- a/app/Controllers/SearchController.php +++ b/app/Controllers/SearchController.php @@ -17,7 +17,8 @@ class SearchController extends BaseController /** * Create a new SearchController instance. * - * @param \Tricks\Repositories\TrickRepositoryInterface $tricks + * @param \Tricks\Repositories\TrickRepositoryInterface $tricks + * * @return void */ public function __construct(TrickRepositoryInterface $tricks) @@ -34,10 +35,10 @@ public function __construct(TrickRepositoryInterface $tricks) */ public function getIndex() { - $term = e(Input::get('q')); + $term = e(Input::get('q')); $tricks = null; - if (! empty($term)) { + if (!empty($term)) { $tricks = $this->tricks->searchByTermPaginated($term, 12); } diff --git a/app/Controllers/SitemapController.php b/app/Controllers/SitemapController.php index 049c82b..7cd185a 100644 --- a/app/Controllers/SitemapController.php +++ b/app/Controllers/SitemapController.php @@ -16,7 +16,8 @@ class SitemapController extends BaseController /** * Create a new SitemapController instance. * - * @param \Tricks\Services\Sitemap\Builder $builder + * @param \Tricks\Services\Sitemap\Builder $builder + * * @return void */ public function __construct(Builder $builder) diff --git a/app/Controllers/TricksController.php b/app/Controllers/TricksController.php index 150d060..f2dbb73 100644 --- a/app/Controllers/TricksController.php +++ b/app/Controllers/TricksController.php @@ -4,7 +4,6 @@ use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Event; -use Illuminate\Support\Facades\Session; use Illuminate\Support\Facades\Request; use Illuminate\Support\Facades\Response; use Tricks\Repositories\TrickRepositoryInterface; @@ -21,7 +20,8 @@ class TricksController extends BaseController /** * Create a new TricksController instance. * - * @param \Tricks\Repositories\TrickRepositoryInterface $tricks + * @param \Tricks\Repositories\TrickRepositoryInterface $tricks + * * @return void */ public function __construct(TrickRepositoryInterface $tricks) @@ -34,7 +34,8 @@ public function __construct(TrickRepositoryInterface $tricks) /** * Show the single trick page. * - * @param string $slug + * @param string $slug + * * @return \Response */ public function getShow($slug = null) @@ -60,12 +61,13 @@ public function getShow($slug = null) /** * Handle the liking of a trick. * - * @param string $slug + * @param string $slug + * * @return \Response */ public function postLike($slug) { - if (! Request::ajax() || ! Auth::check()) { + if (!Request::ajax() || !Auth::check()) { $this->redirectRoute('browse.recent'); } @@ -79,14 +81,12 @@ public function postLike($slug) $voted = $trick->votes()->whereUserId($user->id)->first(); - if(!$voted) { - + if (!$voted) { $user = $trick->votes()->attach($user->id, [ - 'created_at' => new \DateTime, - 'updated_at' => new \DateTime + 'created_at' => new \DateTime(), + 'updated_at' => new \DateTime(), ]); $trick->vote_cache = $trick->vote_cache + 1; - } else { $trick->votes()->detach($voted->id); $trick->vote_cache = $trick->vote_cache - 1; diff --git a/app/Controllers/UserController.php b/app/Controllers/UserController.php index 4783c82..6bde714 100644 --- a/app/Controllers/UserController.php +++ b/app/Controllers/UserController.php @@ -2,11 +2,11 @@ namespace Controllers; -use ImageUpload; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Input; use Illuminate\Support\Facades\Request; use Illuminate\Support\Facades\Response; +use ImageUpload; use Tricks\Repositories\TrickRepositoryInterface; use Tricks\Repositories\UserRepositoryInterface; @@ -36,18 +36,18 @@ class UserController extends BaseController /** * Create a new UserController instance. * - * @param \Tricks\Repositories\TrickRepositoryInterface $tricks + * @param \Tricks\Repositories\TrickRepositoryInterface $tricks * @param \Tricks\Repositories\UserRepositoryInterface $users */ public function __construct(TrickRepositoryInterface $tricks, UserRepositoryInterface $users) { parent::__construct(); - $this->beforeFilter('auth', [ 'except' => 'getPublic' ]); + $this->beforeFilter('auth', ['except' => 'getPublic']); - $this->user = Auth::user(); + $this->user = Auth::user(); $this->tricks = $tricks; - $this->users = $users; + $this->users = $users; } /** @@ -93,13 +93,13 @@ public function postSettings() { $form = $this->users->getSettingsForm(); - if (! $form->isValid()) { - return $this->redirectBack([ 'errors' => $form->getErrors() ]); + if (!$form->isValid()) { + return $this->redirectBack(['errors' => $form->getErrors()]); } $this->users->updateSettings($this->user, Input::all()); - return $this->redirectRoute('user.settings', [], [ 'settings_updated' => true ]); + return $this->redirectRoute('user.settings', [], ['settings_updated' => true]); } /** @@ -129,12 +129,13 @@ public function postAvatar() /** * Show the user's public profile page. * - * @param string $username + * @param string $username + * * @return \Response */ public function getPublic($username) { - $user = $this->users->requireByUsername($username); + $user = $this->users->requireByUsername($username); $tricks = $this->tricks->findAllForUser($user); $this->view('user.public', compact('user', 'tricks')); diff --git a/app/Controllers/UserTricksController.php b/app/Controllers/UserTricksController.php index 2ab9c09..8530baf 100644 --- a/app/Controllers/UserTricksController.php +++ b/app/Controllers/UserTricksController.php @@ -3,9 +3,9 @@ namespace Controllers; use Illuminate\Support\Facades\Auth; +use Tricks\Repositories\CategoryRepositoryInterface; use Tricks\Repositories\TagRepositoryInterface; use Tricks\Repositories\TrickRepositoryInterface; -use Tricks\Repositories\CategoryRepositoryInterface; class UserTricksController extends BaseController { @@ -33,9 +33,10 @@ class UserTricksController extends BaseController /** * Create a new TrickController instance. * - * @param \Tricks\Repositories\TrickRepositoryInterface $trick - * @param \Tricks\Repositories\TagRepositoryInterface $tags - * @param \Tricks\Repositories\CategoryRepositoryInterface $categories + * @param \Tricks\Repositories\TrickRepositoryInterface $trick + * @param \Tricks\Repositories\TagRepositoryInterface $tags + * @param \Tricks\Repositories\CategoryRepositoryInterface $categories + * * @return void */ public function __construct( @@ -47,11 +48,11 @@ public function __construct( $this->beforeFilter('auth'); $this->beforeFilter('trick.owner', [ - 'only' => [ 'getEdit', 'postEdit', 'getDelete' ] + 'only' => ['getEdit', 'postEdit', 'getDelete'], ]); - $this->trick = $trick; - $this->tags = $tags; + $this->trick = $trick; + $this->tags = $tags; $this->categories = $categories; } @@ -62,7 +63,7 @@ public function __construct( */ public function getNew() { - $tagList = $this->tags->listAll(); + $tagList = $this->tags->listAll(); $categoryList = $this->categories->listAll(); $this->view('tricks.new', compact('tagList', 'categoryList')); @@ -77,8 +78,8 @@ public function postNew() { $form = $this->trick->getCreationForm(); - if (! $form->isValid()) { - return $this->redirectBack([ 'errors' => $form->getErrors() ]); + if (!$form->isValid()) { + return $this->redirectBack(['errors' => $form->getErrors()]); } $data = $form->getInputData(); @@ -92,16 +93,17 @@ public function postNew() /** * Show the edit trick page. * - * @param string $slug + * @param string $slug + * * @return \Response */ public function getEdit($slug) { - $trick = $this->trick->findBySlug($slug); - $tagList = $this->tags->listAll(); + $trick = $this->trick->findBySlug($slug); + $tagList = $this->tags->listAll(); $categoryList = $this->categories->listAll(); - $selectedTags = $this->trick->listTagsIdsForTrick($trick); + $selectedTags = $this->trick->listTagsIdsForTrick($trick); $selectedCategories = $this->trick->listCategoriesIdsForTrick($trick); $this->view('tricks.edit', [ @@ -109,37 +111,39 @@ public function getEdit($slug) 'selectedTags' => $selectedTags, 'categoryList' => $categoryList, 'selectedCategories' => $selectedCategories, - 'trick' => $trick + 'trick' => $trick, ]); } /** * Handle the editing of a trick. * - * @param string $slug + * @param string $slug + * * @return \Illuminate\Http\RedirectResponse */ public function postEdit($slug) { $trick = $this->trick->findBySlug($slug); - $form = $this->trick->getEditForm($trick->id); + $form = $this->trick->getEditForm($trick->id); - if (! $form->isValid()) { - return $this->redirectBack([ 'errors' => $form->getErrors() ]); + if (!$form->isValid()) { + return $this->redirectBack(['errors' => $form->getErrors()]); } - $data = $form->getInputData(); + $data = $form->getInputData(); $trick = $this->trick->edit($trick, $data); - return $this->redirectRoute('tricks.edit', [ $trick->slug ], [ - 'success' => \Lang::get('user_tricks.trick_updated') + return $this->redirectRoute('tricks.edit', [$trick->slug], [ + 'success' => \Lang::get('user_tricks.trick_updated'), ]); } /** * Delete a trick from the database. * - * @param string $slug + * @param string $slug + * * @return \Illuminate\Http\RedirectResponse */ public function getDelete($slug) @@ -151,7 +155,7 @@ public function getDelete($slug) $trick->delete(); return $this->redirectRoute('user.index', null, [ - 'success' => \Lang::get('user_tricks.trick_deleted') + 'success' => \Lang::get('user_tricks.trick_deleted'), ]); } } diff --git a/app/Tricks/Category.php b/app/Tricks/Category.php index eca8a83..d6a6f02 100644 --- a/app/Tricks/Category.php +++ b/app/Tricks/Category.php @@ -18,8 +18,8 @@ class Category extends Model * * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ - public function tricks() - { - return $this->belongsToMany('Tricks\Trick'); - } + public function tricks() + { + return $this->belongsToMany('Tricks\Trick'); + } } diff --git a/app/Tricks/Events/ViewTrickHandler.php b/app/Tricks/Events/ViewTrickHandler.php index 69974be..a36e95e 100644 --- a/app/Tricks/Events/ViewTrickHandler.php +++ b/app/Tricks/Events/ViewTrickHandler.php @@ -24,25 +24,27 @@ class ViewTrickHandler /** * Create a new view trick handler instance. * - * @param \Tricks\Repositories\TrickRepositoryInterface $tricks - * @param \Illuminate\Session\Store $session + * @param \Tricks\Repositories\TrickRepositoryInterface $tricks + * @param \Illuminate\Session\Store $session + * * @return void */ public function __construct(TrickRepositoryInterface $tricks, Store $session) { - $this->tricks = $tricks; + $this->tricks = $tricks; $this->session = $session; } /** * Handle the view trick event. * - * @param \Tricks\Trick $trick + * @param \Tricks\Trick $trick + * * @return void */ public function handle($trick) { - if (! $this->hasViewedTrick($trick)) { + if (!$this->hasViewedTrick($trick)) { $trick = $this->tricks->incrementViews($trick); $this->storeViewedTrick($trick); @@ -52,7 +54,8 @@ public function handle($trick) /** * Determine whether the user has viewed the trick. * - * @param \Tricks\Trick $trick + * @param \Tricks\Trick $trick + * * @return bool */ protected function hasViewedTrick($trick) @@ -73,12 +76,13 @@ protected function getViewedTricks() /** * Append the newly viewed trick to the session. * - * @param \Tricks\Trick $trick + * @param \Tricks\Trick $trick + * * @return void */ protected function storeViewedTrick($trick) { - $key = 'viewed_tricks.' . $trick->id; + $key = 'viewed_tricks.'.$trick->id; $this->session->put($key, time()); } diff --git a/app/Tricks/Exceptions/AbstractNotFoundException.php b/app/Tricks/Exceptions/AbstractNotFoundException.php index 0d666c0..63ada96 100644 --- a/app/Tricks/Exceptions/AbstractNotFoundException.php +++ b/app/Tricks/Exceptions/AbstractNotFoundException.php @@ -6,5 +6,4 @@ abstract class AbstractNotFoundException extends Exception { - } diff --git a/app/Tricks/Exceptions/CategoryNotFoundException.php b/app/Tricks/Exceptions/CategoryNotFoundException.php index 147c0e2..f8861ec 100644 --- a/app/Tricks/Exceptions/CategoryNotFoundException.php +++ b/app/Tricks/Exceptions/CategoryNotFoundException.php @@ -4,5 +4,4 @@ class CategoryNotFoundException extends AbstractNotFoundException { - } diff --git a/app/Tricks/Exceptions/GithubEmailAccessException.php b/app/Tricks/Exceptions/GithubEmailAccessException.php index 209492d..534d2a0 100644 --- a/app/Tricks/Exceptions/GithubEmailAccessException.php +++ b/app/Tricks/Exceptions/GithubEmailAccessException.php @@ -6,5 +6,4 @@ class GithubEmailAccessException extends RuntimeException { - } diff --git a/app/Tricks/Exceptions/GithubEmailNotVerifiedException.php b/app/Tricks/Exceptions/GithubEmailNotVerifiedException.php index eb01c76..f46d0c7 100644 --- a/app/Tricks/Exceptions/GithubEmailNotVerifiedException.php +++ b/app/Tricks/Exceptions/GithubEmailNotVerifiedException.php @@ -6,5 +6,4 @@ class GithubEmailNotVerifiedException extends RuntimeException { - } diff --git a/app/Tricks/Exceptions/TagNotFoundException.php b/app/Tricks/Exceptions/TagNotFoundException.php index 2a5f509..1ee352e 100644 --- a/app/Tricks/Exceptions/TagNotFoundException.php +++ b/app/Tricks/Exceptions/TagNotFoundException.php @@ -4,5 +4,4 @@ class TagNotFoundException extends AbstractNotFoundException { - } diff --git a/app/Tricks/Exceptions/UserNotFoundException.php b/app/Tricks/Exceptions/UserNotFoundException.php index 9879aaf..54c9a4e 100644 --- a/app/Tricks/Exceptions/UserNotFoundException.php +++ b/app/Tricks/Exceptions/UserNotFoundException.php @@ -4,5 +4,4 @@ class UserNotFoundException extends AbstractNotFoundException { - } diff --git a/app/Tricks/Filters/TrickOwnerFilter.php b/app/Tricks/Filters/TrickOwnerFilter.php index 2794907..dc15404 100644 --- a/app/Tricks/Filters/TrickOwnerFilter.php +++ b/app/Tricks/Filters/TrickOwnerFilter.php @@ -32,9 +32,10 @@ class TrickOwnerFilter /** * Create a new trick owner filter instance. * - * @param \Illuminate\Auth\AuthManager $auth - * @param \Illuminate\Routing\Redirector $redirect - * @param \Tricks\Repositories\TrickRepositoryInterface $tricks + * @param \Illuminate\Auth\AuthManager $auth + * @param \Illuminate\Routing\Redirector $redirect + * @param \Tricks\Repositories\TrickRepositoryInterface $tricks + * * @return void */ public function __construct( @@ -50,7 +51,8 @@ public function __construct( /** * Execute the route filter. * - * @param \Illuminate\Routing\Route $route + * @param \Illuminate\Routing\Route $route + * * @return void|\Illuminate\Http\RedirectResponse */ public function filter($route) @@ -58,7 +60,7 @@ public function filter($route) $slug = $this->getSlug($route); $userId = $this->getUserId(); - if ( ! $this->isTrickOwnedByUser($slug, $userId)) { + if (!$this->isTrickOwnedByUser($slug, $userId)) { return $this->redirect->route('browse.recent'); } } @@ -75,7 +77,9 @@ protected function getUserId() /** * Get the slug of the trick being edited / deleted. - * @param \Illuminate\Routing\Route $route + * + * @param \Illuminate\Routing\Route $route + * * @return string */ protected function getSlug($route) @@ -86,8 +90,9 @@ protected function getSlug($route) /** * Determine whether the user owns the trick. * - * @param string $slug - * @param int $userId + * @param string $slug + * @param int $userId + * * @return bool */ protected function isTrickOwnedByUser($slug, $userId) diff --git a/app/Tricks/Filters/ViewThrottleFilter.php b/app/Tricks/Filters/ViewThrottleFilter.php index 87d966d..2ce466f 100644 --- a/app/Tricks/Filters/ViewThrottleFilter.php +++ b/app/Tricks/Filters/ViewThrottleFilter.php @@ -2,8 +2,8 @@ namespace Tricks\Filters; -use Illuminate\Session\Store; use Illuminate\Config\Repository; +use Illuminate\Session\Store; class ViewThrottleFilter { @@ -24,13 +24,14 @@ class ViewThrottleFilter /** * Create a new view throttle filter instance. * - * @param \Illuminate\Config\Repository $config - * @param \Illuminate\Session\Store $session + * @param \Illuminate\Config\Repository $config + * @param \Illuminate\Session\Store $session + * * @return void */ public function __construct(Repository $config, Store $session) { - $this->config = $config; + $this->config = $config; $this->session = $session; } @@ -73,12 +74,13 @@ protected function getThrottleTime() /** * Filter the tricks array, removing expired tricks. * - * @param array $tricks + * @param array $tricks + * * @return array */ protected function purgeExpiredTricks(array $tricks) { - $time = time(); + $time = time(); $throttleTime = $this->getThrottleTime(); return array_filter($tricks, function ($timestamp) use ($time, $throttleTime) { @@ -89,7 +91,8 @@ protected function purgeExpiredTricks(array $tricks) /** * Store the recently viewed tricks in the session. * - * @param array $tricks + * @param array $tricks + * * @return void */ protected function storeViewedTricks(array $tricks) diff --git a/app/Tricks/Presenters/TrickPresenter.php b/app/Tricks/Presenters/TrickPresenter.php index cfadb80..0f21c71 100644 --- a/app/Tricks/Presenters/TrickPresenter.php +++ b/app/Tricks/Presenters/TrickPresenter.php @@ -2,12 +2,12 @@ namespace Tricks\Presenters; -use Tricks\User; -use Tricks\Trick; -use Tricks\Category; -use Illuminate\Support\Facades\URL; use Illuminate\Support\Facades\HTML; +use Illuminate\Support\Facades\URL; use McCool\LaravelAutoPresenter\BasePresenter; +use Tricks\Category; +use Tricks\Trick; +use Tricks\User; class TrickPresenter extends BasePresenter { @@ -21,7 +21,8 @@ class TrickPresenter extends BasePresenter /** * Create a new TrickPresenter instance. * - * @param \Tricks\Trick $trick + * @param \Tricks\Trick $trick + * * @return void */ public function __construct(Trick $trick) @@ -36,7 +37,7 @@ public function __construct(Trick $trick) */ public function editLink() { - return URL::route('tricks.edit', [ $this->resource->slug ]); + return URL::route('tricks.edit', [$this->resource->slug]); } /** @@ -46,7 +47,7 @@ public function editLink() */ public function deleteLink() { - return URL::route('tricks.delete', [ $this->resource->slug ]); + return URL::route('tricks.delete', [$this->resource->slug]); } /** @@ -62,7 +63,8 @@ public function timeago() /** * Returns whether the given user has liked this trick. * - * @param \Tricks\User $user + * @param \Tricks\User $user + * * @return bool */ public function likedByUser($user) @@ -107,7 +109,7 @@ public function categories() $categories[] = $this->getCategoryLink($category); } - $result = 'in ' . implode(', ', $categories); + $result = 'in '.implode(', ', $categories); } return $result; @@ -126,12 +128,13 @@ protected function hasCategories() /** * Get a HTML link to the given category. * - * @param \Tricks\Category $category + * @param \Tricks\Category $category + * * @return string */ protected function getCategoryLink(Category $category) { - return HTML::linkRoute('tricks.browse.category', $category->name, [ $category->slug ]); + return HTML::linkRoute('tricks.browse.category', $category->name, [$category->slug]); } /** @@ -142,7 +145,7 @@ protected function getCategoryLink(Category $category) public function pageDescription() { $description = $this->resource->description; - $maxLength = 160; + $maxLength = 160; $description = str_replace('"', '', $description); if (strlen($description) > $maxLength) { @@ -163,7 +166,7 @@ public function pageDescription() */ public function pageTitle() { - $title = $this->resource->title; + $title = $this->resource->title; $baseTitle = ' | Laravel-Tricks.com'; $maxLength = 70; @@ -179,7 +182,8 @@ public function pageTitle() /** * Remove the last word from a given string. * - * @param string $string + * @param string $string + * * @return string */ protected function removeLastWord($string) @@ -200,9 +204,9 @@ public function tagUri() { $url = parse_url(route('tricks.show', $this->resource->slug)); - $output = 'tag:'; - $output .= $url['host'] . ','; - $output .= $this->resource->created_at->format('Y-m-d') . ':'; + $output = 'tag:'; + $output .= $url['host'].','; + $output .= $this->resource->created_at->format('Y-m-d').':'; $output .= $url['path']; return $output; diff --git a/app/Tricks/Presenters/UserPresenter.php b/app/Tricks/Presenters/UserPresenter.php index fd1d2ac..215b16e 100644 --- a/app/Tricks/Presenters/UserPresenter.php +++ b/app/Tricks/Presenters/UserPresenter.php @@ -2,15 +2,16 @@ namespace Tricks\Presenters; -use Tricks\User; use McCool\LaravelAutoPresenter\BasePresenter; +use Tricks\User; class UserPresenter extends BasePresenter { /** * Create a new UserPresenter instance. * - * @param \Tricks\User $user + * @param \Tricks\User $user + * * @return void */ public function __construct(User $user) @@ -21,7 +22,8 @@ public function __construct(User $user) /** * Get the timestamp of the last posted trick of this user. * - * @param \Illuminate\Pagination\Paginator $tricks + * @param \Illuminate\Pagination\Paginator $tricks + * * @return string */ public function lastActivity($tricks) @@ -31,7 +33,7 @@ public function lastActivity($tricks) } $collection = $tricks->getCollection(); - $sorted = $collection->sortBy(function ($trick) { + $sorted = $collection->sortBy(function ($trick) { return $trick->created_at; })->reverse(); @@ -49,7 +51,7 @@ public function fullName() { $profile = $this->resource->profile; - if (! is_null($profile) && ! empty($profile->name)) { + if (!is_null($profile) && !empty($profile->name)) { return $profile->name; } diff --git a/app/Tricks/Profile.php b/app/Tricks/Profile.php index 1011f02..624bf61 100644 --- a/app/Tricks/Profile.php +++ b/app/Tricks/Profile.php @@ -18,9 +18,8 @@ class Profile extends Model * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ - public function user() + public function user() { return $this->belongsTo('Tricks\User'); } } - diff --git a/app/Tricks/Providers/EventServiceProvider.php b/app/Tricks/Providers/EventServiceProvider.php index 55e3c73..68a0658 100644 --- a/app/Tricks/Providers/EventServiceProvider.php +++ b/app/Tricks/Providers/EventServiceProvider.php @@ -13,6 +13,5 @@ public function boot() public function register() { - } } diff --git a/app/Tricks/Providers/SitemapServiceProvider.php b/app/Tricks/Providers/SitemapServiceProvider.php index 3692b2e..b012b3e 100644 --- a/app/Tricks/Providers/SitemapServiceProvider.php +++ b/app/Tricks/Providers/SitemapServiceProvider.php @@ -3,8 +3,6 @@ namespace Tricks\Providers; use Illuminate\Support\ServiceProvider; -use Tricks\Services\Sitemap\Builder; -use Tricks\Services\Sitemap\DataProvider; class SitemapServiceProvider extends ServiceProvider { diff --git a/app/Tricks/Providers/SocialServiceProvider.php b/app/Tricks/Providers/SocialServiceProvider.php index 48130ce..0f9a47f 100644 --- a/app/Tricks/Providers/SocialServiceProvider.php +++ b/app/Tricks/Providers/SocialServiceProvider.php @@ -2,11 +2,11 @@ namespace Tricks\Providers; -use Tricks\Services\Social\Disqus; -use Tricks\Services\Social\Github; -use Illuminate\Support\ServiceProvider; use Guzzle\Service\Client as GuzzleClient; +use Illuminate\Support\ServiceProvider; use League\OAuth2\Client\Provider\Github as GithubProvider; +use Tricks\Services\Social\Disqus; +use Tricks\Services\Social\Github; class SocialServiceProvider extends ServiceProvider { @@ -34,8 +34,8 @@ protected function registerGithub() $this->app['github'] = $this->app->share(function ($app) { $provider = $app['github.provider']; - $config = $app['config']; - $users = $app['Tricks\Repositories\UserRepositoryInterface']; + $config = $app['config']; + $users = $app['Tricks\Repositories\UserRepositoryInterface']; $profiles = $app['Tricks\Repositories\ProfileRepositoryInterface']; return new Github($provider, $config, $users, $profiles); diff --git a/app/Tricks/Repositories/CategoryRepositoryInterface.php b/app/Tricks/Repositories/CategoryRepositoryInterface.php index ea3e6d8..f992b08 100644 --- a/app/Tricks/Repositories/CategoryRepositoryInterface.php +++ b/app/Tricks/Repositories/CategoryRepositoryInterface.php @@ -14,8 +14,9 @@ public function listAll(); /** * Find all categories. * - * @param string $orderColumn - * @param string $orderDir + * @param string $orderColumn + * @param string $orderDir + * * @return \Illuminate\Database\Eloquent\Collection|\Tricks\Category[] */ public function findAll($orderColumn = 'created_at', $orderDir = 'desc'); @@ -30,7 +31,8 @@ public function findAllWithTrickCount(); /** * Find a category by id. * - * @param mixed $id + * @param mixed $id + * * @return \Tricks\Category */ public function findById($id); @@ -38,7 +40,8 @@ public function findById($id); /** * Create a new category in the database. * - * @param array $data + * @param array $data + * * @return \Tricks\Category */ public function create(array $data); @@ -46,8 +49,9 @@ public function create(array $data); /** * Update the specified category in the database. * - * @param mixed $id - * @param array $data + * @param mixed $id + * @param array $data + * * @return \Tricks\Category */ public function update($id, array $data); @@ -62,7 +66,8 @@ public function getMaxOrder(); /** * Delete the specified category from the database. * - * @param mixed $id + * @param mixed $id + * * @return void */ public function delete($id); @@ -70,7 +75,8 @@ public function delete($id); /** * Re-arrange the categories in the database. * - * @param array $data + * @param array $data + * * @return void */ public function arrange(array $data); diff --git a/app/Tricks/Repositories/Eloquent/AbstractRepository.php b/app/Tricks/Repositories/Eloquent/AbstractRepository.php index 0272cac..7375a97 100644 --- a/app/Tricks/Repositories/Eloquent/AbstractRepository.php +++ b/app/Tricks/Repositories/Eloquent/AbstractRepository.php @@ -26,10 +26,11 @@ public function __construct(Model $model) /** * Get a new instance of the model. * - * @param array $attributes + * @param array $attributes + * * @return \Illuminate\Database\Eloquent\Model */ - public function getNew(array $attributes = array()) + public function getNew(array $attributes = []) { return $this->model->newInstance($attributes); } diff --git a/app/Tricks/Repositories/Eloquent/CategoryRepository.php b/app/Tricks/Repositories/Eloquent/CategoryRepository.php index d961f43..9c69645 100644 --- a/app/Tricks/Repositories/Eloquent/CategoryRepository.php +++ b/app/Tricks/Repositories/Eloquent/CategoryRepository.php @@ -2,19 +2,19 @@ namespace Tricks\Repositories\Eloquent; -use Tricks\Category; -use Illuminate\Support\Str; use Illuminate\Support\Facades\DB; -use Tricks\Services\Forms\CategoryForm; -use Tricks\Exceptions\CategoryNotFoundException; +use Illuminate\Support\Str; +use Tricks\Category; use Tricks\Repositories\CategoryRepositoryInterface; +use Tricks\Services\Forms\CategoryForm; class CategoryRepository extends AbstractRepository implements CategoryRepositoryInterface { /** * Create a new DbCategoryRepository instance. * - * @param \Tricks\Category $category + * @param \Tricks\Category $category + * * @return void */ public function __construct(Category $category) @@ -37,8 +37,9 @@ public function listAll() /** * Find all categories. * - * @param string $orderColumn - * @param string $orderDir + * @param string $orderColumn + * @param string $orderDir + * * @return \Illuminate\Database\Eloquent\Collection|\Category[] */ public function findAll($orderColumn = 'created_at', $orderDir = 'desc') @@ -64,14 +65,15 @@ public function findAllWithTrickCount() ->get([ 'categories.name', 'categories.slug', - DB::raw('COUNT(tricks.id) as trick_count') + DB::raw('COUNT(tricks.id) as trick_count'), ]); } /** * Find a category by id. * - * @param mixed $id + * @param mixed $id + * * @return \Tricks\Category */ public function findById($id) @@ -82,17 +84,18 @@ public function findById($id) /** * Create a new category in the database. * - * @param array $data + * @param array $data + * * @return \Tricks\Category */ public function create(array $data) { $category = $this->getNew(); - $category->name = e($data['name']); - $category->slug = Str::slug($category->name, '-'); + $category->name = e($data['name']); + $category->slug = Str::slug($category->name, '-'); $category->description = $data['description']; - $category->order = $this->getMaxOrder() + 1; + $category->order = $this->getMaxOrder() + 1; $category->save(); @@ -102,17 +105,18 @@ public function create(array $data) /** * Update the specified category in the database. * - * @param mixed $id - * @param array $data + * @param mixed $id + * @param array $data + * * @return \Tricks\Category */ public function update($id, array $data) { $category = $this->findById($id); - $category->name = e($data['name']); - $category->slug = Str::slug($category->name, '-'); - $category->description = $data['description']; + $category->name = e($data['name']); + $category->slug = Str::slug($category->name, '-'); + $category->description = $data['description']; $category->save(); @@ -132,7 +136,8 @@ public function getMaxOrder() /** * Delete the specified category from the database. * - * @param mixed $id + * @param mixed $id + * * @return void */ public function delete($id) @@ -145,13 +150,14 @@ public function delete($id) /** * Re-arrange the categories in the database. * - * @param array $data + * @param array $data + * * @return void */ public function arrange(array $data) { $ids = array_values($data); - $categories = $this->model->whereIn('id', $ids)->get([ 'id' ]); + $categories = $this->model->whereIn('id', $ids)->get(['id']); foreach ($data as $order => $id) { if ($category = $categories->find($id)) { @@ -168,6 +174,6 @@ public function arrange(array $data) */ public function getForm() { - return new CategoryForm; + return new CategoryForm(); } } diff --git a/app/Tricks/Repositories/Eloquent/ProfileRepository.php b/app/Tricks/Repositories/Eloquent/ProfileRepository.php index 45eb3e6..4157761 100644 --- a/app/Tricks/Repositories/Eloquent/ProfileRepository.php +++ b/app/Tricks/Repositories/Eloquent/ProfileRepository.php @@ -2,17 +2,18 @@ namespace Tricks\Repositories\Eloquent; -use Tricks\User; +use League\OAuth2\Client\Provider\User as OAuthUser; use Tricks\Profile; use Tricks\Repositories\ProfileRepositoryInterface; -use League\OAuth2\Client\Provider\User as OAuthUser; +use Tricks\User; class ProfileRepository extends AbstractRepository implements ProfileRepositoryInterface { /** * Create a new DbProfileRepository instance. * - * @param \Tricks\Profile $profile + * @param \Tricks\Profile $profile + * * @return void */ public function __construct(Profile $profile) @@ -23,7 +24,8 @@ public function __construct(Profile $profile) /** * Find a profile by it's UID. * - * @param string $uid + * @param string $uid + * * @return \Tricks\Profile */ public function findByUid($uid) @@ -34,26 +36,27 @@ public function findByUid($uid) /** * Create a new profile from Github data. * - * @param \League\OAuth2\Client\Provider\User $userDetails - * @param \Tricks\User $user - * @param string $token + * @param \League\OAuth2\Client\Provider\User $userDetails + * @param \Tricks\User $user + * @param string $token + * * @return \Tricks\Profile */ public function createFromGithubData(OAuthUser $details, User $user, $token) { $profile = $this->getNew(); - $profile->uid = $details->uid; - $profile->username = $details->nickname; - $profile->name = $details->name; - $profile->email = $details->email; - $profile->first_name = $details->first_name; - $profile->last_name = $details->last_name; - $profile->location = $details->location; - $profile->description = $details->description; - $profile->image_url = $details->imageUrl; + $profile->uid = $details->uid; + $profile->username = $details->nickname; + $profile->name = $details->name; + $profile->email = $details->email; + $profile->first_name = $details->first_name; + $profile->last_name = $details->last_name; + $profile->location = $details->location; + $profile->description = $details->description; + $profile->image_url = $details->imageUrl; $profile->access_token = $token; - $profile->user_id = $user->id; + $profile->user_id = $user->id; $profile->save(); @@ -63,8 +66,9 @@ public function createFromGithubData(OAuthUser $details, User $user, $token) /** * Update the access token on the profile. * - * @param \Tricks\Profile $profile - * @param string $token + * @param \Tricks\Profile $profile + * @param string $token + * * @return \Tricks\Profile */ public function updateToken(Profile $profile, $token) diff --git a/app/Tricks/Repositories/Eloquent/TagRepository.php b/app/Tricks/Repositories/Eloquent/TagRepository.php index 6db8beb..6e17610 100644 --- a/app/Tricks/Repositories/Eloquent/TagRepository.php +++ b/app/Tricks/Repositories/Eloquent/TagRepository.php @@ -2,19 +2,19 @@ namespace Tricks\Repositories\Eloquent; -use Tricks\Tag; -use Illuminate\Support\Str; use Illuminate\Support\Facades\DB; -use Tricks\Services\Forms\TagForm; -use Tricks\Exceptions\TagNotFoundException; +use Illuminate\Support\Str; use Tricks\Repositories\TagRepositoryInterface; +use Tricks\Services\Forms\TagForm; +use Tricks\Tag; class TagRepository extends AbstractRepository implements TagRepositoryInterface { /** * Create a new DbTagRepository instance. * - * @param \Tricks\Tag $tags + * @param \Tricks\Tag $tags + * * @return void */ public function __construct(Tag $tag) @@ -37,8 +37,9 @@ public function listAll() /** * Find all tags. * - * @param string $orderColumn - * @param string $orderDir + * @param string $orderColumn + * @param string $orderDir + * * @return \Illuminate\Database\Eloquent\Collection|\Tricks\Tag[] */ public function findAll($orderColumn = 'created_at', $orderDir = 'desc') @@ -53,7 +54,8 @@ public function findAll($orderColumn = 'created_at', $orderDir = 'desc') /** * Find a tag by id. * - * @param mixed $id + * @param mixed $id + * * @return \Tricks\Tag */ public function findById($id) @@ -76,14 +78,15 @@ public function findAllWithTrickCount() ->get([ 'tags.name', 'tags.slug', - DB::raw('COUNT(tricks.id) as trick_count') + DB::raw('COUNT(tricks.id) as trick_count'), ]); } /** * Create a new tag in the database. * - * @param array $data + * @param array $data + * * @return \Tricks\Tag */ public function create(array $data) @@ -101,8 +104,9 @@ public function create(array $data) /** * Update the specified tag in the database. * - * @param mixed $id - * @param array $data + * @param mixed $id + * @param array $data + * * @return \Tricks\Category */ public function update($id, array $data) @@ -120,7 +124,8 @@ public function update($id, array $data) /** * Delete the specified tag from the database. * - * @param mixed $id + * @param mixed $id + * * @return void */ public function delete($id) @@ -139,6 +144,6 @@ public function delete($id) */ public function getForm() { - return new TagForm; + return new TagForm(); } } diff --git a/app/Tricks/Repositories/Eloquent/TrickRepository.php b/app/Tricks/Repositories/Eloquent/TrickRepository.php index 279b3f5..1922103 100644 --- a/app/Tricks/Repositories/Eloquent/TrickRepository.php +++ b/app/Tricks/Repositories/Eloquent/TrickRepository.php @@ -3,17 +3,16 @@ namespace Tricks\Repositories\Eloquent; use Disqus; -use Tricks\Tag; -use Tricks\User; -use Tricks\Trick; -use Tricks\Category; use Illuminate\Support\Str; -use Tricks\Services\Forms\TrickForm; -use Tricks\Services\Forms\TrickEditForm; -use Tricks\Exceptions\TagNotFoundException; -use Illuminate\Database\Eloquent\Collection; +use Tricks\Category; use Tricks\Exceptions\CategoryNotFoundException; +use Tricks\Exceptions\TagNotFoundException; use Tricks\Repositories\TrickRepositoryInterface; +use Tricks\Services\Forms\TrickEditForm; +use Tricks\Services\Forms\TrickForm; +use Tricks\Tag; +use Tricks\Trick; +use Tricks\User; class TrickRepository extends AbstractRepository implements TrickRepositoryInterface { @@ -34,23 +33,25 @@ class TrickRepository extends AbstractRepository implements TrickRepositoryInter /** * Create a new DbTrickRepository instance. * - * @param \Tricks\Trick $trick - * @param \Tricks\Category $category - * @param \Tricks\Tag $tag + * @param \Tricks\Trick $trick + * @param \Tricks\Category $category + * @param \Tricks\Tag $tag + * * @return void */ public function __construct(Trick $trick, Category $category, Tag $tag) { - $this->model = $trick; + $this->model = $trick; $this->category = $category; - $this->tag = $tag; + $this->tag = $tag; } /** * Find all the tricks for the given user paginated. * - * @param \Tricks\User $user - * @param integer $perPage + * @param \Tricks\User $user + * @param int $perPage + * * @return \Illuminate\Pagination\Paginator|\Tricks\Trick[] */ public function findAllForUser(User $user, $perPage = 9) @@ -63,8 +64,9 @@ public function findAllForUser(User $user, $perPage = 9) /** * Find all tricks that are favorited by the given user paginated. * - * @param \Tricks\User $user - * @param integer $perPage + * @param \Tricks\User $user + * @param int $perPage + * * @return \Illuminate\Pagination\Paginator|\Tricks\Trick[] */ public function findAllFavorites(User $user, $perPage = 9) @@ -77,7 +79,8 @@ public function findAllFavorites(User $user, $perPage = 9) /** * Find a trick by the given slug. * - * @param string $slug + * @param string $slug + * * @return \Tricks\Trick */ public function findBySlug($slug) @@ -88,7 +91,8 @@ public function findBySlug($slug) /** * Find all the tricks paginated. * - * @param integer $perPage + * @param int $perPage + * * @return \Illuminate\Pagination\Paginator|\Tricks\Trick[] */ public function findAllPaginated($perPage = 9) @@ -101,7 +105,8 @@ public function findAllPaginated($perPage = 9) /** * Find all tricks order by the creation date paginated. * - * @param integer $per_page + * @param int $per_page + * * @return \Illuminate\Pagination\Paginator|\Tricks\Trick[] */ public function findMostRecent($per_page = 9) @@ -112,7 +117,8 @@ public function findMostRecent($per_page = 9) /** * Find the tricks ordered by the number of comments paginated. * - * @param integer $per_page + * @param int $per_page + * * @return \Illuminate\Pagination\Paginator|\Tricks\Trick[] */ public function findMostCommented($perPage = 9) @@ -136,7 +142,8 @@ public function findMostCommented($perPage = 9) /** * Find the tricks ordered by popularity (most liked / viewed) paginated. * - * @param integer $per_page + * @param int $per_page + * * @return \Illuminate\Pagination\Paginator|\Tricks\Trick[] */ public function findMostPopular($per_page = 9) @@ -169,8 +176,9 @@ public function findAllForSitemap() /** * Find all tricks for the category that matches the given slug. * - * @param string $slug - * @param integer $perPage + * @param string $slug + * @param int $perPage + * * @return array */ public function findByCategory($slug, $perPage = 9) @@ -183,26 +191,27 @@ public function findByCategory($slug, $perPage = 9) $tricks = $category->tricks()->orderBy('created_at', 'DESC')->paginate($perPage); - return [ $category, $tricks ]; + return [$category, $tricks]; } /** * Find all tricks that match the given search term. * - * @param string $term - * @param integer $perPage + * @param string $term + * @param int $perPage + * * @return \Illuminate\Pagination\Paginator|\Tricks\Trick[] */ public function searchByTermPaginated($term, $perPage = 12) { - $tricks = $this->model + $tricks = $this->model ->orWhere('title', 'LIKE', '%'.$term.'%') ->orWhere('description', 'LIKE', '%'.$term.'%') ->orWhereHas('tags', function ($query) use ($term) { - $query->where('title', 'LIKE', '%' . $term . '%'); + $query->where('title', 'LIKE', '%'.$term.'%'); }) ->orWhereHas('categories', function ($query) use ($term) { - $query->where('name', 'LIKE', '%' . $term . '%'); + $query->where('name', 'LIKE', '%'.$term.'%'); }) ->orderBy('created_at', 'desc') ->orderBy('title', 'asc') @@ -214,7 +223,8 @@ public function searchByTermPaginated($term, $perPage = 12) /** * Get a list of tag ids that are associated with the given trick. * - * @param \Tricks\Trick $trick + * @param \Tricks\Trick $trick + * * @return array */ public function listTagsIdsForTrick(Trick $trick) @@ -225,7 +235,8 @@ public function listTagsIdsForTrick(Trick $trick) /** * Get a list of category ids that are associated with the given trick. * - * @param \Tricks\Trick $trick + * @param \Tricks\Trick $trick + * * @return array */ public function listCategoriesIdsForTrick(Trick $trick) @@ -236,18 +247,19 @@ public function listCategoriesIdsForTrick(Trick $trick) /** * Create a new trick in the database. * - * @param array $data + * @param array $data + * * @return \Tricks\Trick */ public function create(array $data) { $trick = $this->getNew(); - $trick->user_id = $data['user_id']; - $trick->title = e($data['title']); - $trick->slug = Str::slug($data['title'], '-'); + $trick->user_id = $data['user_id']; + $trick->title = e($data['title']); + $trick->slug = Str::slug($data['title'], '-'); $trick->description = e($data['description']); - $trick->code = $data['code']; + $trick->code = $data['code']; $trick->save(); @@ -260,17 +272,18 @@ public function create(array $data) /** * Update the trick in the database. * - * @param \Tricks\Trick $trick - * @param array $data + * @param \Tricks\Trick $trick + * @param array $data + * * @return \Tricks\Trick */ public function edit(Trick $trick, array $data) { //$trick->user_id = $data['user_id']; - $trick->title = e($data['title']); - $trick->slug = Str::slug($data['title'], '-'); + $trick->title = e($data['title']); + $trick->slug = Str::slug($data['title'], '-'); $trick->description = e($data['description']); - $trick->code = $data['code']; + $trick->code = $data['code']; $trick->save(); @@ -283,7 +296,8 @@ public function edit(Trick $trick, array $data) /** * Increment the view count on the given trick. * - * @param \Tricks\Trick $trick + * @param \Tricks\Trick $trick + * * @return \Tricks\Trick */ public function incrementViews(Trick $trick) @@ -297,8 +311,9 @@ public function incrementViews(Trick $trick) /** * Find all tricks for the tag that matches the given slug. * - * @param string $slug - * @param integer $perPage + * @param string $slug + * @param int $perPage + * * @return \Illuminate\Pagination\Paginator|\Tricks\Trick[] */ public function findByTag($slug, $perPage = 9) @@ -306,18 +321,19 @@ public function findByTag($slug, $perPage = 9) $tag = $this->tag->whereSlug($slug)->first(); if (is_null($tag)) { - throw new TagNotFoundException('The tag "' . $slug . '" does not exist!'); + throw new TagNotFoundException('The tag "'.$slug.'" does not exist!'); } $tricks = $tag->tricks()->orderBy('created_at', 'desc')->paginate($perPage); - return [ $tag, $tricks ]; + return [$tag, $tricks]; } /** * Find the next trick that was added after the given trick. * - * @param \Tricks\Trick $trick + * @param \Tricks\Trick $trick + * * @return \Tricks\Trick|null */ public function findNextTrick(Trick $trick) @@ -325,7 +341,7 @@ public function findNextTrick(Trick $trick) $next = $this->model->where('created_at', '>=', $trick->created_at) ->where('id', '<>', $trick->id) ->orderBy('created_at', 'asc') - ->first([ 'slug', 'title' ]); + ->first(['slug', 'title']); return $next; } @@ -333,7 +349,8 @@ public function findNextTrick(Trick $trick) /** * Find the previous trick added before the given trick. * - * @param \Tricks\Trick $trick + * @param \Tricks\Trick $trick + * * @return \Tricks\Trick|null */ public function findPreviousTrick(Trick $trick) @@ -341,7 +358,7 @@ public function findPreviousTrick(Trick $trick) $prev = $this->model->where('created_at', '<=', $trick->created_at) ->where('id', '<>', $trick->id) ->orderBy('created_at', 'desc') - ->first([ 'slug', 'title' ]); + ->first(['slug', 'title']); return $prev; } @@ -349,8 +366,9 @@ public function findPreviousTrick(Trick $trick) /** * Check if the user owns the trick corresponding to the given slug. * - * @param string $slug - * @param mixed $userId + * @param string $slug + * @param mixed $userId + * * @return bool */ public function isTrickOwnedByUser($slug, $userId) @@ -365,7 +383,7 @@ public function isTrickOwnedByUser($slug, $userId) */ public function getCreationForm() { - return new TrickForm; + return new TrickForm(); } /** diff --git a/app/Tricks/Repositories/Eloquent/UserRepository.php b/app/Tricks/Repositories/Eloquent/UserRepository.php index 6326817..d26fb7d 100644 --- a/app/Tricks/Repositories/Eloquent/UserRepository.php +++ b/app/Tricks/Repositories/Eloquent/UserRepository.php @@ -2,23 +2,22 @@ namespace Tricks\Repositories\Eloquent; -use Tricks\User; +use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\File; use Illuminate\Support\Facades\Hash; -use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\Session; -use Tricks\Services\Forms\SettingsForm; -use Tricks\Services\Forms\RegistrationForm; +use League\OAuth2\Client\Provider\User as OAuthUser; use Tricks\Exceptions\UserNotFoundException; use Tricks\Repositories\UserRepositoryInterface; -use League\OAuth2\Client\Provider\User as OAuthUser; +use Tricks\User; class UserRepository extends AbstractRepository implements UserRepositoryInterface { /** * Create a new DbUserRepository instance. * - * @param \Tricks\User $user + * @param \Tricks\User $user + * * @return void */ public function __construct(User $user) @@ -29,7 +28,8 @@ public function __construct(User $user) /** * Find all users paginated. * - * @param int $perPage + * @param int $perPage + * * @return Illuminate\Database\Eloquent\Collection|\Tricks\User[] */ public function findAllPaginated($perPage = 200) @@ -42,7 +42,8 @@ public function findAllPaginated($perPage = 200) /** * Find a user by it's username. * - * @param string $username + * @param string $username + * * @return \Tricks\User */ public function findByUsername($username) @@ -53,7 +54,8 @@ public function findByUsername($username) /** * Find a user by it's email. * - * @param string $email + * @param string $email + * * @return \Tricks\User */ public function findByEmail($email) @@ -64,33 +66,36 @@ public function findByEmail($email) /** * Require a user by it's username. * - * @param string $username - * @return \Tricks\User + * @param string $username + * * @throws \Tricks\Exceptions\UserNotFoundException + * + * @return \Tricks\User */ public function requireByUsername($username) { - if (! is_null($user = $this->findByUsername($username))) { + if (!is_null($user = $this->findByUsername($username))) { return $user; } - throw new UserNotFoundException('The user "' . $username . '" does not exist!'); + throw new UserNotFoundException('The user "'.$username.'" does not exist!'); } /** * Create a new user in the database. * - * @param array $data + * @param array $data + * * @return \Tricks\User */ public function create(array $data) { $user = $this->getNew(); - $user->email = e($data['email']); + $user->email = e($data['email']); $user->username = e($data['username']); $user->password = Hash::make($data['password']); - $user->photo = isset($data['image_url']) ? $data['image_url'] : null; + $user->photo = isset($data['image_url']) ? $data['image_url'] : null; $user->save(); @@ -100,21 +105,22 @@ public function create(array $data) /** * Create a new user in the database using GitHub data. * - * @param \League\OAuth2\Client\Provider\User $data + * @param \League\OAuth2\Client\Provider\User $data + * * @return \Tricks\User */ public function createFromGithubData(OAuthUser $data) { - $user = $this->getNew(); + $user = $this->getNew(); - $username = $data->nickname; + $username = $data->nickname; $isAvailable = is_null($this->findByUsername($username)); - $isAllowed = $this->usernameIsAllowed($username); + $isAllowed = $this->usernameIsAllowed($username); $user->username = $username; - if (! $isAvailable or ! $isAllowed) { - $user->username .= '_' . str_random(3); + if (!$isAvailable or !$isAllowed) { + $user->username .= '_'.str_random(3); Session::flash('username_required', true); } @@ -131,19 +137,21 @@ public function createFromGithubData(OAuthUser $data) /** * Returns whether the given username is allowed to be used. * - * @param string $username + * @param string $username + * * @return bool */ protected function usernameIsAllowed($username) { - return ! in_array(strtolower($username), Config::get('config.forbidden_usernames')); + return !in_array(strtolower($username), Config::get('config.forbidden_usernames')); } /** * Update the user's settings. * - * @param \Tricks\User $user - * @param array $data + * @param \Tricks\User $user + * @param array $data + * * @return \Tricks\User */ public function updateSettings(User $user, array $data) diff --git a/app/Tricks/Repositories/ProfileRepositoryInterface.php b/app/Tricks/Repositories/ProfileRepositoryInterface.php index e1192dd..6a36203 100644 --- a/app/Tricks/Repositories/ProfileRepositoryInterface.php +++ b/app/Tricks/Repositories/ProfileRepositoryInterface.php @@ -2,16 +2,17 @@ namespace Tricks\Repositories; -use Tricks\User; -use Tricks\Profile; use League\OAuth2\Client\Provider\User as OAuthUser; +use Tricks\Profile; +use Tricks\User; interface ProfileRepositoryInterface { /** * Find a profile by it's UID. * - * @param string $uid + * @param string $uid + * * @return \Tricks\Profile */ public function findByUid($uid); @@ -19,9 +20,10 @@ public function findByUid($uid); /** * Create a new profile from Github data. * - * @param \League\OAuth2\Client\Provider\User $userDetails - * @param \Tricks\User $user - * @param string $token + * @param \League\OAuth2\Client\Provider\User $userDetails + * @param \Tricks\User $user + * @param string $token + * * @return \Tricks\Profile */ public function createFromGithubData(OAuthUser $details, User $user, $token); @@ -29,8 +31,9 @@ public function createFromGithubData(OAuthUser $details, User $user, $token); /** * Update the access token on the profile. * - * @param \Tricks\Profile $profile - * @param string $token + * @param \Tricks\Profile $profile + * @param string $token + * * @return \Tricks\Profile */ public function updateToken(Profile $profile, $token); diff --git a/app/Tricks/Repositories/TagRepositoryInterface.php b/app/Tricks/Repositories/TagRepositoryInterface.php index c3cede4..cc71342 100644 --- a/app/Tricks/Repositories/TagRepositoryInterface.php +++ b/app/Tricks/Repositories/TagRepositoryInterface.php @@ -14,8 +14,9 @@ public function listAll(); /** * Find all tags. * - * @param string $orderColumn - * @param string $orderDir + * @param string $orderColumn + * @param string $orderDir + * * @return \Illuminate\Database\Eloquent\Collection|\Tricks\Tag[] */ public function findAll($orderColumn = 'created_at', $orderDir = 'desc'); @@ -23,7 +24,8 @@ public function findAll($orderColumn = 'created_at', $orderDir = 'desc'); /** * Find a tag by id. * - * @param mixed $id + * @param mixed $id + * * @return \Tricks\Tag */ public function findById($id); @@ -38,7 +40,8 @@ public function findAllWithTrickCount(); /** * Create a new tag in the database. * - * @param array $data + * @param array $data + * * @return \Tricks\Tag */ public function create(array $data); @@ -46,8 +49,9 @@ public function create(array $data); /** * Update the specified tag in the database. * - * @param mixed $id - * @param array $data + * @param mixed $id + * @param array $data + * * @return \Tricks\Category */ public function update($id, array $data); @@ -55,7 +59,8 @@ public function update($id, array $data); /** * Delete the specified tag from the database. * - * @param mixed $id + * @param mixed $id + * * @return void */ public function delete($id); diff --git a/app/Tricks/Repositories/TrickRepositoryInterface.php b/app/Tricks/Repositories/TrickRepositoryInterface.php index 60eaab1..2fa9a9b 100644 --- a/app/Tricks/Repositories/TrickRepositoryInterface.php +++ b/app/Tricks/Repositories/TrickRepositoryInterface.php @@ -2,16 +2,17 @@ namespace Tricks\Repositories; -use Tricks\User; use Tricks\Trick; +use Tricks\User; interface TrickRepositoryInterface { /** * Find all the tricks for the given user paginated. * - * @param \User $user - * @param integer $perPage + * @param \User $user + * @param int $perPage + * * @return \Illuminate\Pagination\Paginator|\Tricks\Trick[] */ public function findAllForUser(User $user, $perPage = 9); @@ -19,8 +20,9 @@ public function findAllForUser(User $user, $perPage = 9); /** * Find all tricks that are favorited by the given user paginated. * - * @param \User $user - * @param integer $perPage + * @param \User $user + * @param int $perPage + * * @return \Illuminate\Pagination\Paginator|\Tricks\Trick[] */ public function findAllFavorites(User $user, $perPage = 9); @@ -28,7 +30,8 @@ public function findAllFavorites(User $user, $perPage = 9); /** * Find a trick by the given slug. * - * @param string $slug + * @param string $slug + * * @return \Tricks\Trick */ public function findBySlug($slug); @@ -36,7 +39,8 @@ public function findBySlug($slug); /** * Find all the tricks paginated. * - * @param integer $perPage + * @param int $perPage + * * @return \Illuminate\Pagination\Paginator|\Tricks\Trick[] */ public function findAllPaginated($perPage = 9); @@ -44,7 +48,8 @@ public function findAllPaginated($perPage = 9); /** * Find all tricks order by the creation date paginated. * - * @param integer $per_page + * @param int $per_page + * * @return \Illuminate\Pagination\Paginator|\Tricks\Trick[] */ public function findMostRecent($per_page = 9); @@ -52,7 +57,8 @@ public function findMostRecent($per_page = 9); /** * Find the tricks ordered by the number of comments paginated. * - * @param integer $per_page + * @param int $per_page + * * @return \Illuminate\Pagination\Paginator|\Tricks\Trick[] */ public function findMostCommented($per_page = 9); @@ -60,7 +66,8 @@ public function findMostCommented($per_page = 9); /** * Find the tricks ordered by popularity (most liked / viewed) paginated. * - * @param integer $per_page + * @param int $per_page + * * @return \Illuminate\Pagination\Paginator|\Tricks\Trick[] */ public function findMostPopular($per_page = 9); @@ -82,8 +89,9 @@ public function findAllForSitemap(); /** * Find all tricks that match the given search term. * - * @param string $term - * @param integer $perPage + * @param string $term + * @param int $perPage + * * @return \Illuminate\Pagination\Paginator|\Tricks\Trick[] */ public function searchByTermPaginated($term, $perPage); @@ -91,8 +99,9 @@ public function searchByTermPaginated($term, $perPage); /** * Find all tricks for the category that matches the given slug. * - * @param string $slug - * @param integer $perPage + * @param string $slug + * @param int $perPage + * * @return array */ public function findByCategory($slug, $perPage = 9); @@ -100,7 +109,8 @@ public function findByCategory($slug, $perPage = 9); /** * Get a list of tag ids that are associated with the given trick. * - * @param \Tricks\Trick $trick + * @param \Tricks\Trick $trick + * * @return array */ public function listTagsIdsForTrick(Trick $trick); @@ -108,7 +118,8 @@ public function listTagsIdsForTrick(Trick $trick); /** * Get a list of category ids that are associated with the given trick. * - * @param \Tricks\Trick $trick + * @param \Tricks\Trick $trick + * * @return array */ public function listCategoriesIdsForTrick(Trick $trick); @@ -116,7 +127,8 @@ public function listCategoriesIdsForTrick(Trick $trick); /** * Create a new trick in the database. * - * @param array $data + * @param array $data + * * @return \Tricks\Trick */ public function create(array $data); @@ -124,8 +136,9 @@ public function create(array $data); /** * Update the trick in the database. * - * @param \Tricks\Trick $trick - * @param array $data + * @param \Tricks\Trick $trick + * @param array $data + * * @return \Tricks\Trick */ public function edit(Trick $trick, array $data); @@ -133,7 +146,8 @@ public function edit(Trick $trick, array $data); /** * Increment the view count on the given trick. * - * @param \Tricks\Trick $trick + * @param \Tricks\Trick $trick + * * @return \Tricks\Trick */ public function incrementViews(Trick $trick); @@ -141,8 +155,9 @@ public function incrementViews(Trick $trick); /** * Find all tricks for the tag that matches the given slug. * - * @param string $slug - * @param integer $perPage + * @param string $slug + * @param int $perPage + * * @return array */ public function findByTag($slug, $perPage = 9); @@ -150,7 +165,8 @@ public function findByTag($slug, $perPage = 9); /** * Find the next trick that was added after the given trick. * - * @param \Tricks\Trick $trick + * @param \Tricks\Trick $trick + * * @return \Tricks\Trick|null */ public function findNextTrick(Trick $trick); @@ -158,7 +174,8 @@ public function findNextTrick(Trick $trick); /** * Find the previous trick added before the given trick. * - * @param \Tricks\Trick $trick + * @param \Tricks\Trick $trick + * * @return \Tricks\Trick|null */ public function findPreviousTrick(Trick $trick); @@ -166,8 +183,9 @@ public function findPreviousTrick(Trick $trick); /** * Check if the user owns the trick corresponding to the given slug. * - * @param string $slug - * @param mixed $userId + * @param string $slug + * @param mixed $userId + * * @return bool */ public function isTrickOwnedByUser($slug, $userId); diff --git a/app/Tricks/Repositories/UserRepositoryInterface.php b/app/Tricks/Repositories/UserRepositoryInterface.php index 1ed3584..0b018bd 100644 --- a/app/Tricks/Repositories/UserRepositoryInterface.php +++ b/app/Tricks/Repositories/UserRepositoryInterface.php @@ -2,15 +2,16 @@ namespace Tricks\Repositories; -use Tricks\User; use League\OAuth2\Client\Provider\User as OAuthUser; +use Tricks\User; interface UserRepositoryInterface { /** * Find all users paginated. * - * @param int $perPage + * @param int $perPage + * * @return \Illuminate\Pagination\Paginator|\User[] */ public function findAllPaginated($perPage = 200); @@ -18,7 +19,8 @@ public function findAllPaginated($perPage = 200); /** * Find a user by it's username. * - * @param string $username + * @param string $username + * * @return \Tricks\User */ public function findByUsername($username); @@ -26,7 +28,8 @@ public function findByUsername($username); /** * Find a user by it's email. * - * @param string $email + * @param string $email + * * @return \Tricks\User */ public function findByEmail($email); @@ -34,24 +37,28 @@ public function findByEmail($email); /** * Require a user by it's username. * - * @param string $username - * @return \Tricks\User + * @param string $username * * @throws \Tricks\Exceptions\UserNotFoundException + * + * @return \Tricks\User */ public function requireByUsername($username); /** * Create a new user in the database. * - * @param array $data + * @param array $data + * * @return \Tricks\User */ public function create(array $data); /** * Create a new user in the database using GitHub data. - * @param array $data + * + * @param array $data + * * @return \Tricks\User */ public function createFromGithubData(OAuthUser $data); @@ -59,7 +66,8 @@ public function createFromGithubData(OAuthUser $data); /** * Update the user's settings. * - * @param array $data + * @param array $data + * * @return \Tricks\User */ public function updateSettings(User $user, array $data); diff --git a/app/Tricks/Services/Feeds/Builder.php b/app/Tricks/Services/Feeds/Builder.php index 0b81582..5779bac 100644 --- a/app/Tricks/Services/Feeds/Builder.php +++ b/app/Tricks/Services/Feeds/Builder.php @@ -46,9 +46,10 @@ class Builder /** * Create a new feed builder instance. * - * @param \Tricks\Repositories\TrickRepositoryInterface $tricks - * @param \Illuminate\Http\Response $response - * @param \Illuminate\View\Environment $view + * @param \Tricks\Repositories\TrickRepositoryInterface $tricks + * @param \Illuminate\Http\Response $response + * @param \Illuminate\View\Environment $view + * * @return void */ public function __construct( @@ -64,7 +65,8 @@ public function __construct( /** * Set the feed type to build. * - * @param string $type + * @param string $type + * * @return void */ public function setType($type) @@ -75,7 +77,8 @@ public function setType($type) /** * Set the charset to render the feed in. * - * @param string $charset + * @param string $charset + * * @return void */ public function setCharset($charset) @@ -123,7 +126,7 @@ protected function prepareHeaders() { $contentType = $this->getContentType(); - $header = $contentType . '; charset=' . $this->charset; + $header = $contentType.'; charset='.$this->charset; $this->response->header('Content-Type', $header); } @@ -141,7 +144,8 @@ protected function getContentType() /** * Prepare the feed view. * - * @param array $data + * @param array $data + * * @return \Illuminate\View\View */ protected function prepareView(array $data) diff --git a/app/Tricks/Services/Forms/CategoryForm.php b/app/Tricks/Services/Forms/CategoryForm.php index 26344bb..2b1aaf0 100644 --- a/app/Tricks/Services/Forms/CategoryForm.php +++ b/app/Tricks/Services/Forms/CategoryForm.php @@ -11,6 +11,6 @@ class CategoryForm extends AbstractForm */ protected $rules = [ 'name' => 'required', - 'description' => 'required|min:4' + 'description' => 'required|min:4', ]; } diff --git a/app/Tricks/Services/Forms/RegistrationForm.php b/app/Tricks/Services/Forms/RegistrationForm.php index 4f75938..168b3a5 100644 --- a/app/Tricks/Services/Forms/RegistrationForm.php +++ b/app/Tricks/Services/Forms/RegistrationForm.php @@ -21,7 +21,7 @@ class RegistrationForm extends AbstractForm protected $rules = [ 'username' => 'required|min:4|alpha_num|unique:users,username', 'email' => 'required|email|min:5|unique:users', - 'password' => 'required|min:6|confirmed' + 'password' => 'required|min:6|confirmed', ]; /** @@ -30,13 +30,14 @@ class RegistrationForm extends AbstractForm * @var array */ protected $messages = [ - 'not_in' => 'The selected username is reserved, please try a different username.' + 'not_in' => 'The selected username is reserved, please try a different username.', ]; /** * Create a new RegistrationForm instance. * - * @param \Illuminate\Config\Repository $config + * @param \Illuminate\Config\Repository $config + * * @return void */ public function __construct(Repository $config) @@ -56,7 +57,7 @@ protected function getPreparedRules() $forbidden = $this->config->get('config.forbidden_usernames'); $forbidden = implode(',', $forbidden); - $this->rules['username'] .= '|not_in:' . $forbidden; + $this->rules['username'] .= '|not_in:'.$forbidden; return $this->rules; } diff --git a/app/Tricks/Services/Forms/SettingsForm.php b/app/Tricks/Services/Forms/SettingsForm.php index 3fd5c85..d58ef92 100644 --- a/app/Tricks/Services/Forms/SettingsForm.php +++ b/app/Tricks/Services/Forms/SettingsForm.php @@ -28,14 +28,15 @@ class SettingsForm extends AbstractForm */ protected $rules = [ 'username' => 'required|min:4', - 'password' => 'confirmed|min:6' + 'password' => 'confirmed|min:6', ]; /** * Create a new SettingsForm instance. * - * @param \Illuminate\Config\Repository $config - * @param \Illuminate\Auth\AuthManager $auth + * @param \Illuminate\Config\Repository $config + * @param \Illuminate\Auth\AuthManager $auth + * * @return void */ public function __construct(Repository $config, AuthManager $auth) @@ -54,10 +55,10 @@ public function __construct(Repository $config, AuthManager $auth) protected function getPreparedRules() { $forbidden = implode(',', $this->config->get('config.forbidden_usernames')); - $userId = $this->auth->user()->id; + $userId = $this->auth->user()->id; - $this->rules['username'] .= '|not_in:' . $forbidden; - $this->rules['username'] .= '|unique:users,username,' . $userId; + $this->rules['username'] .= '|not_in:'.$forbidden; + $this->rules['username'] .= '|unique:users,username,'.$userId; return $this->rules; } @@ -70,7 +71,7 @@ protected function getPreparedRules() public function getInputData() { return array_only($this->inputData, [ - 'username', 'password', 'password_confirmation' + 'username', 'password', 'password_confirmation', ]); } } diff --git a/app/Tricks/Services/Forms/TagForm.php b/app/Tricks/Services/Forms/TagForm.php index f1299bb..c2fc81b 100644 --- a/app/Tricks/Services/Forms/TagForm.php +++ b/app/Tricks/Services/Forms/TagForm.php @@ -10,6 +10,6 @@ class TagForm extends AbstractForm * @var array */ protected $rules = [ - 'name' => 'required' + 'name' => 'required', ]; } diff --git a/app/Tricks/Services/Forms/TrickEditForm.php b/app/Tricks/Services/Forms/TrickEditForm.php index 56e94e5..f3bd117 100644 --- a/app/Tricks/Services/Forms/TrickEditForm.php +++ b/app/Tricks/Services/Forms/TrickEditForm.php @@ -21,7 +21,7 @@ class TrickEditForm extends AbstractForm 'description' => 'required|min:10', 'tags' => 'required', 'categories' => 'required', - 'code' => 'required' + 'code' => 'required', ]; public function __construct($id) @@ -38,7 +38,7 @@ public function __construct($id) */ protected function getPreparedRules() { - $this->rules['title'] .= ',' . $this->id; + $this->rules['title'] .= ','.$this->id; return $this->rules; } @@ -51,7 +51,7 @@ protected function getPreparedRules() public function getInputData() { return array_only($this->inputData, [ - 'title', 'description', 'tags', 'categories', 'code' + 'title', 'description', 'tags', 'categories', 'code', ]); } } diff --git a/app/Tricks/Services/Forms/TrickForm.php b/app/Tricks/Services/Forms/TrickForm.php index 8e7f2fa..6314a06 100644 --- a/app/Tricks/Services/Forms/TrickForm.php +++ b/app/Tricks/Services/Forms/TrickForm.php @@ -14,7 +14,7 @@ class TrickForm extends AbstractForm 'description' => 'required|min:10', 'tags' => 'required', 'categories' => 'required', - 'code' => 'required' + 'code' => 'required', ]; /** @@ -25,7 +25,7 @@ class TrickForm extends AbstractForm public function getInputData() { return array_only($this->inputData, [ - 'title', 'description', 'tags', 'categories', 'code' + 'title', 'description', 'tags', 'categories', 'code', ]); } } diff --git a/app/Tricks/Services/Navigation/Builder.php b/app/Tricks/Services/Navigation/Builder.php index dd5a2c8..5bbb384 100644 --- a/app/Tricks/Services/Navigation/Builder.php +++ b/app/Tricks/Services/Navigation/Builder.php @@ -24,8 +24,9 @@ class Builder /** * Create a new Navigation Builder instance. * - * @param \Illuminate\Config\Repository $config - * @param \Illuminate\Auth\AuthManager $auth + * @param \Illuminate\Config\Repository $config + * @param \Illuminate\Auth\AuthManager $auth + * * @return void */ public function __construct(Repository $config, AuthManager $auth) @@ -37,24 +38,24 @@ public function __construct(Repository $config, AuthManager $auth) /** * Build the HTML navigation from the given config key. * - * @param string $url - * @param string $type + * @param string $url + * @param string $type + * * @return string */ public function make($url, $type = 'menu') { - $menu = $this->getNavigationConfig($type); - $html = ''; + $menu = $this->getNavigationConfig($type); + $html = ''; $hasActive = false; foreach ($menu as $item) { $isActive = false; - if (! $hasActive && $this->isActiveItem($item, $url)) { + if (!$hasActive && $this->isActiveItem($item, $url)) { $isActive = $hasActive = true; } - $html .= $this->getNavigationItem($item, $isActive); } @@ -64,18 +65,21 @@ public function make($url, $type = 'menu') /** * Load the navigation config for the given type. * - * @param string $type + * @param string $type + * * @return array */ protected function getNavigationConfig($type) { - return $this->config->get('navigation.' . $type); + return $this->config->get('navigation.'.$type); } /** * Determine whether the given item is currently active. - * @param array $item - * @param string $url + * + * @param array $item + * @param string $url + * * @return bool */ protected function isActiveItem(array $item, $url) @@ -92,8 +96,9 @@ protected function isActiveItem(array $item, $url) /** * Get a parsed HTML navigation list item for the given item. * - * @param array $item - * @param bool $isActive + * @param array $item + * @param bool $isActive + * * @return string */ protected function getNavigationItem(array $item, $isActive) @@ -106,7 +111,8 @@ protected function getNavigationItem(array $item, $isActive) /** * Get the HTML anchor link for the given item. * - * @param array $item + * @param array $item + * * @return string */ protected function getItemAnchor(array $item) @@ -117,14 +123,15 @@ protected function getItemAnchor(array $item) /** * Wrap the given anchor in a list item. * - * @param string $anchor - * @param bool $isActive + * @param string $anchor + * @param bool $isActive + * * @return string */ protected function wrapAnchor($anchor, $isActive) { $class = $isActive ? ' class="active"' : ''; - return '' . $anchor . ''; + return ''.$anchor.''; } } diff --git a/app/Tricks/Services/Sitemap/Builder.php b/app/Tricks/Services/Sitemap/Builder.php index 6b846b4..511a78a 100644 --- a/app/Tricks/Services/Sitemap/Builder.php +++ b/app/Tricks/Services/Sitemap/Builder.php @@ -2,8 +2,8 @@ namespace Tricks\Services\Sitemap; -use Roumen\Sitemap\Sitemap; use Illuminate\Config\Repository; +use Roumen\Sitemap\Sitemap; class Builder { @@ -38,9 +38,10 @@ class Builder /** * Create a new sitemap builder instance. * - * @param \Roumen\Sitemap\Sitemap $sitemap - * @param \Tricks\Services\Sitemap\DataProvider $provider - * @param \Illuminate\Config\Repository $config + * @param \Roumen\Sitemap\Sitemap $sitemap + * @param \Tricks\Services\Sitemap\DataProvider $provider + * @param \Illuminate\Config\Repository $config + * * @return void */ public function __construct(Sitemap $sitemap, DataProvider $provider, Repository $config) @@ -53,7 +54,8 @@ public function __construct(Sitemap $sitemap, DataProvider $provider, Repository /** * Set the type of sitemap to build. * - * @param string $type + * @param string $type + * * @return void */ public function setType($type) @@ -78,7 +80,7 @@ public function render() } /** - * Add the static pages to the sitemap + * Add the static pages to the sitemap. * * @return void */ @@ -104,14 +106,15 @@ protected function getTypes() /** * Add the dynamic data of the given type to the sitemap. * - * @param string $type - * @param array $config + * @param string $type + * @param array $config + * * @return void */ protected function addDynamicData($type, $config) { foreach ($this->getItems($type) as $item) { - $url = $this->getItemUrl($item, $type); + $url = $this->getItemUrl($item, $type); $lastMod = $item->{$config['lastMod']}; $this->sitemap->add($url, $lastMod, $config['priority'], $config['freq']); @@ -121,7 +124,8 @@ protected function addDynamicData($type, $config) /** * Get the dynamic items from the data provider. * - * @param string $type + * @param string $type + * * @return \Illuminate\Support\Collection */ protected function getItems($type) @@ -134,19 +138,21 @@ protected function getItems($type) /** * Get the name of the data method. * - * @param string $type + * @param string $type + * * @return string */ protected function getDataMethodName($type) { - return 'get' . studly_case($type); + return 'get'.studly_case($type); } /** * Get the url of the given item. * - * @param mixed $item - * @param string $type + * @param mixed $item + * @param string $type + * * @return string */ protected function getItemUrl($item, $type) @@ -159,11 +165,12 @@ protected function getItemUrl($item, $type) /** * Get the name of the url method. * - * @param string $type + * @param string $type + * * @return string */ protected function getUrlMethodName($type) { - return 'get' . studly_case(str_singular($type)) . 'Url'; + return 'get'.studly_case(str_singular($type)).'Url'; } } diff --git a/app/Tricks/Services/Sitemap/DataProvider.php b/app/Tricks/Services/Sitemap/DataProvider.php index 7adb296..d7ceacd 100644 --- a/app/Tricks/Services/Sitemap/DataProvider.php +++ b/app/Tricks/Services/Sitemap/DataProvider.php @@ -3,9 +3,9 @@ namespace Tricks\Services\Sitemap; use Illuminate\Routing\UrlGenerator; +use Tricks\Repositories\CategoryRepositoryInterface; use Tricks\Repositories\TagRepositoryInterface; use Tricks\Repositories\TrickRepositoryInterface; -use Tricks\Repositories\CategoryRepositoryInterface; class DataProvider { @@ -40,10 +40,11 @@ class DataProvider /** * Create a new data provider instance. * - * @param \Illuminate\Routing\UrlGenerator $url - * @param \Tricks\Repositories\TagRepositoryInterface $tags - * @param \Tricks\Repositories\TrickRepositoryInterface $tricks - * @param \Tricks\Repositories\CategoryRepositoryInterface $categories + * @param \Illuminate\Routing\UrlGenerator $url + * @param \Tricks\Repositories\TagRepositoryInterface $tags + * @param \Tricks\Repositories\TrickRepositoryInterface $tricks + * @param \Tricks\Repositories\CategoryRepositoryInterface $categories + * * @return void */ public function __construct( @@ -71,7 +72,8 @@ public function getTags() /** * Get the url for the given tag. * - * @param \Tricks\Tag $tag + * @param \Tricks\Tag $tag + * * @return string */ public function getTagUrl($tag) @@ -92,7 +94,8 @@ public function getTricks() /** * Get the url for the given trick. * - * @param \Tricks\Trick $trick + * @param \Tricks\Trick $trick + * * @return string */ public function getTrickUrl($trick) @@ -113,7 +116,8 @@ public function getCategories() /** * Get the url for the given category. * - * @param \Tricks\Category $category + * @param \Tricks\Category $category + * * @return string */ public function getCategoryUrl($category) @@ -143,9 +147,10 @@ public function getStaticPages() /** * Get the data for the given page. * - * @param string $route - * @param string $freq - * @param string $priority + * @param string $route + * @param string $freq + * @param string $priority + * * @return array */ protected function getPage($route, $freq, $priority) diff --git a/app/Tricks/Services/Social/Disqus.php b/app/Tricks/Services/Social/Disqus.php index cca0b5d..23dc65a 100644 --- a/app/Tricks/Services/Social/Disqus.php +++ b/app/Tricks/Services/Social/Disqus.php @@ -2,19 +2,19 @@ namespace Tricks\Services\Social; -use Tricks\Trick; -use RuntimeException; -use Illuminate\Config\Repository; -use Guzzle\Service\Client as GuzzleClient; -use Illuminate\Database\Eloquent\Collection; use Guzzle\Http\Exception\BadResponseException; use Guzzle\Http\Message\Request as GuzzleRequest; use Guzzle\Http\QueryAggregator\DuplicateAggregator; +use Guzzle\Service\Client as GuzzleClient; +use Illuminate\Config\Repository; +use Illuminate\Database\Eloquent\Collection; +use RuntimeException; +use Tricks\Trick; class Disqus { /** - * The curl client used for Disqus API interaction + * The curl client used for Disqus API interaction. * * @var \Guzzle\Service\Client */ @@ -30,8 +30,9 @@ class Disqus /** * Create a new Disqus instance. * - * @param \Guzzle\Service\Client $client - * @param \Illuminate\Config\Repository $config + * @param \Guzzle\Service\Client $client + * @param \Illuminate\Config\Repository $config + * * @return void */ public function __construct(GuzzleClient $client, Repository $config) @@ -43,20 +44,22 @@ public function __construct(GuzzleClient $client, Repository $config) /** * Get a config item. * - * @param mixed $key + * @param mixed $key + * * @return mixed */ protected function getConfig($key = null) { - $key = is_null($key) ? '' : '.' . $key; + $key = is_null($key) ? '' : '.'.$key; - return $this->config->get('social.disqus' . $key); + return $this->config->get('social.disqus'.$key); } /** * Normalize the given trick(s) to an array of tricks. * - * @param mixed $tricks + * @param mixed $tricks + * * @return array */ protected function getValidTricks($tricks) @@ -66,7 +69,7 @@ protected function getValidTricks($tricks) } if ($tricks instanceof Trick) { - $tricks = [ $tricks ]; + $tricks = [$tricks]; } return $tricks; @@ -75,28 +78,30 @@ protected function getValidTricks($tricks) /** * Determine whether the given tricks are invalid. * - * @param mixed $tricks + * @param mixed $tricks + * * @return bool */ protected function areInvalidTricks($tricks) { - return ! $tricks instanceof Trick && - ! ($tricks instanceof Collection && $tricks->count() > 0); + return !$tricks instanceof Trick && + !($tricks instanceof Collection && $tricks->count() > 0); } /** * Get a formatted list of the trick ids. * - * @param array $tricks + * @param array $tricks + * * @return array */ protected function getThreadsArray($tricks) { $threads = []; - $format = $this->getConfig('threadFormat'); + $format = $this->getConfig('threadFormat'); foreach ($tricks as $trick) { - $threads[] = $format . $trick->id; + $threads[] = $format.$trick->id; } return $threads; @@ -105,8 +110,9 @@ protected function getThreadsArray($tricks) /** * Prepare the query string before the API request. * - * @param \Guzzle\Http\Message\Request $request - * @param array $tricks + * @param \Guzzle\Http\Message\Request $request + * @param array $tricks + * * @return \Guzzle\Http\Message\Request */ protected function prepareQuery(GuzzleRequest $request, $tricks) @@ -130,13 +136,14 @@ protected function prepareQuery(GuzzleRequest $request, $tricks) */ protected function getQueryAggregator() { - return new DuplicateAggregator; + return new DuplicateAggregator(); } /** * Get the response from the prepared request. * - * @param \Guzzle\Http\Message\Request $request + * @param \Guzzle\Http\Message\Request $request + * * @return array */ protected function getResponse($request) @@ -146,13 +153,15 @@ protected function getResponse($request) return $response['response']; } catch (BadResponseException $bre) { - return null; + return; } } /** * Append the comment counts to the given tricks. - * @param mixed $tricks + * + * @param mixed $tricks + * * @return mixed */ public function appendCommentCounts($tricks) diff --git a/app/Tricks/Services/Social/Github.php b/app/Tricks/Services/Social/Github.php index 9d8af7d..3a7a42b 100644 --- a/app/Tricks/Services/Social/Github.php +++ b/app/Tricks/Services/Social/Github.php @@ -3,10 +3,10 @@ namespace Tricks\Services\Social; use Illuminate\Config\Repository; -use Tricks\Repositories\UserRepositoryInterface; -use Tricks\Repositories\ProfileRepositoryInterface; -use Tricks\Exceptions\GithubEmailNotVerifiedException; use League\OAuth2\Client\Provider\Github as GithubProvider; +use Tricks\Exceptions\GithubEmailNotVerifiedException; +use Tricks\Repositories\ProfileRepositoryInterface; +use Tricks\Repositories\UserRepositoryInterface; class Github { @@ -41,9 +41,10 @@ class Github /** * Create a new Github registration instance. * - * @param \League\OAuth2\Client\Provider\Github $provider - * @param \Tricks\Repositories\UserRepositoryInterface $users - * @param \Tricks\Repositories\ProfileRepositoryInterface $profiles + * @param \League\OAuth2\Client\Provider\Github $provider + * @param \Tricks\Repositories\UserRepositoryInterface $users + * @param \Tricks\Repositories\ProfileRepositoryInterface $profiles + * * @return void */ public function __construct( @@ -53,35 +54,37 @@ public function __construct( ProfileRepositoryInterface $profiles ) { $this->provider = $provider; - $this->config = $config; - $this->users = $users; + $this->config = $config; + $this->users = $users; $this->profiles = $profiles; } /** * Get a config item. * - * @param mixed $key + * @param mixed $key + * * @return mixed */ protected function getConfig($key = null) { - $key = is_null($key) ? '' : '.' . $key; + $key = is_null($key) ? '' : '.'.$key; - return $this->config->get('social.github' . $key); + return $this->config->get('social.github'.$key); } /** * Register a new user using their Github account. * - * @param string $code + * @param string $code + * * @return \Tricks\User */ public function register($code) { - $token = $this->provider->getAccessToken('authorization_code', [ 'code' => $code ]); + $token = $this->provider->getAccessToken('authorization_code', ['code' => $code]); - $userDetails = $this->provider->getUserDetails($token); + $userDetails = $this->provider->getUserDetails($token); $verifiedEmails = $this->getVerifiedEmails($token->accessToken); $userDetails->email = $this->getPrimaryEmail($verifiedEmails); @@ -98,7 +101,7 @@ public function register($code) $profile = $this->profiles->createFromGithubData($userDetails, $user, $token->accessToken); } else { $profile = $this->profiles->updateToken($profile, $token->accessToken); - $user = $profile->user; + $user = $profile->user; } return $user; @@ -107,13 +110,14 @@ public function register($code) /** * Get the primary, verified email address from the Github data. * - * @param mixed $emails + * @param mixed $emails + * * @return mixed */ protected function getPrimaryEmail($emails) { foreach ($emails as $email) { - if (! $email->primary) { + if (!$email->primary) { continue; } @@ -121,30 +125,31 @@ protected function getPrimaryEmail($emails) return $email->email; } - throw new GithubEmailNotVerifiedException; + throw new GithubEmailNotVerifiedException(); } - return null; + return; } /** - * Get all the users email addresses + * Get all the users email addresses. + * + * @param string $token * - * @param string $token * @return mixed */ protected function getVerifiedEmails($token) { $ch = curl_init('https://api.github.com/user/emails?access_token='.$token); - $userAgent = $this->getConfig('user_agent'); + $userAgent = $this->getConfig('user_agent'); $options = [ CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => [ 'Content-type: application/json', 'Accept: application/vnd.github.v3', - 'User-Agent: '.$userAgent - ] + 'User-Agent: '.$userAgent, + ], ]; curl_setopt_array($ch, $options); @@ -154,7 +159,7 @@ protected function getVerifiedEmails($token) $error = curl_error($ch); throw new GithubEmailAccessException($error); } - + return json_decode($result); } } diff --git a/app/Tricks/Services/Upload/ImageUploadService.php b/app/Tricks/Services/Upload/ImageUploadService.php index b5efa1a..1a59b2c 100644 --- a/app/Tricks/Services/Upload/ImageUploadService.php +++ b/app/Tricks/Services/Upload/ImageUploadService.php @@ -2,8 +2,8 @@ namespace Tricks\Services\Upload; -use Intervention\Image\Image; use Illuminate\Filesystem\Filesystem; +use Intervention\Image\Image; use Symfony\Component\HttpFoundation\File\UploadedFile; class ImageUploadService @@ -46,7 +46,8 @@ class ImageUploadService /** * Create a new ImageUploadService instance. * - * @param \Illuminate\Filesystem\Filesystem $filesystem + * @param \Illuminate\Filesystem\Filesystem $filesystem + * * @return void */ public function __construct(Filesystem $filesystem) @@ -57,7 +58,8 @@ public function __construct(Filesystem $filesystem) /** * Enable CORS from the given origin. * - * @param string $origin + * @param string $origin + * * @return void */ public function enableCORS($origin) @@ -67,39 +69,41 @@ public function enableCORS($origin) 'X-Requested-With', 'Content-Range', 'Content-Disposition', - 'Content-Type' + 'Content-Type', ]; - header('Access-Control-Allow-Origin: ' . $origin); + header('Access-Control-Allow-Origin: '.$origin); header('Access-Control-Allow-Methods: POST, GET, OPTIONS'); - header('Access-Control-Allow-Headers: ' . implode(', ', $allowHeaders)); + header('Access-Control-Allow-Headers: '.implode(', ', $allowHeaders)); } /** * Get the full path from the given partial path. * - * @param string $path + * @param string $path + * * @return string */ protected function getFullPath($path) { - return public_path() . '/' . $path; + return public_path().'/'.$path; } /** - * Make a new unique filename + * Make a new unique filename. * * @return string */ protected function makeFilename() { - return sha1(time() . time()) . ".{$this->extension}"; + return sha1(time().time()).".{$this->extension}"; } /** * Get the contents of the file located at the given path. * - * @param string $path + * @param string $path + * * @return mixed */ protected function getFile($path) @@ -110,7 +114,8 @@ protected function getFile($path) /** * Get the size of the file located at the given path. * - * @param string $path + * @param string $path + * * @return mixed */ protected function getFileSize($path) @@ -119,25 +124,27 @@ protected function getFileSize($path) } /** - * Construct the data URL for the JSON body + * Construct the data URL for the JSON body. + * + * @param string $mime + * @param string $path * - * @param string $mime - * @param string $path * @return string */ protected function getDataUrl($mime, $path) { $base = base64_encode($this->getFile($path)); - return 'data:' . $mime . ';base64,' . $base; + return 'data:'.$mime.';base64,'.$base; } /** * Construct the body of the JSON response. * - * @param string $filename - * @param string $mime - * @param string $path + * @param string $filename + * @param string $mime + * @param string $path + * * @return array */ protected function getJsonBody($filename, $mime, $path) @@ -147,8 +154,8 @@ protected function getJsonBody($filename, $mime, $path) 'filename' => $filename, 'mime' => $mime, 'size' => $this->getFileSize($path), - 'dataURL' => $this->getDataUrl($mime, $path) - ] + 'dataURL' => $this->getDataUrl($mime, $path), + ], ]; } @@ -156,20 +163,21 @@ protected function getJsonBody($filename, $mime, $path) * Handle the file upload. Returns the response body on success, or false * on failure. * - * @param \Symfony\Component\HttpFoundation\File\UploadedFile $file + * @param \Symfony\Component\HttpFoundation\File\UploadedFile $file + * * @return array|bool */ public function handle(UploadedFile $file) { - $mime = $file->getMimeType(); + $mime = $file->getMimeType(); $filename = $this->makeFilename(); - $path = $this->getFullPath($this->directory . '/' . $filename); + $path = $this->getFullPath($this->directory.'/'.$filename); $success = Image::make($file->getRealPath()) ->resize($this->size, $this->size, true, false) ->save($path, $this->quality); - if (! $success) { + if (!$success) { return false; } diff --git a/app/Tricks/Tag.php b/app/Tricks/Tag.php index 1995ad0..da54ad1 100644 --- a/app/Tricks/Tag.php +++ b/app/Tricks/Tag.php @@ -18,8 +18,8 @@ class Tag extends Model * * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ - public function tricks() - { - return $this->belongsToMany('Tricks\Trick'); - } + public function tricks() + { + return $this->belongsToMany('Tricks\Trick'); + } } diff --git a/app/Tricks/Trick.php b/app/Tricks/Trick.php index 510e978..a2ed5f5 100644 --- a/app/Tricks/Trick.php +++ b/app/Tricks/Trick.php @@ -13,36 +13,36 @@ class Trick extends Model */ protected $table = 'tricks'; - /** - * The class used to present the model. - * - * @var string - */ - public $presenter = 'Tricks\Presenters\TrickPresenter'; + /** + * The class used to present the model. + * + * @var string + */ + public $presenter = 'Tricks\Presenters\TrickPresenter'; - /** - * The relations to eager load on every query. - * - * @var array - */ - protected $with = [ 'tags', 'categories', 'user' ]; + /** + * The relations to eager load on every query. + * + * @var array + */ + protected $with = ['tags', 'categories', 'user']; - /** - * Query the tricks' votes. - * - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany - */ - public function votes() - { - return $this->belongsToMany('Tricks\User', 'votes'); - } + /** + * Query the tricks' votes. + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + */ + public function votes() + { + return $this->belongsToMany('Tricks\User', 'votes'); + } - /** - * Query the user that posted the trick. - * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo - */ - public function user() + /** + * Query the user that posted the trick. + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + */ + public function user() { return $this->belongsTo('Tricks\User'); } @@ -52,18 +52,18 @@ public function user() * * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ - public function tags() - { - return $this->belongsToMany('Tricks\Tag'); - } + public function tags() + { + return $this->belongsToMany('Tricks\Tag'); + } - /** - * Query the categories under which the trick was posted. - * - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany - */ - public function categories() - { - return $this->belongsToMany('Tricks\Category'); - } + /** + * Query the categories under which the trick was posted. + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + */ + public function categories() + { + return $this->belongsToMany('Tricks\Category'); + } } diff --git a/app/Tricks/User.php b/app/Tricks/User.php index f9d3338..c71611c 100644 --- a/app/Tricks/User.php +++ b/app/Tricks/User.php @@ -3,153 +3,153 @@ namespace Tricks; use Gravatar; +use Illuminate\Auth\Reminders\RemindableInterface; use Illuminate\Auth\UserInterface; use Illuminate\Database\Eloquent\Model; -use Illuminate\Auth\Reminders\RemindableInterface; class User extends Model implements UserInterface, RemindableInterface { - /** - * The class to used to present the model. - * - * @var string - */ - public $presenter = 'Tricks\Presenters\UserPresenter'; + /** + * The class to used to present the model. + * + * @var string + */ + public $presenter = 'Tricks\Presenters\UserPresenter'; /** * The table associated with the model. * * @var string */ - protected $table = 'users'; - - /** - * The attributes that should be hidden for arrays. - * - * @var array - */ - protected $hidden = [ 'password' ]; - - /** - * Users should not be admin by default - * - * @var array - */ - protected $attributes = [ - 'is_admin' => false - ]; - - /** - * Query the user's social profile. - * - * @return \Illuminate\Database\Eloquent\Relations\HasOne - */ - public function profile() - { - return $this->hasOne('Tricks\Profile'); - } - - /** - * Query the tricks that the user has posted. - * - * @return \Illuminate\Database\Eloquent\Relations\HasMany - */ - public function tricks() - { - return $this->hasMany('Tricks\Trick'); - } - - /** - * Query the votes that are casted by the user. - * - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany - */ - public function votes() - { - return $this->belongsToMany('Tricks\Trick', 'votes'); - } - - /** - * Get the remember me token from DB - * - * @return mixed - */ - public function getRememberToken() - { - return $this->remember_token; - } - - /** - * Set the remember me token to DB - * - * @return mixed - */ - public function setRememberToken($value) - { - $this->remember_token = $value; - } - - /** - * Get the column of remember me token in DB - * - * @return mixed - */ - public function getRememberTokenName() - { - return 'remember_token'; - } - - /** - * Get the unique identifier for the user. - * - * @return mixed - */ - public function getAuthIdentifier() - { - return $this->getKey(); - } - - /** - * Get the password for the user. - * - * @return string - */ - public function getAuthPassword() - { - return $this->password; - } - - /** - * Get the user's avatar image. - * - * @return string - */ - public function getPhotocssAttribute() - { - if($this->photo) { - return url('img/avatar/' . $this->photo); - } - - return Gravatar::src($this->email, 100); - } - - /** - * Get the e-mail address where password reminders are sent. - * - * @return string - */ - public function getReminderEmail() - { - return $this->email; - } - - /** - * Check user's permissions - * - * @return bool - */ - public function isAdmin() - { - return ($this->is_admin == true); - } + protected $table = 'users'; + + /** + * The attributes that should be hidden for arrays. + * + * @var array + */ + protected $hidden = ['password']; + + /** + * Users should not be admin by default. + * + * @var array + */ + protected $attributes = [ + 'is_admin' => false, + ]; + + /** + * Query the user's social profile. + * + * @return \Illuminate\Database\Eloquent\Relations\HasOne + */ + public function profile() + { + return $this->hasOne('Tricks\Profile'); + } + + /** + * Query the tricks that the user has posted. + * + * @return \Illuminate\Database\Eloquent\Relations\HasMany + */ + public function tricks() + { + return $this->hasMany('Tricks\Trick'); + } + + /** + * Query the votes that are casted by the user. + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + */ + public function votes() + { + return $this->belongsToMany('Tricks\Trick', 'votes'); + } + + /** + * Get the remember me token from DB. + * + * @return mixed + */ + public function getRememberToken() + { + return $this->remember_token; + } + + /** + * Set the remember me token to DB. + * + * @return mixed + */ + public function setRememberToken($value) + { + $this->remember_token = $value; + } + + /** + * Get the column of remember me token in DB. + * + * @return mixed + */ + public function getRememberTokenName() + { + return 'remember_token'; + } + + /** + * Get the unique identifier for the user. + * + * @return mixed + */ + public function getAuthIdentifier() + { + return $this->getKey(); + } + + /** + * Get the password for the user. + * + * @return string + */ + public function getAuthPassword() + { + return $this->password; + } + + /** + * Get the user's avatar image. + * + * @return string + */ + public function getPhotocssAttribute() + { + if ($this->photo) { + return url('img/avatar/'.$this->photo); + } + + return Gravatar::src($this->email, 100); + } + + /** + * Get the e-mail address where password reminders are sent. + * + * @return string + */ + public function getReminderEmail() + { + return $this->email; + } + + /** + * Check user's permissions. + * + * @return bool + */ + public function isAdmin() + { + return $this->is_admin == true; + } } diff --git a/app/config/app.php b/app/config/app.php index 6bc4f5a..5d2c0cc 100644 --- a/app/config/app.php +++ b/app/config/app.php @@ -1,6 +1,6 @@ array( + 'providers' => [ 'Illuminate\Foundation\Providers\ArtisanServiceProvider', 'Illuminate\Auth\AuthServiceProvider', @@ -118,7 +118,7 @@ 'Tricks\Providers\NavigationServiceProvider', 'Tricks\Providers\SitemapServiceProvider', 'Tricks\Providers\EventServiceProvider', - ), + ], /* |-------------------------------------------------------------------------- @@ -144,7 +144,7 @@ | */ - 'aliases' => array( + 'aliases' => [ 'App' => 'Illuminate\Support\Facades\App', 'Artisan' => 'Illuminate\Support\Facades\Artisan', @@ -191,6 +191,6 @@ 'ImageUpload' => 'Tricks\Facades\ImageUpload', 'Navigation' => 'Tricks\Facades\Navigation', 'Disqus' => 'Tricks\Facades\Disqus', - ), + ], -); +]; diff --git a/app/config/auth.php b/app/config/auth.php index fc57201..2ed0aa3 100644 --- a/app/config/auth.php +++ b/app/config/auth.php @@ -1,71 +1,71 @@ 'eloquent', + 'driver' => 'eloquent', - /* - |-------------------------------------------------------------------------- - | Authentication Model - |-------------------------------------------------------------------------- - | - | When using the "Eloquent" authentication driver, we need to know which - | Eloquent model should be used to retrieve your users. Of course, it - | is often just the "User" model but you may use whatever you like. - | - */ + /* + |-------------------------------------------------------------------------- + | Authentication Model + |-------------------------------------------------------------------------- + | + | When using the "Eloquent" authentication driver, we need to know which + | Eloquent model should be used to retrieve your users. Of course, it + | is often just the "User" model but you may use whatever you like. + | + */ - 'model' => 'Tricks\User', + 'model' => 'Tricks\User', - /* - |-------------------------------------------------------------------------- - | Authentication Table - |-------------------------------------------------------------------------- - | - | When using the "Database" authentication driver, we need to know which - | table should be used to retrieve your users. We have chosen a basic - | default value but you may easily change it to any table you like. - | - */ + /* + |-------------------------------------------------------------------------- + | Authentication Table + |-------------------------------------------------------------------------- + | + | When using the "Database" authentication driver, we need to know which + | table should be used to retrieve your users. We have chosen a basic + | default value but you may easily change it to any table you like. + | + */ - 'table' => 'users', + 'table' => 'users', - /* - |-------------------------------------------------------------------------- - | Password Reminder Settings - |-------------------------------------------------------------------------- - | - | Here you may set the settings for password reminders, including a view - | that should be used as your password reminder e-mail. You will also - | be able to set the name of the table that holds the reset tokens. - | - | The "expire" time is the number of minutes that the reminder should be - | considered valid. This security feature keeps tokens short-lived so - | they have less time to be guessed. You may change this as needed. - | - */ + /* + |-------------------------------------------------------------------------- + | Password Reminder Settings + |-------------------------------------------------------------------------- + | + | Here you may set the settings for password reminders, including a view + | that should be used as your password reminder e-mail. You will also + | be able to set the name of the table that holds the reset tokens. + | + | The "expire" time is the number of minutes that the reminder should be + | considered valid. This security feature keeps tokens short-lived so + | they have less time to be guessed. You may change this as needed. + | + */ - 'reminder' => array( + 'reminder' => [ - 'email' => 'emails.auth.reminder', + 'email' => 'emails.auth.reminder', - 'table' => 'password_reminders', + 'table' => 'password_reminders', - 'expire' => 60, + 'expire' => 60, - ), + ], -); +]; diff --git a/app/config/cache.php b/app/config/cache.php index 76053ab..8a8630e 100644 --- a/app/config/cache.php +++ b/app/config/cache.php @@ -1,89 +1,89 @@ 'redis', - - /* - |-------------------------------------------------------------------------- - | File Cache Location - |-------------------------------------------------------------------------- - | - | When using the "file" cache driver, we need a location where the cache - | files may be stored. A sensible default has been specified, but you - | are free to change it to any other place on disk that you desire. - | - */ - - 'path' => storage_path().'/cache', - - /* - |-------------------------------------------------------------------------- - | Database Cache Connection - |-------------------------------------------------------------------------- - | - | When using the "database" cache driver you may specify the connection - | that should be used to store the cached items. When this option is - | null the default database connection will be utilized for cache. - | - */ - - 'connection' => null, - - /* - |-------------------------------------------------------------------------- - | Database Cache Table - |-------------------------------------------------------------------------- - | - | When using the "database" cache driver we need to know the table that - | should be used to store the cached items. A default table name has - | been provided but you're free to change it however you deem fit. - | - */ - - 'table' => 'cache', - - /* - |-------------------------------------------------------------------------- - | Memcached Servers - |-------------------------------------------------------------------------- - | - | Now you may specify an array of your Memcached servers that should be - | used when utilizing the Memcached cache driver. All of the servers - | should contain a value for "host", "port", and "weight" options. - | - */ - - 'memcached' => array( - - array('host' => '127.0.0.1', 'port' => 11211, 'weight' => 100), - - ), - - /* - |-------------------------------------------------------------------------- - | Cache Key Prefix - |-------------------------------------------------------------------------- - | - | When utilizing a RAM based store such as APC or Memcached, there might - | be other applications utilizing the same cache. So, we'll specify a - | value to get prefixed to all our keys so we can avoid collisions. - | - */ - - 'prefix' => 'laravel', - -); +return [ + + /* + |-------------------------------------------------------------------------- + | Default Cache Driver + |-------------------------------------------------------------------------- + | + | This option controls the default cache "driver" that will be used when + | using the Caching library. Of course, you may use other drivers any + | time you wish. This is the default when another is not specified. + | + | Supported: "file", "database", "apc", "memcached", "redis", "array" + | + */ + + 'driver' => 'redis', + + /* + |-------------------------------------------------------------------------- + | File Cache Location + |-------------------------------------------------------------------------- + | + | When using the "file" cache driver, we need a location where the cache + | files may be stored. A sensible default has been specified, but you + | are free to change it to any other place on disk that you desire. + | + */ + + 'path' => storage_path().'/cache', + + /* + |-------------------------------------------------------------------------- + | Database Cache Connection + |-------------------------------------------------------------------------- + | + | When using the "database" cache driver you may specify the connection + | that should be used to store the cached items. When this option is + | null the default database connection will be utilized for cache. + | + */ + + 'connection' => null, + + /* + |-------------------------------------------------------------------------- + | Database Cache Table + |-------------------------------------------------------------------------- + | + | When using the "database" cache driver we need to know the table that + | should be used to store the cached items. A default table name has + | been provided but you're free to change it however you deem fit. + | + */ + + 'table' => 'cache', + + /* + |-------------------------------------------------------------------------- + | Memcached Servers + |-------------------------------------------------------------------------- + | + | Now you may specify an array of your Memcached servers that should be + | used when utilizing the Memcached cache driver. All of the servers + | should contain a value for "host", "port", and "weight" options. + | + */ + + 'memcached' => [ + + ['host' => '127.0.0.1', 'port' => 11211, 'weight' => 100], + + ], + + /* + |-------------------------------------------------------------------------- + | Cache Key Prefix + |-------------------------------------------------------------------------- + | + | When utilizing a RAM based store such as APC or Memcached, there might + | be other applications utilizing the same cache. So, we'll specify a + | value to get prefixed to all our keys so we can avoid collisions. + | + */ + + 'prefix' => 'laravel', + +]; diff --git a/app/config/compile.php b/app/config/compile.php index 54d7185..63f5737 100644 --- a/app/config/compile.php +++ b/app/config/compile.php @@ -1,18 +1,16 @@ 3600, + 'view_throttle_time' => 3600, - 'version' => '1.0.0', - 'version_date' => 'February 19, 2014', + 'version' => '1.0.0', + 'version_date' => 'February 19, 2014', - 'analytics_property_id' => 'UA-XXXX-Y', - 'disqus_shortname' => 'Your Disqus shortname here', + 'analytics_property_id' => 'UA-XXXX-Y', + 'disqus_shortname' => 'Your Disqus shortname here', - // Admin email (the notifications are sent to this email, also see the mail.php config for the "From" address) - 'admin_email' => '', + // Admin email (the notifications are sent to this email, also see the mail.php config for the "From" address) + 'admin_email' => '', - // available user permission types that are matched by user_type column in the users table - 'user_types' => array( - 'admin' => 100, - 'reviewer' => 20, - 'user' => 10 - ), + // available user permission types that are matched by user_type column in the users table + 'user_types' => [ + 'admin' => 100, + 'reviewer' => 20, + 'user' => 10, + ], - // Some potential usernames should be protected and new or existing users will not - // be able to take any of the following usernames : - 'forbidden_usernames' => [ - 'tricks', - 'trick', - 'user', - 'admin', - 'privacy', - 'license', - 'resources', - 'about', - 'login', - 'logout', - 'register', - 'img', - 'css', - 'js', - 'feed', - 'feed.atom', - 'feed.xml' - ], -); + // Some potential usernames should be protected and new or existing users will not + // be able to take any of the following usernames : + 'forbidden_usernames' => [ + 'tricks', + 'trick', + 'user', + 'admin', + 'privacy', + 'license', + 'resources', + 'about', + 'login', + 'logout', + 'register', + 'img', + 'css', + 'js', + 'feed', + 'feed.atom', + 'feed.xml', + ], +]; diff --git a/app/config/database.php b/app/config/database.php index 79f8faa..b9bde59 100644 --- a/app/config/database.php +++ b/app/config/database.php @@ -1,124 +1,124 @@ PDO::FETCH_CLASS, - - /* - |-------------------------------------------------------------------------- - | Default Database Connection Name - |-------------------------------------------------------------------------- - | - | Here you may specify which of the database connections below you wish - | to use as your default connection for all database work. Of course - | you may use many connections at once using the Database library. - | - */ - - 'default' => 'mysql', - - /* - |-------------------------------------------------------------------------- - | Database Connections - |-------------------------------------------------------------------------- - | - | Here are each of the database connections setup for your application. - | Of course, examples of configuring each database platform that is - | supported by Laravel is shown below to make development simple. - | - | - | All database work in Laravel is done through the PHP PDO facilities - | so make sure you have the driver for your particular database of - | choice installed on your machine before you begin development. - | - */ - - 'connections' => array( - - 'sqlite' => array( - 'driver' => 'sqlite', - 'database' => __DIR__.'/../database/production.sqlite', - 'prefix' => '', - ), - - 'mysql' => array( - 'driver' => 'mysql', - 'host' => 'localhost', - 'database' => 'laravel-tricks', - 'username' => 'root', - 'password' => '', - 'charset' => 'utf8', - 'collation' => 'utf8_unicode_ci', - 'prefix' => '', - ), - - 'pgsql' => array( - 'driver' => 'pgsql', - 'host' => 'localhost', - 'database' => 'database', - 'username' => 'root', - 'password' => '', - 'charset' => 'utf8', - 'prefix' => '', - 'schema' => 'public', - ), - - 'sqlsrv' => array( - 'driver' => 'sqlsrv', - 'host' => 'localhost', - 'database' => 'database', - 'username' => 'root', - 'password' => '', - 'prefix' => '', - ), - - ), - - /* - |-------------------------------------------------------------------------- - | Migration Repository Table - |-------------------------------------------------------------------------- - | - | This table keeps track of all the migrations that have already run for - | your application. Using this information, we can determine which of - | the migrations on disk have not actually be run in the databases. - | - */ - - 'migrations' => 'migrations', - - /* - |-------------------------------------------------------------------------- - | Redis Databases - |-------------------------------------------------------------------------- - | - | Redis is an open source, fast, and advanced key-value store that also - | provides a richer set of commands than a typical key-value systems - | such as APC or Memcached. Laravel makes it easy to dig right in. - | - */ - - 'redis' => array( - - 'cluster' => true, - - 'default' => array( - 'host' => '127.0.0.1', - 'port' => 6379, - 'database' => 0, - ), - - ), - -); +return [ + + /* + |-------------------------------------------------------------------------- + | PDO Fetch Style + |-------------------------------------------------------------------------- + | + | By default, database results will be returned as instances of the PHP + | stdClass object; however, you may desire to retrieve records in an + | array format for simplicity. Here you can tweak the fetch style. + | + */ + + 'fetch' => PDO::FETCH_CLASS, + + /* + |-------------------------------------------------------------------------- + | Default Database Connection Name + |-------------------------------------------------------------------------- + | + | Here you may specify which of the database connections below you wish + | to use as your default connection for all database work. Of course + | you may use many connections at once using the Database library. + | + */ + + 'default' => 'mysql', + + /* + |-------------------------------------------------------------------------- + | Database Connections + |-------------------------------------------------------------------------- + | + | Here are each of the database connections setup for your application. + | Of course, examples of configuring each database platform that is + | supported by Laravel is shown below to make development simple. + | + | + | All database work in Laravel is done through the PHP PDO facilities + | so make sure you have the driver for your particular database of + | choice installed on your machine before you begin development. + | + */ + + 'connections' => [ + + 'sqlite' => [ + 'driver' => 'sqlite', + 'database' => __DIR__.'/../database/production.sqlite', + 'prefix' => '', + ], + + 'mysql' => [ + 'driver' => 'mysql', + 'host' => 'localhost', + 'database' => 'laravel-tricks', + 'username' => 'root', + 'password' => '', + 'charset' => 'utf8', + 'collation' => 'utf8_unicode_ci', + 'prefix' => '', + ], + + 'pgsql' => [ + 'driver' => 'pgsql', + 'host' => 'localhost', + 'database' => 'database', + 'username' => 'root', + 'password' => '', + 'charset' => 'utf8', + 'prefix' => '', + 'schema' => 'public', + ], + + 'sqlsrv' => [ + 'driver' => 'sqlsrv', + 'host' => 'localhost', + 'database' => 'database', + 'username' => 'root', + 'password' => '', + 'prefix' => '', + ], + + ], + + /* + |-------------------------------------------------------------------------- + | Migration Repository Table + |-------------------------------------------------------------------------- + | + | This table keeps track of all the migrations that have already run for + | your application. Using this information, we can determine which of + | the migrations on disk have not actually be run in the databases. + | + */ + + 'migrations' => 'migrations', + + /* + |-------------------------------------------------------------------------- + | Redis Databases + |-------------------------------------------------------------------------- + | + | Redis is an open source, fast, and advanced key-value store that also + | provides a richer set of commands than a typical key-value systems + | such as APC or Memcached. Laravel makes it easy to dig right in. + | + */ + + 'redis' => [ + + 'cluster' => true, + + 'default' => [ + 'host' => '127.0.0.1', + 'port' => 6379, + 'database' => 0, + ], + + ], + +]; diff --git a/app/config/local/app.php b/app/config/local/app.php index 9e40622..6e7de75 100644 --- a/app/config/local/app.php +++ b/app/config/local/app.php @@ -1,5 +1,5 @@ true -); +return [ + 'debug' => true, +]; diff --git a/app/config/local/cache.php b/app/config/local/cache.php index 0cb53c3..1778fae 100644 --- a/app/config/local/cache.php +++ b/app/config/local/cache.php @@ -1,5 +1,5 @@ 'file', -); \ No newline at end of file +return [ + 'driver' => 'file', +]; diff --git a/app/config/local/queue.php b/app/config/local/queue.php index c447f07..870164f 100644 --- a/app/config/local/queue.php +++ b/app/config/local/queue.php @@ -1,5 +1,5 @@ 'sync' -); +return [ + 'default' => 'sync', +]; diff --git a/app/config/local/session.php b/app/config/local/session.php index 7dfb9c7..b4aab04 100644 --- a/app/config/local/session.php +++ b/app/config/local/session.php @@ -1,7 +1,7 @@ 'native', + 'driver' => 'native', -); \ No newline at end of file +]; diff --git a/app/config/mail.php b/app/config/mail.php index 68961ab..1b05981 100644 --- a/app/config/mail.php +++ b/app/config/mail.php @@ -1,124 +1,124 @@ 'smtp', - - /* - |-------------------------------------------------------------------------- - | SMTP Host Address - |-------------------------------------------------------------------------- - | - | Here you may provide the host address of the SMTP server used by your - | applications. A default option is provided that is compatible with - | the Postmark mail service, which will provide reliable delivery. - | - */ - - 'host' => 'smtp.gmail.com', - - /* - |-------------------------------------------------------------------------- - | SMTP Host Port - |-------------------------------------------------------------------------- - | - | This is the SMTP port used by your application to delivery e-mails to - | users of your application. Like the host we have set this value to - | stay compatible with the Postmark e-mail application by default. - | - */ - - 'port' => 587, - - /* - |-------------------------------------------------------------------------- - | Global "From" Address - |-------------------------------------------------------------------------- - | - | You may wish for all e-mails sent by your application to be sent from - | the same address. Here, you may specify a name and address that is - | used globally for all e-mails that are sent by your application. - | - */ - - 'from' => array('address' => '', 'name' => ''), - - /* - |-------------------------------------------------------------------------- - | E-Mail Encryption Protocol - |-------------------------------------------------------------------------- - | - | Here you may specify the encryption protocol that should be used when - | the application send e-mail messages. A sensible default using the - | transport layer security protocol should provide great security. - | - */ - - 'encryption' => 'tls', - - /* - |-------------------------------------------------------------------------- - | SMTP Server Username - |-------------------------------------------------------------------------- - | - | If your SMTP server requires a username for authentication, you should - | set it here. This will get used to authenticate with your server on - | connection. You may also set the "password" value below this one. - | - */ - - 'username' => '', - - /* - |-------------------------------------------------------------------------- - | SMTP Server Password - |-------------------------------------------------------------------------- - | - | Here you may set the password required by your SMTP server to send out - | messages from your application. This will be given to the server on - | connection so that the application will be able to send messages. - | - */ - - 'password' => '', - - /* - |-------------------------------------------------------------------------- - | Sendmail System Path - |-------------------------------------------------------------------------- - | - | When using the "sendmail" driver to send e-mails, we will need to know - | the path to where Sendmail lives on this server. A default path has - | been provided here, which will work well on most of your systems. - | - */ - - 'sendmail' => '/usr/sbin/sendmail -bs', - - /* - |-------------------------------------------------------------------------- - | Mail "Pretend" - |-------------------------------------------------------------------------- - | - | When this option is enabled, e-mail will not actually be sent over the - | web and will instead be written to your application's logs files so - | you may inspect the message. This is great for local development. - | - */ - - 'pretend' => false, - -); +return [ + + /* + |-------------------------------------------------------------------------- + | Mail Driver + |-------------------------------------------------------------------------- + | + | Laravel supports both SMTP and PHP's "mail" function as drivers for the + | sending of e-mail. You may specify which one you're using throughout + | your application here. By default, Laravel is setup for SMTP mail. + | + | Supported: "smtp", "mail", "sendmail" + | + */ + + 'driver' => 'smtp', + + /* + |-------------------------------------------------------------------------- + | SMTP Host Address + |-------------------------------------------------------------------------- + | + | Here you may provide the host address of the SMTP server used by your + | applications. A default option is provided that is compatible with + | the Postmark mail service, which will provide reliable delivery. + | + */ + + 'host' => 'smtp.gmail.com', + + /* + |-------------------------------------------------------------------------- + | SMTP Host Port + |-------------------------------------------------------------------------- + | + | This is the SMTP port used by your application to delivery e-mails to + | users of your application. Like the host we have set this value to + | stay compatible with the Postmark e-mail application by default. + | + */ + + 'port' => 587, + + /* + |-------------------------------------------------------------------------- + | Global "From" Address + |-------------------------------------------------------------------------- + | + | You may wish for all e-mails sent by your application to be sent from + | the same address. Here, you may specify a name and address that is + | used globally for all e-mails that are sent by your application. + | + */ + + 'from' => ['address' => '', 'name' => ''], + + /* + |-------------------------------------------------------------------------- + | E-Mail Encryption Protocol + |-------------------------------------------------------------------------- + | + | Here you may specify the encryption protocol that should be used when + | the application send e-mail messages. A sensible default using the + | transport layer security protocol should provide great security. + | + */ + + 'encryption' => 'tls', + + /* + |-------------------------------------------------------------------------- + | SMTP Server Username + |-------------------------------------------------------------------------- + | + | If your SMTP server requires a username for authentication, you should + | set it here. This will get used to authenticate with your server on + | connection. You may also set the "password" value below this one. + | + */ + + 'username' => '', + + /* + |-------------------------------------------------------------------------- + | SMTP Server Password + |-------------------------------------------------------------------------- + | + | Here you may set the password required by your SMTP server to send out + | messages from your application. This will be given to the server on + | connection so that the application will be able to send messages. + | + */ + + 'password' => '', + + /* + |-------------------------------------------------------------------------- + | Sendmail System Path + |-------------------------------------------------------------------------- + | + | When using the "sendmail" driver to send e-mails, we will need to know + | the path to where Sendmail lives on this server. A default path has + | been provided here, which will work well on most of your systems. + | + */ + + 'sendmail' => '/usr/sbin/sendmail -bs', + + /* + |-------------------------------------------------------------------------- + | Mail "Pretend" + |-------------------------------------------------------------------------- + | + | When this option is enabled, e-mail will not actually be sent over the + | web and will instead be written to your application's logs files so + | you may inspect the message. This is great for local development. + | + */ + + 'pretend' => false, + +]; diff --git a/app/config/navigation.php b/app/config/navigation.php index 21eb322..5a5276f 100644 --- a/app/config/navigation.php +++ b/app/config/navigation.php @@ -2,48 +2,48 @@ // Defining menu structure here // the items that need to appear when user is logged in should have logged_in set as true -return array( +return [ - 'menu' => array( - array( - 'label' => 'Browse', - 'route' => 'browse.recent', - 'active' => array('/','popular','comments') - ), - array( - 'label' => 'Categories', - 'route' => 'browse.categories', - 'active' => array('categories*') - ), - array( - 'label' => 'Tags', - 'route' => 'browse.tags', - 'active' => array('tags*') - ), - array( - 'label' => 'Create New', - 'route' => 'tricks.new', - 'active' => array('user/tricks/new'), - // 'logged_in' => true - ), - ), + 'menu' => [ + [ + 'label' => 'Browse', + 'route' => 'browse.recent', + 'active' => ['/', 'popular', 'comments'], + ], + [ + 'label' => 'Categories', + 'route' => 'browse.categories', + 'active' => ['categories*'], + ], + [ + 'label' => 'Tags', + 'route' => 'browse.tags', + 'active' => ['tags*'], + ], + [ + 'label' => 'Create New', + 'route' => 'tricks.new', + 'active' => ['user/tricks/new'], + // 'logged_in' => true + ], + ], - 'browse' => array( - array( - 'label' => 'Most recent', - 'route' => 'browse.recent', - 'active' => array('/') - ), - array( - 'label' => 'Most popular', - 'route' => 'browse.popular', - 'active' => array('popular') - ), - array( - 'label' => 'Most commented', - 'route' => 'browse.comments', - 'active' => array('comments') - ), - ), + 'browse' => [ + [ + 'label' => 'Most recent', + 'route' => 'browse.recent', + 'active' => ['/'], + ], + [ + 'label' => 'Most popular', + 'route' => 'browse.popular', + 'active' => ['popular'], + ], + [ + 'label' => 'Most commented', + 'route' => 'browse.comments', + 'active' => ['comments'], + ], + ], -); +]; diff --git a/app/config/packages/itsgoingd/clockwork/config.php b/app/config/packages/itsgoingd/clockwork/config.php index b29c6a1..6890b53 100644 --- a/app/config/packages/itsgoingd/clockwork/config.php +++ b/app/config/packages/itsgoingd/clockwork/config.php @@ -1,6 +1,6 @@ array( + 'filter' => [ 'routes', // It might be a good idea to not collect routes in every request as this might use a lot of disk space - ) + ], -); +]; diff --git a/app/config/packages/thomaswelton/laravel-gravatar/config.php b/app/config/packages/thomaswelton/laravel-gravatar/config.php index 1f86a24..0d3457f 100644 --- a/app/config/packages/thomaswelton/laravel-gravatar/config.php +++ b/app/config/packages/thomaswelton/laravel-gravatar/config.php @@ -1,6 +1,6 @@ 100, - 'default' => 'mm' -); +return [ + 'size' => 100, + 'default' => 'mm', +]; diff --git a/app/config/queue.php b/app/config/queue.php index ac7e000..22bcf56 100644 --- a/app/config/queue.php +++ b/app/config/queue.php @@ -1,60 +1,60 @@ 'iron', - - /* - |-------------------------------------------------------------------------- - | Queue Connections - |-------------------------------------------------------------------------- - | - | Here you may configure the connection information for each server that - | is used by your application. A default configuration has been added - | for each back-end shipped with Laravel. You are free to add more. - | - */ - - 'connections' => array( - - 'sync' => array( - 'driver' => 'sync', - ), - - 'beanstalkd' => array( - 'driver' => 'beanstalkd', - 'host' => 'localhost', - 'queue' => 'default', - ), - - 'sqs' => array( - 'driver' => 'sqs', - 'key' => 'your-public-key', - 'secret' => 'your-secret-key', - 'queue' => 'your-queue-url', - 'region' => 'us-east-1', - ), - - 'iron' => array( - 'driver' => 'iron', - 'project' => '', - 'token' => '', - 'queue' => '', - ), - - ), - -); +return [ + + /* + |-------------------------------------------------------------------------- + | Default Queue Driver + |-------------------------------------------------------------------------- + | + | The Laravel queue API supports a variety of back-ends via an unified + | API, giving you convenient access to each back-end using the same + | syntax for each one. Here you may set the default queue driver. + | + | Supported: "sync", "beanstalkd", "sqs", "iron" + | + */ + + 'default' => 'iron', + + /* + |-------------------------------------------------------------------------- + | Queue Connections + |-------------------------------------------------------------------------- + | + | Here you may configure the connection information for each server that + | is used by your application. A default configuration has been added + | for each back-end shipped with Laravel. You are free to add more. + | + */ + + 'connections' => [ + + 'sync' => [ + 'driver' => 'sync', + ], + + 'beanstalkd' => [ + 'driver' => 'beanstalkd', + 'host' => 'localhost', + 'queue' => 'default', + ], + + 'sqs' => [ + 'driver' => 'sqs', + 'key' => 'your-public-key', + 'secret' => 'your-secret-key', + 'queue' => 'your-queue-url', + 'region' => 'us-east-1', + ], + + 'iron' => [ + 'driver' => 'iron', + 'project' => '', + 'token' => '', + 'queue' => '', + ], + + ], + +]; diff --git a/app/config/remote.php b/app/config/remote.php index f790467..402cc4f 100644 --- a/app/config/remote.php +++ b/app/config/remote.php @@ -1,6 +1,6 @@ array( + 'connections' => [ - 'production' => array( + 'production' => [ 'host' => '', 'username' => '', 'password' => '', 'key' => '', 'root' => '/var/www', - ), + ], - ), + ], /* |-------------------------------------------------------------------------- @@ -49,10 +49,10 @@ | */ - 'groups' => array( + 'groups' => [ - 'web' => array('production') + 'web' => ['production'], - ), + ], -); +]; diff --git a/app/config/session.php b/app/config/session.php index 218344e..7b547ea 100644 --- a/app/config/session.php +++ b/app/config/session.php @@ -1,128 +1,128 @@ 'redis', - - /* - |-------------------------------------------------------------------------- - | Session Lifetime - |-------------------------------------------------------------------------- - | - | Here you may specify the number of minutes that you wish the session - | to be allowed to remain idle before it expires. If you want them - | to immediately expire when the browser closes, set it to zero. - | - */ - - 'lifetime' => 500, - - 'expire_on_close' => false, - - /* - |-------------------------------------------------------------------------- - | Session File Location - |-------------------------------------------------------------------------- - | - | When using the native session driver, we need a location where session - | files may be stored. A default has been set for you but a different - | location may be specified. This is only needed for file sessions. - | - */ - - 'files' => storage_path().'/sessions', - - /* - |-------------------------------------------------------------------------- - | Session Database Connection - |-------------------------------------------------------------------------- - | - | When using the "database" session driver, you may specify the database - | connection that should be used to manage your sessions. This should - | correspond to a connection in your "database" configuration file. - | - */ - - 'connection' => null, - - /* - |-------------------------------------------------------------------------- - | Session Database Table - |-------------------------------------------------------------------------- - | - | When using the "database" session driver, you may specify the table we - | should use to manage the sessions. Of course, a sensible default is - | provided for you; however, you are free to change this as needed. - | - */ - - 'table' => 'sessions', - - /* - |-------------------------------------------------------------------------- - | Session Sweeping Lottery - |-------------------------------------------------------------------------- - | - | Some session drivers must manually sweep their storage location to get - | rid of old sessions from storage. Here are the chances that it will - | happen on a given request. By default, the odds are 2 out of 100. - | - */ - - 'lottery' => array(2, 100), - - /* - |-------------------------------------------------------------------------- - | Session Cookie Name - |-------------------------------------------------------------------------- - | - | Here you may change the name of the cookie used to identify a session - | instance by ID. The name specified here will get used every time a - | new session cookie is created by the framework for every driver. - | - */ - - 'cookie' => 'tricks_session', - - /* - |-------------------------------------------------------------------------- - | Session Cookie Path - |-------------------------------------------------------------------------- - | - | The session cookie path determines the path for which the cookie will - | be regarded as available. Typically, this will be the root path of - | your application but you are free to change this when necessary. - | - */ - - 'path' => '/', - - /* - |-------------------------------------------------------------------------- - | Session Cookie Domain - |-------------------------------------------------------------------------- - | - | Here you may change the domain of the cookie used to identify a session - | in your application. This will determine which domains the cookie is - | available to in your application. A sensible default has been set. - | - */ - - 'domain' => null, +return [ + + /* + |-------------------------------------------------------------------------- + | Default Session Driver + |-------------------------------------------------------------------------- + | + | This option controls the default session "driver" that will be used on + | requests. By default, we will use the lightweight native driver but + | you may specify any of the other wonderful drivers provided here. + | + | Supported: "native", "cookie", "database", "apc", + | "memcached", "redis", "array" + | + */ + + 'driver' => 'redis', + + /* + |-------------------------------------------------------------------------- + | Session Lifetime + |-------------------------------------------------------------------------- + | + | Here you may specify the number of minutes that you wish the session + | to be allowed to remain idle before it expires. If you want them + | to immediately expire when the browser closes, set it to zero. + | + */ + + 'lifetime' => 500, + + 'expire_on_close' => false, + + /* + |-------------------------------------------------------------------------- + | Session File Location + |-------------------------------------------------------------------------- + | + | When using the native session driver, we need a location where session + | files may be stored. A default has been set for you but a different + | location may be specified. This is only needed for file sessions. + | + */ + + 'files' => storage_path().'/sessions', + + /* + |-------------------------------------------------------------------------- + | Session Database Connection + |-------------------------------------------------------------------------- + | + | When using the "database" session driver, you may specify the database + | connection that should be used to manage your sessions. This should + | correspond to a connection in your "database" configuration file. + | + */ + + 'connection' => null, + + /* + |-------------------------------------------------------------------------- + | Session Database Table + |-------------------------------------------------------------------------- + | + | When using the "database" session driver, you may specify the table we + | should use to manage the sessions. Of course, a sensible default is + | provided for you; however, you are free to change this as needed. + | + */ + + 'table' => 'sessions', + + /* + |-------------------------------------------------------------------------- + | Session Sweeping Lottery + |-------------------------------------------------------------------------- + | + | Some session drivers must manually sweep their storage location to get + | rid of old sessions from storage. Here are the chances that it will + | happen on a given request. By default, the odds are 2 out of 100. + | + */ + + 'lottery' => [2, 100], + + /* + |-------------------------------------------------------------------------- + | Session Cookie Name + |-------------------------------------------------------------------------- + | + | Here you may change the name of the cookie used to identify a session + | instance by ID. The name specified here will get used every time a + | new session cookie is created by the framework for every driver. + | + */ + + 'cookie' => 'tricks_session', + + /* + |-------------------------------------------------------------------------- + | Session Cookie Path + |-------------------------------------------------------------------------- + | + | The session cookie path determines the path for which the cookie will + | be regarded as available. Typically, this will be the root path of + | your application but you are free to change this when necessary. + | + */ + + 'path' => '/', + + /* + |-------------------------------------------------------------------------- + | Session Cookie Domain + |-------------------------------------------------------------------------- + | + | Here you may change the domain of the cookie used to identify a session + | in your application. This will determine which domains the cookie is + | available to in your application. A sensible default has been set. + | + */ + + 'domain' => null, /* |-------------------------------------------------------------------------- @@ -136,4 +136,4 @@ */ 'secure' => false, -); +]; diff --git a/app/config/sitemap.php b/app/config/sitemap.php index 1108576..b00f601 100644 --- a/app/config/sitemap.php +++ b/app/config/sitemap.php @@ -1,23 +1,23 @@ array( + 'tricks' => [ 'priority' => '0.9', 'freq' => 'weekly', 'lastMod' => 'created_at', - ), + ], - 'tags' => array( + 'tags' => [ 'priority' => '0.9', 'freq' => 'daily', 'lastMod' => 'created_at', - ), + ], - 'categories' => array( + 'categories' => [ 'priority' => '0.9', 'freq' => 'daily', 'lastMod' => 'created_at', - ), + ], -); +]; diff --git a/app/config/social.php b/app/config/social.php index cde145c..6a2f815 100644 --- a/app/config/social.php +++ b/app/config/social.php @@ -2,7 +2,7 @@ // This config file stores social login Auth keys -return array( +return [ /* |-------------------------------------------------------------------------- @@ -15,12 +15,12 @@ | track security issues and without this the Github login will not work. | */ - 'github' => array( - 'clientId' => '', - 'clientSecret' => '', - 'scopes' => array('user:email'), - 'user_agent' => '' - ), + 'github' => [ + 'clientId' => '', + 'clientSecret' => '', + 'scopes' => ['user:email'], + 'user_agent' => '', + ], /* |-------------------------------------------------------------------------- @@ -30,10 +30,10 @@ | Then copy and paste the PublicKey and the forum name found in the integrations. | */ - 'disqus' => array( + 'disqus' => [ 'publicKey' => '', 'forum' => '', 'requestUrl' => 'http://disqus.com/api/3.0/threads/set.json', 'threadFormat' => 'ident:', - ), -); + ], +]; diff --git a/app/config/testing/cache.php b/app/config/testing/cache.php index 16d3ae2..9f436e2 100644 --- a/app/config/testing/cache.php +++ b/app/config/testing/cache.php @@ -1,20 +1,20 @@ 'array', + 'driver' => 'array', -); \ No newline at end of file +]; diff --git a/app/config/testing/session.php b/app/config/testing/session.php index a18c1b9..17de809 100644 --- a/app/config/testing/session.php +++ b/app/config/testing/session.php @@ -1,21 +1,21 @@ 'array', + 'driver' => 'array', -); \ No newline at end of file +]; diff --git a/app/config/view.php b/app/config/view.php index 34b8f38..0cc2ffb 100644 --- a/app/config/view.php +++ b/app/config/view.php @@ -1,31 +1,31 @@ array(__DIR__.'/../views'), + 'paths' => [__DIR__.'/../views'], - /* - |-------------------------------------------------------------------------- - | Pagination View - |-------------------------------------------------------------------------- - | - | This view will be used to render the pagination link output, and can - | be easily customized here to show any view you like. A clean view - | compatible with Twitter's Bootstrap is given to you by default. - | - */ + /* + |-------------------------------------------------------------------------- + | Pagination View + |-------------------------------------------------------------------------- + | + | This view will be used to render the pagination link output, and can + | be easily customized here to show any view you like. A clean view + | compatible with Twitter's Bootstrap is given to you by default. + | + */ - 'pagination' => 'pagination::slider-3', + 'pagination' => 'pagination::slider-3', -); +]; diff --git a/app/config/workbench.php b/app/config/workbench.php index 56bee52..735a794 100644 --- a/app/config/workbench.php +++ b/app/config/workbench.php @@ -1,31 +1,31 @@ '', + 'name' => '', - /* - |-------------------------------------------------------------------------- - | Workbench Author E-Mail Address - |-------------------------------------------------------------------------- - | - | Like the option above, your e-mail address is used when generating new - | workbench packages. The e-mail is placed in your composer.json file - | automatically after the package is created by the workbench tool. - | - */ + /* + |-------------------------------------------------------------------------- + | Workbench Author E-Mail Address + |-------------------------------------------------------------------------- + | + | Like the option above, your e-mail address is used when generating new + | workbench packages. The e-mail is placed in your composer.json file + | automatically after the package is created by the workbench tool. + | + */ - 'email' => '', + 'email' => '', -); \ No newline at end of file +]; diff --git a/app/database/migrations/2013_11_13_222806_create_users_table.php b/app/database/migrations/2013_11_13_222806_create_users_table.php index 5e0bf32..843d985 100644 --- a/app/database/migrations/2013_11_13_222806_create_users_table.php +++ b/app/database/migrations/2013_11_13_222806_create_users_table.php @@ -2,27 +2,25 @@ use Illuminate\Database\Migrations\Migration; -class CreateUsersTable extends Migration { +class CreateUsersTable extends Migration +{ + public function up() + { + Schema::create('users', function ($table) { + $table->engine = 'InnoDB'; - public function up() - { - Schema::create('users', function($table) - { - $table->engine = 'InnoDB'; - - $table->increments('id')->unsigned(); - $table->string('email')->unique(); - $table->string('photo')->nullable()->default(NULL); - $table->string('username'); - $table->string('password'); - $table->boolean('is_admin')->default(0); - $table->timestamps(); - }); - } - - public function down() - { - Schema::drop('users'); - } + $table->increments('id')->unsigned(); + $table->string('email')->unique(); + $table->string('photo')->nullable()->default(null); + $table->string('username'); + $table->string('password'); + $table->boolean('is_admin')->default(0); + $table->timestamps(); + }); + } + public function down() + { + Schema::drop('users'); + } } diff --git a/app/database/migrations/2013_11_13_222807_create_tricks_table.php b/app/database/migrations/2013_11_13_222807_create_tricks_table.php index 43e8c16..c7bd1a5 100644 --- a/app/database/migrations/2013_11_13_222807_create_tricks_table.php +++ b/app/database/migrations/2013_11_13_222807_create_tricks_table.php @@ -2,18 +2,17 @@ use Illuminate\Database\Migrations\Migration; -class CreateTricksTable extends Migration { - +class CreateTricksTable extends Migration +{ public function up() { - Schema::create('tricks', function($table) - { + Schema::create('tricks', function ($table) { $table->engine = 'InnoDB'; $table->increments('id')->unsigned(); $table->string('title', 140); $table->string('slug')->unique(); - $table->text('description')->nullable()->default(NULL); + $table->text('description')->nullable()->default(null); $table->text('code'); $table->integer('vote_cache')->unsigned()->default(0); $table->integer('view_cache')->unsigned()->default(0); @@ -29,12 +28,10 @@ public function up() public function down() { - Schema::table('tricks', function($table) - { + Schema::table('tricks', function ($table) { $table->dropForeign('tricks_user_id_foreign'); }); Schema::drop('tricks'); } - } diff --git a/app/database/migrations/2013_11_13_222808_create_tags_table.php b/app/database/migrations/2013_11_13_222808_create_tags_table.php index b2a8ed9..bd6678e 100644 --- a/app/database/migrations/2013_11_13_222808_create_tags_table.php +++ b/app/database/migrations/2013_11_13_222808_create_tags_table.php @@ -2,18 +2,17 @@ use Illuminate\Database\Migrations\Migration; -class CreateTagsTable extends Migration { - +class CreateTagsTable extends Migration +{ public function up() { - Schema::create('tags', function($table) - { + Schema::create('tags', function ($table) { $table->engine = 'InnoDB'; $table->increments('id')->unsigned(); $table->string('name'); $table->string('slug')->unique(); - $table->integer('user_id')->unsigned()->nullable()->default(NULL); + $table->integer('user_id')->unsigned()->nullable()->default(null); $table->timestamps(); $table->foreign('user_id') @@ -25,11 +24,9 @@ public function up() public function down() { - Schema::table('tags', function($table) - { + Schema::table('tags', function ($table) { $table->dropForeign('tags_user_id_foreign'); }); Schema::drop('tags'); } - } diff --git a/app/database/migrations/2013_11_13_222809_create_categories_table.php b/app/database/migrations/2013_11_13_222809_create_categories_table.php index eb0bb29..71c2cfc 100644 --- a/app/database/migrations/2013_11_13_222809_create_categories_table.php +++ b/app/database/migrations/2013_11_13_222809_create_categories_table.php @@ -2,18 +2,17 @@ use Illuminate\Database\Migrations\Migration; -class CreateCategoriesTable extends Migration { - +class CreateCategoriesTable extends Migration +{ public function up() { - Schema::create('categories', function($table) - { + Schema::create('categories', function ($table) { $table->engine = 'InnoDB'; $table->increments('id')->unsigned(); $table->string('name'); $table->string('slug')->unique(); - $table->string('description')->nullable()->default(NULL); + $table->string('description')->nullable()->default(null); $table->timestamps(); }); } @@ -22,5 +21,4 @@ public function down() { Schema::drop('categories'); } - } diff --git a/app/database/migrations/2013_11_13_222810_create_votes_table.php b/app/database/migrations/2013_11_13_222810_create_votes_table.php index f75d788..dc88c8e 100644 --- a/app/database/migrations/2013_11_13_222810_create_votes_table.php +++ b/app/database/migrations/2013_11_13_222810_create_votes_table.php @@ -2,12 +2,11 @@ use Illuminate\Database\Migrations\Migration; -class CreateVotesTable extends Migration { - +class CreateVotesTable extends Migration +{ public function up() { - Schema::create('votes', function($table) - { + Schema::create('votes', function ($table) { $table->engine = 'InnoDB'; $table->increments('id')->unsigned(); @@ -29,13 +28,11 @@ public function up() public function down() { - Schema::table('votes', function($table) - { + Schema::table('votes', function ($table) { $table->dropForeign('votes_user_id_foreign'); $table->dropForeign('votes_trick_id_foreign'); }); Schema::drop('votes'); } - } diff --git a/app/database/migrations/2013_11_13_222811_create_tag_trick_table.php b/app/database/migrations/2013_11_13_222811_create_tag_trick_table.php index e51e40b..8e5b78a 100644 --- a/app/database/migrations/2013_11_13_222811_create_tag_trick_table.php +++ b/app/database/migrations/2013_11_13_222811_create_tag_trick_table.php @@ -2,12 +2,11 @@ use Illuminate\Database\Migrations\Migration; -class CreateTagTrickTable extends Migration { - +class CreateTagTrickTable extends Migration +{ public function up() { - Schema::create('tag_trick', function($table) - { + Schema::create('tag_trick', function ($table) { $table->engine = 'InnoDB'; $table->increments('id')->unsigned(); @@ -29,13 +28,11 @@ public function up() public function down() { - Schema::table('tag_trick', function($table) - { + Schema::table('tag_trick', function ($table) { $table->dropForeign('tag_trick_tag_id_foreign'); $table->dropForeign('tag_trick_trick_id_foreign'); }); Schema::drop('tag_trick'); } - } diff --git a/app/database/migrations/2013_11_13_222812_create_category_trick_table.php b/app/database/migrations/2013_11_13_222812_create_category_trick_table.php index b36468b..5904b23 100644 --- a/app/database/migrations/2013_11_13_222812_create_category_trick_table.php +++ b/app/database/migrations/2013_11_13_222812_create_category_trick_table.php @@ -2,12 +2,11 @@ use Illuminate\Database\Migrations\Migration; -class CreateCategoryTrickTable extends Migration { - +class CreateCategoryTrickTable extends Migration +{ public function up() { - Schema::create('category_trick', function($table) - { + Schema::create('category_trick', function ($table) { $table->engine = 'InnoDB'; $table->increments('id')->unsigned(); @@ -29,12 +28,10 @@ public function up() public function down() { - Schema::table('category_trick', function($table) - { + Schema::table('category_trick', function ($table) { $table->dropForeign('category_trick_category_id_foreign'); $table->dropForeign('category_trick_trick_id_foreign'); }); Schema::drop('category_trick'); } - } diff --git a/app/database/migrations/2013_11_13_222813_create_profiles_table.php b/app/database/migrations/2013_11_13_222813_create_profiles_table.php index a9247ad..0e52398 100644 --- a/app/database/migrations/2013_11_13_222813_create_profiles_table.php +++ b/app/database/migrations/2013_11_13_222813_create_profiles_table.php @@ -2,27 +2,26 @@ use Illuminate\Database\Migrations\Migration; -class CreateProfilesTable extends Migration { - +class CreateProfilesTable extends Migration +{ public function up() { - Schema::create('profiles', function($table) - { + Schema::create('profiles', function ($table) { $table->engine = 'InnoDB'; $table->increments('id')->unsigned(); $table->string('uid'); $table->integer('user_id')->unsigned(); - $table->string('username')->nullable()->default(NULL); - $table->string('name')->nullable()->default(NULL); - $table->string('email')->nullable()->default(NULL); - $table->string('first_name')->nullable()->default(NULL); - $table->string('last_name')->nullable()->default(NULL); - $table->string('location')->nullable()->default(NULL); - $table->string('description')->nullable()->default(NULL); - $table->string('image_url')->nullable()->default(NULL); - $table->string('access_token')->nullable()->default(NULL); - $table->string('access_token_secret')->nullable()->default(NULL); + $table->string('username')->nullable()->default(null); + $table->string('name')->nullable()->default(null); + $table->string('email')->nullable()->default(null); + $table->string('first_name')->nullable()->default(null); + $table->string('last_name')->nullable()->default(null); + $table->string('location')->nullable()->default(null); + $table->string('description')->nullable()->default(null); + $table->string('image_url')->nullable()->default(null); + $table->string('access_token')->nullable()->default(null); + $table->string('access_token_secret')->nullable()->default(null); $table->timestamps(); $table->foreign('user_id') @@ -34,12 +33,10 @@ public function up() public function down() { - Schema::table('profiles', function($table) - { + Schema::table('profiles', function ($table) { $table->dropForeign('profiles_user_id_foreign'); }); Schema::drop('profiles'); } - } diff --git a/app/database/migrations/2013_11_20_072925_add_order_to_category_table.php b/app/database/migrations/2013_11_20_072925_add_order_to_category_table.php index 6c7c1ea..0065fb7 100644 --- a/app/database/migrations/2013_11_20_072925_add_order_to_category_table.php +++ b/app/database/migrations/2013_11_20_072925_add_order_to_category_table.php @@ -2,32 +2,29 @@ use Illuminate\Database\Migrations\Migration; -class AddOrderToCategoryTable extends Migration { - - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::table('categories', function($table) - { - $table->integer('order')->unsigned()->after('description'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('categories', function($table) - { - $table->dropColumn('order'); - }); - } +class AddOrderToCategoryTable extends Migration +{ + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::table('categories', function ($table) { + $table->integer('order')->unsigned()->after('description'); + }); + } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('categories', function ($table) { + $table->dropColumn('order'); + }); + } } diff --git a/app/database/migrations/2013_11_22_072925_add_spam_to_tricks_table.php b/app/database/migrations/2013_11_22_072925_add_spam_to_tricks_table.php index 8432630..94dcd64 100644 --- a/app/database/migrations/2013_11_22_072925_add_spam_to_tricks_table.php +++ b/app/database/migrations/2013_11_22_072925_add_spam_to_tricks_table.php @@ -2,32 +2,29 @@ use Illuminate\Database\Migrations\Migration; -class AddSpamToTricksTable extends Migration { - - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::table('tricks', function($table) - { - $table->boolean('spam')->default(0)->after('id'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('tricks', function($table) - { - $table->dropColumn('spam'); - }); - } +class AddSpamToTricksTable extends Migration +{ + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::table('tricks', function ($table) { + $table->boolean('spam')->default(0)->after('id'); + }); + } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('tricks', function ($table) { + $table->dropColumn('spam'); + }); + } } diff --git a/app/database/migrations/2013_11_25_202456_create_password_reminders_table.php b/app/database/migrations/2013_11_25_202456_create_password_reminders_table.php index 68a0674..aae38cb 100644 --- a/app/database/migrations/2013_11_25_202456_create_password_reminders_table.php +++ b/app/database/migrations/2013_11_25_202456_create_password_reminders_table.php @@ -1,33 +1,31 @@ string('email')->index(); - $table->string('token')->index(); - $table->timestamp('created_at'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::drop('password_reminders'); - } +class CreatePasswordRemindersTable extends Migration +{ + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::create('password_reminders', function (Blueprint $table) { + $table->string('email')->index(); + $table->string('token')->index(); + $table->timestamp('created_at'); + }); + } -} \ No newline at end of file + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('password_reminders'); + } +} diff --git a/app/database/migrations/2014_04_17_181442_add_remember_to_user_table.php b/app/database/migrations/2014_04_17_181442_add_remember_to_user_table.php index 6e7915e..12ea78e 100644 --- a/app/database/migrations/2014_04_17_181442_add_remember_to_user_table.php +++ b/app/database/migrations/2014_04_17_181442_add_remember_to_user_table.php @@ -1,34 +1,30 @@ string('remember_token',100)->nullable()->after('id'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('users', function($table) - { - $table->dropColumn('remember_token'); - }); - } +class AddRememberToUserTable extends Migration +{ + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::table('users', function ($table) { + $table->string('remember_token', 100)->nullable()->after('id'); + }); + } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('users', function ($table) { + $table->dropColumn('remember_token'); + }); + } } diff --git a/app/database/seeds/CategoriesTableSeeder.php b/app/database/seeds/CategoriesTableSeeder.php index 2e90e11..b10b3cd 100644 --- a/app/database/seeds/CategoriesTableSeeder.php +++ b/app/database/seeds/CategoriesTableSeeder.php @@ -1,7 +1,7 @@ insert($categories); DB::table('category_trick')->insert([ - [ 'category_id' => '2', 'trick_id' => '1' ], - [ 'category_id' => '1', 'trick_id' => '2' ], - [ 'category_id' => '2', 'trick_id' => '3' ], + ['category_id' => '2', 'trick_id' => '1'], + ['category_id' => '1', 'trick_id' => '2'], + ['category_id' => '2', 'trick_id' => '3'], ]); } } - - diff --git a/app/database/seeds/DatabaseSeeder.php b/app/database/seeds/DatabaseSeeder.php index 4e47bda..bef4ef5 100644 --- a/app/database/seeds/DatabaseSeeder.php +++ b/app/database/seeds/DatabaseSeeder.php @@ -1,20 +1,19 @@ call('UsersTableSeeder'); - $this->call('TricksTableSeeder'); - $this->call('CategoriesTableSeeder'); - $this->call('TagsTableSeeder'); - } +class DatabaseSeeder extends Seeder +{ + /** + * Run the database seeds. + * + * @return void + */ + public function run() + { + Eloquent::unguard(); + $this->call('UsersTableSeeder'); + $this->call('TricksTableSeeder'); + $this->call('CategoriesTableSeeder'); + $this->call('TagsTableSeeder'); + } } diff --git a/app/database/seeds/TagsTableSeeder.php b/app/database/seeds/TagsTableSeeder.php index 4a6eaf9..8625a26 100644 --- a/app/database/seeds/TagsTableSeeder.php +++ b/app/database/seeds/TagsTableSeeder.php @@ -1,7 +1,7 @@ insert($tags); DB::table('tag_trick')->insert([ - [ 'tag_id' => '1', 'trick_id' => '1' ], - [ 'tag_id' => '2', 'trick_id' => '2' ], - [ 'tag_id' => '1', 'trick_id' => '3' ], - [ 'tag_id' => '3', 'trick_id' => '3' ], + ['tag_id' => '1', 'trick_id' => '1'], + ['tag_id' => '2', 'trick_id' => '2'], + ['tag_id' => '1', 'trick_id' => '3'], + ['tag_id' => '3', 'trick_id' => '3'], ]); } } diff --git a/app/database/seeds/TricksTableSeeder.php b/app/database/seeds/TricksTableSeeder.php index 89711bb..d286f7d 100644 --- a/app/database/seeds/TricksTableSeeder.php +++ b/app/database/seeds/TricksTableSeeder.php @@ -1,29 +1,28 @@ '1', - 'title' => 'Display all SQL executed in Eloquent', - 'slug' => 'display-all-sql-executed-in-eloquent', - 'description' => 'Put this in your routes.php file and you will see the SQL that Eloquent is executing when you go to pages that have any sort of access to Eloquent models. This helps a lot when debugging SQL in Laravel.', - 'code' => '// Display all SQL executed in Eloquent +class TricksTableSeeder extends Seeder +{ + public function run() + { + $tricks = [ + [ + 'id' => '1', + 'title' => 'Display all SQL executed in Eloquent', + 'slug' => 'display-all-sql-executed-in-eloquent', + 'description' => 'Put this in your routes.php file and you will see the SQL that Eloquent is executing when you go to pages that have any sort of access to Eloquent models. This helps a lot when debugging SQL in Laravel.', + 'code' => '// Display all SQL executed in Eloquent Event::listen(\'illuminate.query\', function($query) { var_dump($query); });', - 'user_id' => '1' - ], - [ - 'id' => '2', - 'title' => 'Dynamic View assignments', - 'slug' => 'dynamic-view-assignments', - 'description' => 'Laravel offers a dynamic interface for assigning certain data. This can be used e.g. for adding a dynamic \'where\' to your Eloquent queries. However, not everyone know that this same trick also works on View assignments!', - 'code' => '// In Eloquent, you can assigned \'where\' clauses dynamically + 'user_id' => '1', + ], + [ + 'id' => '2', + 'title' => 'Dynamic View assignments', + 'slug' => 'dynamic-view-assignments', + 'description' => 'Laravel offers a dynamic interface for assigning certain data. This can be used e.g. for adding a dynamic \'where\' to your Eloquent queries. However, not everyone know that this same trick also works on View assignments!', + 'code' => '// In Eloquent, you can assigned \'where\' clauses dynamically Post::whereSlug(\'slug\')->get(); // Results in ...WHERE `slug` = \'slug\'... @@ -31,14 +30,14 @@ public function run() View::make(\'posts.index\')->withPosts($posts); // Same as: View::make(\'posts.index\')->with(\'posts\', $posts);', - 'user_id' => '2', - ], - [ - 'id' => '3', - 'title' => 'Eager loading constraints', - 'slug' => 'eager-loading-constraints', - 'description' => 'Ever find yourself wanting to only find models that have a certain relationship matching certain conditions? Laravel 4.1 makes this really easy, and introduces great eager loading constraints!', - 'code' => ' '2', + ], + [ + 'id' => '3', + 'title' => 'Eager loading constraints', + 'slug' => 'eager-loading-constraints', + 'description' => 'Ever find yourself wanting to only find models that have a certain relationship matching certain conditions? Laravel 4.1 makes this really easy, and introduces great eager loading constraints!', + 'code' => 'where(\'name\', \'=\', \'laravel\'); -})->where(\'published_at\', '>=', Carbon\Carbon::now()->subWeek())->get();', - 'user_id' => '2', - ] - ]; - - DB::table('tricks')->insert($tricks); - } +})->where(\'published_at\', ' >= ', Carbon\Carbon::now()->subWeek())->get();', + 'user_id' => '2', + ], + ]; + DB::table('tricks')->insert($tricks); + } } diff --git a/app/database/seeds/UsersTableSeeder.php b/app/database/seeds/UsersTableSeeder.php index b65ae9f..9844bcc 100644 --- a/app/database/seeds/UsersTableSeeder.php +++ b/app/database/seeds/UsersTableSeeder.php @@ -1,27 +1,26 @@ truncate(); + // DB::table('users')->truncate(); $users = [ [ 'username' => 'msurguy', 'email' => 'user1@example.com', 'password' => Hash::make('password'), - 'is_admin' => '1' + 'is_admin' => '1', ], [ 'username' => 'stidges', 'email' => 'user2@example.com', 'password' => Hash::make('password'), - 'is_admin' => '1' - ] + 'is_admin' => '1', + ], ]; DB::table('users')->insert($users); } - } diff --git a/app/filters.php b/app/filters.php index 6fd80c3..711b8cb 100644 --- a/app/filters.php +++ b/app/filters.php @@ -12,12 +12,11 @@ */ App::before(function ($request) { - // + // }); - App::after(function ($request, $response) { - // + // }); /* @@ -31,22 +30,20 @@ | */ - Route::filter('admin', function () { - if (Auth::guest() || (Auth::check() && ! Auth::user()->isAdmin())) { - return Redirect::guest('login'); - } + if (Auth::guest() || (Auth::check() && !Auth::user()->isAdmin())) { + return Redirect::guest('login'); + } }); -Route::filter('auth', function() { - if (Auth::guest()) { - return Redirect::guest('login'); - } +Route::filter('auth', function () { + if (Auth::guest()) { + return Redirect::guest('login'); + } }); - Route::filter('auth.basic', function () { - return Auth::basic(); + return Auth::basic(); }); /* @@ -61,9 +58,9 @@ */ Route::filter('guest', function () { - if (Auth::check()) { - return Redirect::to('/'); - } + if (Auth::check()) { + return Redirect::to('/'); + } }); /* @@ -78,9 +75,9 @@ */ Route::filter('csrf', function () { - if (Session::token() != Input::get('_token')) { - throw new Illuminate\Session\TokenMismatchException; - } + if (Session::token() != Input::get('_token')) { + throw new Illuminate\Session\TokenMismatchException(); + } }); Route::filter('trick.view_throttle', 'Tricks\Filters\ViewThrottleFilter'); diff --git a/app/lang/en/admin.php b/app/lang/en/admin.php index 94261b3..73d2465 100644 --- a/app/lang/en/admin.php +++ b/app/lang/en/admin.php @@ -1,42 +1,43 @@ - 'Editing category', - 'viewing_category' => 'Viewing category', - 'category_for_tricks' => 'Categories for Laravel tricks', - 'add_new_category' => 'Add new Category', - 'title' => 'Title', - 'name' => 'Name', - 'username' => 'Username', - 'description' => 'Description', - 'num_of_tricks' => '# of Tricks', - 'actions' => 'Actions', - 'cancel' => 'Cancel', - 'edit' => 'Edit', - 'create' => 'Create', - 'keep' => 'Keep', - 'tag' => 'Tag', - 'add_new_tag' => 'Add new Tag', - 'viewing_users' => 'Viewing Users', - 'tag_will_be_deleted' => 'This Tag will be deleted!', - 'all_tags' => 'All Tags', - 'adding_new_tag' => 'Adding new Tag', - 'delete' => 'Delete', - 'viewing_tags' => 'Viewing Tags', - 'adding_new_category' => 'Adding new category', - 'editing_a_category' => 'Editing a category', - 'editing_tag' => 'Editing tag', - 'editing_a_tag' => 'Editing a tag', - 'save_category' => 'Save category', - 'save_tag' => 'Save tag', - 'please_fix_errors' => 'Please fix the errors below:', - 'are_you_sure' => 'Are you sure?', - 'category_will_be_deleted' => 'This Category will be deleted!', - 'showing_all_users' => 'Showing all users', - 'avatar' => 'Avatar', - 'email' => 'Email', - 'tricks' => 'Tricks', - 'date_registered' => 'Date Registered', - 'github_profile' => 'Github Profile?', - -); + +return [ + 'editing_category' => 'Editing category', + 'viewing_category' => 'Viewing category', + 'category_for_tricks' => 'Categories for Laravel tricks', + 'add_new_category' => 'Add new Category', + 'title' => 'Title', + 'name' => 'Name', + 'username' => 'Username', + 'description' => 'Description', + 'num_of_tricks' => '# of Tricks', + 'actions' => 'Actions', + 'cancel' => 'Cancel', + 'edit' => 'Edit', + 'create' => 'Create', + 'keep' => 'Keep', + 'tag' => 'Tag', + 'add_new_tag' => 'Add new Tag', + 'viewing_users' => 'Viewing Users', + 'tag_will_be_deleted' => 'This Tag will be deleted!', + 'all_tags' => 'All Tags', + 'adding_new_tag' => 'Adding new Tag', + 'delete' => 'Delete', + 'viewing_tags' => 'Viewing Tags', + 'adding_new_category' => 'Adding new category', + 'editing_a_category' => 'Editing a category', + 'editing_tag' => 'Editing tag', + 'editing_a_tag' => 'Editing a tag', + 'save_category' => 'Save category', + 'save_tag' => 'Save tag', + 'please_fix_errors' => 'Please fix the errors below:', + 'are_you_sure' => 'Are you sure?', + 'category_will_be_deleted' => 'This Category will be deleted!', + 'showing_all_users' => 'Showing all users', + 'avatar' => 'Avatar', + 'email' => 'Email', + 'tricks' => 'Tricks', + 'date_registered' => 'Date Registered', + 'github_profile' => 'Github Profile?', + +]; diff --git a/app/lang/en/browse.php b/app/lang/en/browse.php index 6b8010c..0db4196 100644 --- a/app/lang/en/browse.php +++ b/app/lang/en/browse.php @@ -1,18 +1,19 @@ - ':title | Laravel-Tricks.com', - 'browsing_most_recent_tricks' => 'Browsing Most Recent Laravel Tricks', - 'browsing_most_popular_tricks' => 'Browsing Most Popular Laravel Tricks', - 'browsing_tag' => 'Browsing Tag ":tag"', - 'tag' => 'Tag ":tag"', - 'tags' => 'Tags', - 'category' => 'Category ":category"', - 'categories' => 'Categories', - 'recent' => 'Recent', - 'popular' => 'Popular', - 'most_commented' => 'Most commented', - 'browsing_most_commented_tricks' => 'Browsing Most Commented Laravel Tricks', - 'browsing_category' => 'Browsing Category ":category"', - -); \ No newline at end of file + +return [ + 'site_title' => ':title | Laravel-Tricks.com', + 'browsing_most_recent_tricks' => 'Browsing Most Recent Laravel Tricks', + 'browsing_most_popular_tricks' => 'Browsing Most Popular Laravel Tricks', + 'browsing_tag' => 'Browsing Tag ":tag"', + 'tag' => 'Tag ":tag"', + 'tags' => 'Tags', + 'category' => 'Category ":category"', + 'categories' => 'Categories', + 'recent' => 'Recent', + 'popular' => 'Popular', + 'most_commented' => 'Most commented', + 'browsing_most_commented_tricks' => 'Browsing Most Commented Laravel Tricks', + 'browsing_category' => 'Browsing Category ":category"', + +]; diff --git a/app/lang/en/emails.php b/app/lang/en/emails.php index 00ff052..2358dec 100644 --- a/app/lang/en/emails.php +++ b/app/lang/en/emails.php @@ -1,7 +1,8 @@ - 'Password Reset', - 'reset_password_here' => 'To reset your password, complete this form: :form_link', - -); \ No newline at end of file + +return [ + 'password_reset' => 'Password Reset', + 'reset_password_here' => 'To reset your password, complete this form: :form_link', + +]; diff --git a/app/lang/en/feeds.php b/app/lang/en/feeds.php index ef45f82..d9e4df4 100644 --- a/app/lang/en/feeds.php +++ b/app/lang/en/feeds.php @@ -1,10 +1,11 @@ - 'Laravel-Tricks', - 'link' => 'http://www.laravel-tricks.com', - 'sub_title' => 'Laravel tricks is a website that aggregates useful tips and tricks for Laravel PHP framework', - 'author' => ' + +return [ + 'title' => 'Laravel-Tricks', + 'link' => 'http://www.laravel-tricks.com', + 'sub_title' => 'Laravel tricks is a website that aggregates useful tips and tricks for Laravel PHP framework', + 'author' => ' Maks Surguy http://twitter.com/msurguy @@ -13,5 +14,4 @@ Stidges http://twitter.com/stidges ', -); - +]; diff --git a/app/lang/en/home.php b/app/lang/en/home.php index 8003c49..36ea247 100644 --- a/app/lang/en/home.php +++ b/app/lang/en/home.php @@ -1,49 +1,49 @@ - 'About Laravel-Tricks website', - 'about_title' => 'About Laravel tricks', - 'error' => 'Error', - 'error_title' => 'Whoops... That\'s an error...', - 'registration' => 'Registration', - 'errors_during_registration' => 'There were errors during registration:', - 'password' => 'Password', - 'password_placeholder' => 'Password...', - 'or' => 'OR', - 'already_have_an_account' => 'Already have an account?', - 'confirm_password' => 'Confirm Password', - 'confirm_password_placeholder' => 'Confirm Password...', - 'email' => 'Email', - 'email_placeholder' => 'Email...', - 'username' => 'Username', - 'username_placeholder' => 'Username...', - 'password_placeholder' => 'Password...', - 'register' => 'Register', - 'register_with_github' => 'Register with Github', - 'github_mail_not_verified' => 'You don\'t have any verified emails in your Github profile, please register using email', - 'welcome' => 'Welcome', - 'forgot_your_password' => 'Forgot your password?', - 'do_not_have_account_yet' => 'Don\'t have an account yet?', - 'login' => 'Login', - 'login_with_github' => 'Login with Github', - 'login_title' => 'Login', - 'email_or_password_incorrect' => 'E-mail or password was incorrect, please try again', - 'password_has_been_reset' => 'Your password has been reset, please log in', - 'remember_me' => 'Remember me', - 'latest_tricks' => 'Latest tricks', - 'share_title' => 'Share & follow', - 'share_twitter' => 'Share on Twitter', - 'twitter_text' => 'Tips and Tricks for @laravelphp from @laraveltricks #php #dev #tips', - 'share_facebook' => 'Share on Facebook', - 'facebook_text' => 'Useful Tips and Tricks for Laravel PHP framework', - 'about_what_is_this' => '

What is this

+ +return [ + 'about_tricks_website' => 'About Laravel-Tricks website', + 'about_title' => 'About Laravel tricks', + 'error' => 'Error', + 'error_title' => 'Whoops... That\'s an error...', + 'registration' => 'Registration', + 'errors_during_registration' => 'There were errors during registration:', + 'password' => 'Password', + 'password_placeholder' => 'Password...', + 'or' => 'OR', + 'already_have_an_account' => 'Already have an account?', + 'confirm_password' => 'Confirm Password', + 'confirm_password_placeholder' => 'Confirm Password...', + 'email' => 'Email', + 'email_placeholder' => 'Email...', + 'username' => 'Username', + 'username_placeholder' => 'Username...', + 'password_placeholder' => 'Password...', + 'register' => 'Register', + 'register_with_github' => 'Register with Github', + 'github_mail_not_verified' => 'You don\'t have any verified emails in your Github profile, please register using email', + 'welcome' => 'Welcome', + 'forgot_your_password' => 'Forgot your password?', + 'do_not_have_account_yet' => 'Don\'t have an account yet?', + 'login' => 'Login', + 'login_with_github' => 'Login with Github', + 'login_title' => 'Login', + 'email_or_password_incorrect' => 'E-mail or password was incorrect, please try again', + 'password_has_been_reset' => 'Your password has been reset, please log in', + 'remember_me' => 'Remember me', + 'latest_tricks' => 'Latest tricks', + 'share_title' => 'Share & follow', + 'share_twitter' => 'Share on Twitter', + 'twitter_text' => 'Tips and Tricks for @laravelphp from @laraveltricks #php #dev #tips', + 'share_facebook' => 'Share on Facebook', + 'facebook_text' => 'Useful Tips and Tricks for Laravel PHP framework', + 'about_what_is_this' => '

What is this

Laravel Tricks was created to help Laravel community find and share interesting ways of using Laravel framework

The idea is simple: When you work with Laravel long enough you find some cool ways of using it, and to other people they might seem as "tricks" so we thought to create a centralized place for all Laravel users to share those findings.

', - 'about_who' => '

Who?

+ 'about_who' => '

Who?

Laravel Tricks website was created by Stidges and Maks Surguy in November 2013

Want the source?

- The source of this website is available on Github.' -); - + The source of this website is available on Github.', +]; diff --git a/app/lang/en/layouts.php b/app/lang/en/layouts.php index 59eb549..aada5d1 100644 --- a/app/lang/en/layouts.php +++ b/app/lang/en/layouts.php @@ -1,10 +1,9 @@ - 'Laravel tricks is a website that aggregates useful tips and tricks for Laravel PHP framework', - 'meta_author' => 'Stidges, @stidges and Maks Surguy, @msurguy', - 'site_title' => 'Laravel-Tricks.com', - -); +return [ + 'meta_description' => 'Laravel tricks is a website that aggregates useful tips and tricks for Laravel PHP framework', + 'meta_author' => 'Stidges, @stidges and Maks Surguy, @msurguy', + 'site_title' => 'Laravel-Tricks.com', +]; diff --git a/app/lang/en/pagination.php b/app/lang/en/pagination.php index eb9be3b..43834bb 100644 --- a/app/lang/en/pagination.php +++ b/app/lang/en/pagination.php @@ -1,20 +1,21 @@ - '« Previous', + /* + |-------------------------------------------------------------------------- + | Pagination Language Lines + |-------------------------------------------------------------------------- + | + | The following language lines are used by the paginator library to build + | the simple pagination links. You are free to change them to anything + | you want to customize your views to better match your application. + | + */ - 'next' => 'Next »', + 'previous' => '« Previous', -); \ No newline at end of file + 'next' => 'Next »', + +]; diff --git a/app/lang/en/partials.php b/app/lang/en/partials.php index 75c901d..36fc6fa 100644 --- a/app/lang/en/partials.php +++ b/app/lang/en/partials.php @@ -1,21 +1,21 @@ - 'Website built with Laravel by Stidges & Maks Surguy', - 'about' => 'About', - 'register' => 'Register', - 'login' => 'Login', - 'profile' => 'Profile', - 'my_tricks' => 'My Tricks', - 'my_profile' => 'My Profile', - 'toggle_navigation' => 'Toggle navigation', - 'search_placeholder' => 'Search...', - 'my_favorites' => 'My Favorites', - 'settings' => 'Settings', - 'logout' => 'Logout', - 'footer_links' => ' + +return [ + 'credits' => 'Website built with Laravel by Stidges & Maks Surguy', + 'about' => 'About', + 'register' => 'Register', + 'login' => 'Login', + 'profile' => 'Profile', + 'my_tricks' => 'My Tricks', + 'my_profile' => 'My Profile', + 'toggle_navigation' => 'Toggle navigation', + 'search_placeholder' => 'Search...', + 'my_favorites' => 'My Favorites', + 'settings' => 'Settings', + 'logout' => 'Logout', + 'footer_links' => ' | ', - -); +]; diff --git a/app/lang/en/password.php b/app/lang/en/password.php index 69bf414..427a8fb 100644 --- a/app/lang/en/password.php +++ b/app/lang/en/password.php @@ -1,18 +1,18 @@ - 'Reset password', - 'resetting_password' => 'Resetting password', - 'mail_has_been_sent' => 'An e-mail with the password reset link has been sent.', - 'email' => 'Email', - 'email_reset_placeholder' => 'Email', - 'new_password' => 'New Password', - 'confirm_password' => 'Confirm New Password', - 'reset' => 'Reset password', - 'remember_password' => 'Remembered password? Login', - 'invalid_password_or_mail' => 'The password reset token or email is invalid', - 'resetting_password' => 'Resetting password', - 'email_placeholder' => 'E-mail to send password reminder...', - -); +return [ + 'reset_password' => 'Reset password', + 'resetting_password' => 'Resetting password', + 'mail_has_been_sent' => 'An e-mail with the password reset link has been sent.', + 'email' => 'Email', + 'email_reset_placeholder' => 'Email', + 'new_password' => 'New Password', + 'confirm_password' => 'Confirm New Password', + 'reset' => 'Reset password', + 'remember_password' => 'Remembered password? Login', + 'invalid_password_or_mail' => 'The password reset token or email is invalid', + 'resetting_password' => 'Resetting password', + 'email_placeholder' => 'E-mail to send password reminder...', + +]; diff --git a/app/lang/en/reminders.php b/app/lang/en/reminders.php index 71514a1..6d2cc48 100644 --- a/app/lang/en/reminders.php +++ b/app/lang/en/reminders.php @@ -1,6 +1,6 @@ "Passwords must be at least six characters and match the confirmation.", + 'password' => 'Passwords must be at least six characters and match the confirmation.', - "user" => "We can't find a user with that e-mail address.", + 'user' => "We can't find a user with that e-mail address.", - "token" => "This password reset token is invalid.", + 'token' => 'This password reset token is invalid.', - "sent" => "Password reminder sent!", - - "your_password_reminder" => "Your Password Reminder for Laravel Tricks", + 'sent' => 'Password reminder sent!', -); + 'your_password_reminder' => 'Your Password Reminder for Laravel Tricks', + +]; diff --git a/app/lang/en/search.php b/app/lang/en/search.php index e031a37..8fb8993 100644 --- a/app/lang/en/search.php +++ b/app/lang/en/search.php @@ -1,8 +1,8 @@ - 'Search results for ":term"', - 'please_provide_search_term' => 'Please provide a search term', - -); +return [ + 'search_results_for' => 'Search results for ":term"', + 'please_provide_search_term' => 'Please provide a search term', + +]; diff --git a/app/lang/en/tricks.php b/app/lang/en/tricks.php index f6ac34c..b8fa005 100644 --- a/app/lang/en/tricks.php +++ b/app/lang/en/tricks.php @@ -1,25 +1,26 @@ - 'Trick', - 'submitted' => 'Submitted :timeago :categories', - 'are_you_sure' => 'Are you sure?', - 'cancel' => 'Cancel', - 'creating_new_trick' => 'Creating a new trick', - 'update_trick' => 'Update Trick', - 'delete' => 'Delete', - 'title' => 'Title', - 'no_tricks_found' => 'Sorry, but I couldn\'t find any tricks for you!', - 'tag_trick_placeholder' => 'Tag this trick', - 'categorize_trick_placeholder' => 'Choose Categories for this trick', - 'title_placeholder' => 'Name this trick', - 'description' => 'Description', - 'remove_trick' => 'Remove trick', - 'trick_description_placeholder' => 'Give detailed description of the trick', - 'trick_code' => 'Trick code:', - 'save_trick' => 'Save Trick', - 'editing_trick' => 'Editing trick', - 'errors_while_editing' => 'There were errors while editing this trick:', - 'errors_while_creating' => 'There were errors while creating this trick:', - 'are_you_sure_text' => 'Are you sure you want to remove this trick?', -); \ No newline at end of file + +return [ + 'trick' => 'Trick', + 'submitted' => 'Submitted :timeago :categories', + 'are_you_sure' => 'Are you sure?', + 'cancel' => 'Cancel', + 'creating_new_trick' => 'Creating a new trick', + 'update_trick' => 'Update Trick', + 'delete' => 'Delete', + 'title' => 'Title', + 'no_tricks_found' => 'Sorry, but I couldn\'t find any tricks for you!', + 'tag_trick_placeholder' => 'Tag this trick', + 'categorize_trick_placeholder' => 'Choose Categories for this trick', + 'title_placeholder' => 'Name this trick', + 'description' => 'Description', + 'remove_trick' => 'Remove trick', + 'trick_description_placeholder' => 'Give detailed description of the trick', + 'trick_code' => 'Trick code:', + 'save_trick' => 'Save Trick', + 'editing_trick' => 'Editing trick', + 'errors_while_editing' => 'There were errors while editing this trick:', + 'errors_while_creating' => 'There were errors while creating this trick:', + 'are_you_sure_text' => 'Are you sure you want to remove this trick?', +]; diff --git a/app/lang/en/user.php b/app/lang/en/user.php index 9f77ba2..300f3ff 100644 --- a/app/lang/en/user.php +++ b/app/lang/en/user.php @@ -1,34 +1,35 @@ - 'Account Settings', - 'my_favorites' => 'My Favorites', - 'profile' => 'Profile', - 'settings' => 'Settings', - 'welcome' => 'Welcome to Laravel tricks!', - 'welcome_subtitle' => 'Explore the tricks, create and share some of your own!', - 'my_tricks' => 'My tricks', - 'create_new' => 'Create new', - 'submitted_tricks' => 'Submitted tricks', - 'last_trick' => 'Last trick:', - 'total_tricks' => 'Total tricks:', - 'joined' => 'Joined:', - 'upload' => 'Upload', - 'crop_picture' => 'Crop the picture', - 'reset_form' => 'Reset form', - 'update' => 'Update', - 'confirm_password' => 'Confirm Password', - 'password' => 'Password', - 'new_password' => 'New Password', - 'uploading' => 'Uploading', - 'username' => 'Username', - 'user_settings' => 'User settings', - 'back_to_profile' => 'Back to profile', - 'choose' => 'Choose', - 'notice' => 'Notice:', - 'notice_password' => 'Please create a password if you\'d like to login with email as well', - 'profile_picture' => 'Profile Picture', - 'settings_updated' => 'Your settings have been updated!', - 'email' => 'Email', - 'github_user_already_taken' => 'Your Github username has already been taken on this site, please choose a different username', -); + +return [ + 'account_settings' => 'Account Settings', + 'my_favorites' => 'My Favorites', + 'profile' => 'Profile', + 'settings' => 'Settings', + 'welcome' => 'Welcome to Laravel tricks!', + 'welcome_subtitle' => 'Explore the tricks, create and share some of your own!', + 'my_tricks' => 'My tricks', + 'create_new' => 'Create new', + 'submitted_tricks' => 'Submitted tricks', + 'last_trick' => 'Last trick:', + 'total_tricks' => 'Total tricks:', + 'joined' => 'Joined:', + 'upload' => 'Upload', + 'crop_picture' => 'Crop the picture', + 'reset_form' => 'Reset form', + 'update' => 'Update', + 'confirm_password' => 'Confirm Password', + 'password' => 'Password', + 'new_password' => 'New Password', + 'uploading' => 'Uploading', + 'username' => 'Username', + 'user_settings' => 'User settings', + 'back_to_profile' => 'Back to profile', + 'choose' => 'Choose', + 'notice' => 'Notice:', + 'notice_password' => 'Please create a password if you\'d like to login with email as well', + 'profile_picture' => 'Profile Picture', + 'settings_updated' => 'Your settings have been updated!', + 'email' => 'Email', + 'github_user_already_taken' => 'Your Github username has already been taken on this site, please choose a different username', +]; diff --git a/app/lang/en/user_tricks.php b/app/lang/en/user_tricks.php index 167aa78..0e86ea7 100644 --- a/app/lang/en/user_tricks.php +++ b/app/lang/en/user_tricks.php @@ -1,8 +1,9 @@ - 'Trick has been updated', - 'trick_deleted' => 'Trick has been deleted', - 'trick_does_not_belong_to_you' => 'This trick doesn\'t belong to you', - -); \ No newline at end of file + +return [ + 'trick_update' => 'Trick has been updated', + 'trick_deleted' => 'Trick has been deleted', + 'trick_does_not_belong_to_you' => 'This trick doesn\'t belong to you', + +]; diff --git a/app/lang/en/validation.php b/app/lang/en/validation.php index 5a24a40..8bc5e87 100644 --- a/app/lang/en/validation.php +++ b/app/lang/en/validation.php @@ -1,98 +1,98 @@ "The :attribute must be accepted.", - "active_url" => "The :attribute is not a valid URL.", - "after" => "The :attribute must be a date after :date.", - "alpha" => "The :attribute may only contain letters.", - "alpha_dash" => "The :attribute may only contain letters, numbers, and dashes.", - "alpha_num" => "The :attribute may only contain letters and numbers.", - "array" => "The :attribute must be an array.", - "before" => "The :attribute must be a date before :date.", - "between" => array( - "numeric" => "The :attribute must be between :min - :max.", - "file" => "The :attribute must be between :min - :max kilobytes.", - "string" => "The :attribute must be between :min - :max characters.", - "array" => "The :attribute must have between :min - :max items.", - ), - "confirmed" => "The :attribute confirmation does not match.", - "date" => "The :attribute is not a valid date.", - "date_format" => "The :attribute does not match the format :format.", - "different" => "The :attribute and :other must be different.", - "digits" => "The :attribute must be :digits digits.", - "digits_between" => "The :attribute must be between :min and :max digits.", - "email" => "The :attribute format is invalid.", - "exists" => "The selected :attribute is invalid.", - "image" => "The :attribute must be an image.", - "in" => "The selected :attribute is invalid.", - "integer" => "The :attribute must be an integer.", - "ip" => "The :attribute must be a valid IP address.", - "max" => array( - "numeric" => "The :attribute may not be greater than :max.", - "file" => "The :attribute may not be greater than :max kilobytes.", - "string" => "The :attribute may not be greater than :max characters.", - "array" => "The :attribute may not have more than :max items.", - ), - "mimes" => "The :attribute must be a file of type: :values.", - "min" => array( - "numeric" => "The :attribute must be at least :min.", - "file" => "The :attribute must be at least :min kilobytes.", - "string" => "The :attribute must be at least :min characters.", - "array" => "The :attribute must have at least :min items.", - ), - "not_in" => "The selected :attribute is invalid.", - "numeric" => "The :attribute must be a number.", - "regex" => "The :attribute format is invalid.", - "required" => "The :attribute field is required.", - "required_if" => "The :attribute field is required when :other is :value.", - "required_with" => "The :attribute field is required when :values is present.", - "required_without" => "The :attribute field is required when :values is not present.", - "same" => "The :attribute and :other must match.", - "size" => array( - "numeric" => "The :attribute must be :size.", - "file" => "The :attribute must be :size kilobytes.", - "string" => "The :attribute must be :size characters.", - "array" => "The :attribute must contain :size items.", - ), - "unique" => "The :attribute has already been taken.", - "url" => "The :attribute format is invalid.", + 'accepted' => 'The :attribute must be accepted.', + 'active_url' => 'The :attribute is not a valid URL.', + 'after' => 'The :attribute must be a date after :date.', + 'alpha' => 'The :attribute may only contain letters.', + 'alpha_dash' => 'The :attribute may only contain letters, numbers, and dashes.', + 'alpha_num' => 'The :attribute may only contain letters and numbers.', + 'array' => 'The :attribute must be an array.', + 'before' => 'The :attribute must be a date before :date.', + 'between' => [ + 'numeric' => 'The :attribute must be between :min - :max.', + 'file' => 'The :attribute must be between :min - :max kilobytes.', + 'string' => 'The :attribute must be between :min - :max characters.', + 'array' => 'The :attribute must have between :min - :max items.', + ], + 'confirmed' => 'The :attribute confirmation does not match.', + 'date' => 'The :attribute is not a valid date.', + 'date_format' => 'The :attribute does not match the format :format.', + 'different' => 'The :attribute and :other must be different.', + 'digits' => 'The :attribute must be :digits digits.', + 'digits_between' => 'The :attribute must be between :min and :max digits.', + 'email' => 'The :attribute format is invalid.', + 'exists' => 'The selected :attribute is invalid.', + 'image' => 'The :attribute must be an image.', + 'in' => 'The selected :attribute is invalid.', + 'integer' => 'The :attribute must be an integer.', + 'ip' => 'The :attribute must be a valid IP address.', + 'max' => [ + 'numeric' => 'The :attribute may not be greater than :max.', + 'file' => 'The :attribute may not be greater than :max kilobytes.', + 'string' => 'The :attribute may not be greater than :max characters.', + 'array' => 'The :attribute may not have more than :max items.', + ], + 'mimes' => 'The :attribute must be a file of type: :values.', + 'min' => [ + 'numeric' => 'The :attribute must be at least :min.', + 'file' => 'The :attribute must be at least :min kilobytes.', + 'string' => 'The :attribute must be at least :min characters.', + 'array' => 'The :attribute must have at least :min items.', + ], + 'not_in' => 'The selected :attribute is invalid.', + 'numeric' => 'The :attribute must be a number.', + 'regex' => 'The :attribute format is invalid.', + 'required' => 'The :attribute field is required.', + 'required_if' => 'The :attribute field is required when :other is :value.', + 'required_with' => 'The :attribute field is required when :values is present.', + 'required_without' => 'The :attribute field is required when :values is not present.', + 'same' => 'The :attribute and :other must match.', + 'size' => [ + 'numeric' => 'The :attribute must be :size.', + 'file' => 'The :attribute must be :size kilobytes.', + 'string' => 'The :attribute must be :size characters.', + 'array' => 'The :attribute must contain :size items.', + ], + 'unique' => 'The :attribute has already been taken.', + 'url' => 'The :attribute format is invalid.', - /* - |-------------------------------------------------------------------------- - | Custom Validation Language Lines - |-------------------------------------------------------------------------- - | - | Here you may specify custom validation messages for attributes using the - | convention "attribute.rule" to name the lines. This makes it quick to - | specify a specific custom language line for a given attribute rule. - | - */ + /* + |-------------------------------------------------------------------------- + | Custom Validation Language Lines + |-------------------------------------------------------------------------- + | + | Here you may specify custom validation messages for attributes using the + | convention "attribute.rule" to name the lines. This makes it quick to + | specify a specific custom language line for a given attribute rule. + | + */ - 'custom' => array(), + 'custom' => [], - /* - |-------------------------------------------------------------------------- - | Custom Validation Attributes - |-------------------------------------------------------------------------- - | - | The following language lines are used to swap attribute place-holders - | with something more reader friendly such as E-Mail Address instead - | of "email". This simply helps us make messages a little cleaner. - | - */ + /* + |-------------------------------------------------------------------------- + | Custom Validation Attributes + |-------------------------------------------------------------------------- + | + | The following language lines are used to swap attribute place-holders + | with something more reader friendly such as E-Mail Address instead + | of "email". This simply helps us make messages a little cleaner. + | + */ - 'attributes' => array(), + 'attributes' => [], -); +]; diff --git a/app/routes.php b/app/routes.php index b50ca8a..0af3086 100644 --- a/app/routes.php +++ b/app/routes.php @@ -1,92 +1,93 @@ 'admin', 'namespace' => 'Controllers\Admin' ], function () { +// Admin routes +Route::group(['prefix' => 'admin', 'namespace' => 'Controllers\Admin'], function () { Route::controller('tags', 'TagsController', [ 'getIndex' => 'admin.tags.index', - 'getView' => 'admin.tags.view' + 'getView' => 'admin.tags.view', ]); Route::controller('categories', 'CategoriesController', [ 'getIndex' => 'admin.categories.index', - 'getView' => 'admin.categories.view' + 'getView' => 'admin.categories.view', ]); Route::controller('users', 'UsersController'); }); -Route::group([ 'namespace' => 'Controllers' ], function () { - # Home routes - Route::get('/', [ 'as' => 'browse.recent', 'uses' => 'BrowseController@getBrowseRecent' ]); - Route::get('popular', [ 'as' => 'browse.popular', 'uses' => 'BrowseController@getBrowsePopular' ]); - Route::get('comments', [ 'as' => 'browse.comments', 'uses' => 'BrowseController@getBrowseComments' ]); - Route::get('about', [ 'as' => 'about', 'uses' => 'HomeController@getAbout' ]); +Route::group(['namespace' => 'Controllers'], function () { + // Home routes + Route::get('/', ['as' => 'browse.recent', 'uses' => 'BrowseController@getBrowseRecent']); + Route::get('popular', ['as' => 'browse.popular', 'uses' => 'BrowseController@getBrowsePopular']); + Route::get('comments', ['as' => 'browse.comments', 'uses' => 'BrowseController@getBrowseComments']); + Route::get('about', ['as' => 'about', 'uses' => 'HomeController@getAbout']); - # Trick routes - Route::get('tricks/{trick_slug?}', [ 'as' => 'tricks.show', 'uses' => 'TricksController@getShow' ]); - Route::post('tricks/{trick_slug}/like', [ 'as' => 'tricks.like', 'uses' => 'TricksController@postLike' ]); + // Trick routes + Route::get('tricks/{trick_slug?}', ['as' => 'tricks.show', 'uses' => 'TricksController@getShow']); + Route::post('tricks/{trick_slug}/like', ['as' => 'tricks.like', 'uses' => 'TricksController@postLike']); - # Browse routes - Route::get('categories', [ 'as' => 'browse.categories', 'uses' => 'BrowseController@getCategoryIndex']); + // Browse routes + Route::get('categories', ['as' => 'browse.categories', 'uses' => 'BrowseController@getCategoryIndex']); Route::get('categories/{category_slug}', [ 'as' => 'tricks.browse.category', - 'uses' => 'BrowseController@getBrowseCategory' + 'uses' => 'BrowseController@getBrowseCategory', ]); - Route::get('tags', [ 'as' => 'browse.tags', 'uses' => 'BrowseController@getTagIndex' ]); - Route::get('tags/{tag_slug}', [ 'as' => 'tricks.browse.tag', 'uses' => 'BrowseController@getBrowseTag' ]); + Route::get('tags', ['as' => 'browse.tags', 'uses' => 'BrowseController@getTagIndex']); + Route::get('tags/{tag_slug}', ['as' => 'tricks.browse.tag', 'uses' => 'BrowseController@getBrowseTag']); - # Search routes + // Search routes Route::get('search', 'SearchController@getIndex'); - # Sitemap route + // Sitemap route Route::get('sitemap', 'SitemapController@getIndex'); Route::get('sitemap.xml', 'SitemapController@getIndex'); - # Authentication and registration routes - Route::get('login', [ 'as' => 'auth.login', 'uses' => 'AuthController@getLogin' ]); + // Authentication and registration routes + Route::get('login', ['as' => 'auth.login', 'uses' => 'AuthController@getLogin']); Route::post('login', 'AuthController@postLogin'); - Route::get('login/github', [ 'as' => 'auth.login.github', 'uses' => 'AuthController@getLoginWithGithub' ]); - Route::get('register', [ 'as' => 'auth.register', 'uses' => 'AuthController@getRegister']); + Route::get('login/github', ['as' => 'auth.login.github', 'uses' => 'AuthController@getLoginWithGithub']); + Route::get('register', ['as' => 'auth.register', 'uses' => 'AuthController@getRegister']); Route::post('register', 'AuthController@postRegister'); - Route::get('logout', [ 'as' => 'auth.logout', 'uses' => 'AuthController@getLogout' ]); + Route::get('logout', ['as' => 'auth.logout', 'uses' => 'AuthController@getLogout']); - # Password reminder routes + // Password reminder routes Route::controller('password', 'RemindersController', [ 'getRemind' => 'auth.remind', - 'getReset' => 'auth.reset' + 'getReset' => 'auth.reset', ]); - # User profile routes - Route::get('user', [ 'as' => 'user.index', 'uses' => 'UserController@getIndex' ]); - Route::get('user/settings', [ 'as' => 'user.settings', 'uses' => 'UserController@getSettings' ]); + // User profile routes + Route::get('user', ['as' => 'user.index', 'uses' => 'UserController@getIndex']); + Route::get('user/settings', ['as' => 'user.settings', 'uses' => 'UserController@getSettings']); Route::post('user/settings', 'UserController@postSettings'); - Route::get('user/favorites', [ 'as' => 'user.favorites', 'uses' => 'UserController@getFavorites' ]); - Route::post('user/avatar', [ 'as' => 'user.avatar', 'uses' => 'UserController@postAvatar' ]); + Route::get('user/favorites', ['as' => 'user.favorites', 'uses' => 'UserController@getFavorites']); + Route::post('user/avatar', ['as' => 'user.avatar', 'uses' => 'UserController@postAvatar']); - # Trick creation route - Route::get('user/tricks/new', [ 'as' => 'tricks.new', 'uses' => 'UserTricksController@getNew' ]); + // Trick creation route + Route::get('user/tricks/new', ['as' => 'tricks.new', 'uses' => 'UserTricksController@getNew']); Route::post('user/tricks/new', 'UserTricksController@postNew'); - # Trick editing route - Route::get('user/tricks/{trick_slug}', [ 'as' => 'tricks.edit', 'uses' => 'UserTricksController@getEdit' ]); + // Trick editing route + Route::get('user/tricks/{trick_slug}', ['as' => 'tricks.edit', 'uses' => 'UserTricksController@getEdit']); Route::post('user/tricks/{trick_slug}', 'UserTricksController@postEdit'); - # Trick delete route - Route::get('user/tricks/{trick_slug}/delete', [ 'as' => 'tricks.delete', 'uses' => 'UserTricksController@getDelete' ]); + // Trick delete route + Route::get('user/tricks/{trick_slug}/delete', ['as' => 'tricks.delete', 'uses' => 'UserTricksController@getDelete']); - # Feed routes - Route::get('feed', [ 'as' => 'feed.atom', 'uses' => 'FeedsController@getAtom' ]); - Route::get('feed.atom', [ 'uses' => 'FeedsController@getAtom' ]); - Route::get('feed.xml', [ 'as' => 'feed.rss', 'uses' => 'FeedsController@getRss' ]); + // Feed routes + Route::get('feed', ['as' => 'feed.atom', 'uses' => 'FeedsController@getAtom']); + Route::get('feed.atom', ['uses' => 'FeedsController@getAtom']); + Route::get('feed.xml', ['as' => 'feed.rss', 'uses' => 'FeedsController@getRss']); - # This route will match the user by username to display their public profile - # (if we want people to see who favorites and who posts what) - Route::get('{user}', [ 'as' => 'user.profile', 'uses' => 'UserController@getPublic' ]); + // This route will match the user by username to display their public profile + // (if we want people to see who favorites and who posts what) + Route::get('{user}', ['as' => 'user.profile', 'uses' => 'UserController@getPublic']); }); diff --git a/app/start/artisan.php b/app/start/artisan.php index 1df850b..409e9ad 100644 --- a/app/start/artisan.php +++ b/app/start/artisan.php @@ -10,4 +10,3 @@ | the console gets access to each of the command object instances. | */ - diff --git a/app/start/global.php b/app/start/global.php index e4463f0..520b071 100644 --- a/app/start/global.php +++ b/app/start/global.php @@ -26,11 +26,11 @@ | */ -App::error(function(Exception $exception, $code) { - Log::error($exception); +App::error(function (Exception $exception, $code) { + Log::error($exception); }); -App::error(function(Tricks\Exceptions\AbstractNotFoundException $exception, $code) { +App::error(function (Tricks\Exceptions\AbstractNotFoundException $exception, $code) { $error = $exception->getMessage(); return Response::view('home.error', compact('error'), 404); @@ -47,8 +47,8 @@ | */ -App::down(function() { - return Response::make("Be right back!", 503); +App::down(function () { + return Response::make('Be right back!', 503); }); /* diff --git a/app/start/local.php b/app/start/local.php index adab104..7ea77fb 100644 --- a/app/start/local.php +++ b/app/start/local.php @@ -1,3 +1,3 @@ getProperty($property); - $reflectionProperty->setAccessible(true); - $reflectionProperty->setValue($class, $value); - } + $reflectionProperty = $reflectionClass->getProperty($property); + $reflectionProperty->setAccessible(true); + $reflectionProperty->setValue($class, $value); + } - public function getProtectedProperty($class, $property) - { - return Assert::readAttribute($class, $property); - } + public function getProtectedProperty($class, $property) + { + return Assert::readAttribute($class, $property); + } - protected function incomplete($message = 'This test has not been implemented yet.') - { - $this->markTestIncomplete($message); - } + protected function incomplete($message = 'This test has not been implemented yet.') + { + $this->markTestIncomplete($message); + } } diff --git a/app/tests/Tricks/CategoryTest.php b/app/tests/Tricks/CategoryTest.php index 3251368..2cd8c67 100644 --- a/app/tests/Tricks/CategoryTest.php +++ b/app/tests/Tricks/CategoryTest.php @@ -5,28 +5,27 @@ use Mockery; use TestCase; -class CategoryTest -extends TestCase +class CategoryTest extends TestCase { - public function tearDown() - { - Mockery::close(); - } + public function tearDown() + { + Mockery::close(); + } /** * @group tricks */ public function testTricks() { - $mock = Mockery::mock('Tricks\Category') + $mock = Mockery::mock('Tricks\Category') ->makePartial(); - $mock + $mock ->shouldReceive('belongsToMany') ->atLeast()->once() ->with('Tricks\Trick') ->andReturn('mocked'); - $this->assertEquals('mocked', $mock->tricks()); + $this->assertEquals('mocked', $mock->tricks()); } } diff --git a/app/tests/Tricks/Events/ViewTrickHandlerTest.php b/app/tests/Tricks/Events/ViewTrickHandlerTest.php index 0252eac..941300c 100644 --- a/app/tests/Tricks/Events/ViewTrickHandlerTest.php +++ b/app/tests/Tricks/Events/ViewTrickHandlerTest.php @@ -5,34 +5,33 @@ use Mockery; use TestCase; -class ViewTrickHandlerTest -extends TestCase +class ViewTrickHandlerTest extends TestCase { - public function tearDown() - { - Mockery::close(); - } + public function tearDown() + { + Mockery::close(); + } /** * @group tricks/events */ public function testConstructor() { - $trickRepositoryMock = Mockery::mock('Tricks\Repositories\TrickRepositoryInterface'); + $trickRepositoryMock = Mockery::mock('Tricks\Repositories\TrickRepositoryInterface'); - $storeMock = Mockery::mock('Illuminate\Session\Store'); + $storeMock = Mockery::mock('Illuminate\Session\Store'); - $viewTrickHandler = new ViewTrickHandler( + $viewTrickHandler = new ViewTrickHandler( $trickRepositoryMock, $storeMock ); - $this->assertSame( + $this->assertSame( $trickRepositoryMock, $this->getProtectedProperty($viewTrickHandler, 'tricks') ); - $this->assertSame( + $this->assertSame( $storeMock, $this->getProtectedProperty($viewTrickHandler, 'session') ); @@ -43,37 +42,37 @@ public function testConstructor() */ public function testHandle() { - $trickMock = Mockery::mock('Tricks\Trick'); + $trickMock = Mockery::mock('Tricks\Trick'); - $trickRepositoryMock = Mockery::mock('Tricks\Repositories\TrickRepositoryInterface') + $trickRepositoryMock = Mockery::mock('Tricks\Repositories\TrickRepositoryInterface') ->makePartial(); - $trickRepositoryMock + $trickRepositoryMock ->shouldReceive('incrementViews') ->atLeast()->once() ->with($trickMock) ->andReturn('mocked'); - $storeMock = Mockery::mock('Illuminate\Session\Store'); + $storeMock = Mockery::mock('Illuminate\Session\Store'); - $viewTrickHandlerMock = Mockery::mock('Tricks\Events\ViewTrickHandler', [ + $viewTrickHandlerMock = Mockery::mock('Tricks\Events\ViewTrickHandler', [ $trickRepositoryMock, - $storeMock + $storeMock, ]) ->shouldAllowMockingProtectedMethods() ->makePartial(); - $viewTrickHandlerMock + $viewTrickHandlerMock ->shouldReceive('hasViewedTrick') ->atLeast()->once() ->andReturn(false); - $viewTrickHandlerMock + $viewTrickHandlerMock ->shouldReceive('storeViewedTrick') ->atLeast()->once() ->with('mocked'); - $viewTrickHandlerMock->handle($trickMock); + $viewTrickHandlerMock->handle($trickMock); } /** @@ -81,32 +80,32 @@ public function testHandle() */ public function testHasViewedTrick() { - $viewTrickHandlerMock = Mockery::mock('Tricks\Events\ViewTrickHandler', [ + $viewTrickHandlerMock = Mockery::mock('Tricks\Events\ViewTrickHandler', [ Mockery::mock('Tricks\Repositories\TrickRepositoryInterface'), - Mockery::mock('Illuminate\Session\Store') + Mockery::mock('Illuminate\Session\Store'), ]) ->shouldAllowMockingProtectedMethods() ->makePartial(); - $time = time(); + $time = time(); - $tricks = [ - "1" => $time - 50, - "2" => $time - 150, - "3" => $time + $tricks = [ + '1' => $time - 50, + '2' => $time - 150, + '3' => $time, ]; - $viewTrickHandlerMock + $viewTrickHandlerMock ->shouldReceive('getViewedTricks') ->atLeast()->once() ->andReturn($tricks); - $trickMock = Mockery::mock('Tricks\Trick') + $trickMock = Mockery::mock('Tricks\Trick') ->makePartial(); - $trickMock->id = 2; + $trickMock->id = 2; - $this->assertTrue($viewTrickHandlerMock->hasViewedTrick($trickMock)); + $this->assertTrue($viewTrickHandlerMock->hasViewedTrick($trickMock)); } /** @@ -114,25 +113,25 @@ public function testHasViewedTrick() */ public function testGetViewedTricks() { - $trickRepositoryMock = Mockery::mock('Tricks\Repositories\TrickRepositoryInterface'); + $trickRepositoryMock = Mockery::mock('Tricks\Repositories\TrickRepositoryInterface'); - $storeMock = Mockery::mock('Illuminate\Session\Store') + $storeMock = Mockery::mock('Illuminate\Session\Store') ->makePartial(); - $storeMock + $storeMock ->shouldReceive('get') ->atLeast()->once() ->with('viewed_tricks', []) ->andReturn('mocked'); - $viewTrickHandlerMock = Mockery::mock('Tricks\Events\ViewTrickHandler', [ + $viewTrickHandlerMock = Mockery::mock('Tricks\Events\ViewTrickHandler', [ $trickRepositoryMock, - $storeMock + $storeMock, ]) ->shouldAllowMockingProtectedMethods() ->makePartial(); - $this->assertEquals('mocked', $viewTrickHandlerMock->getViewedTricks()); + $this->assertEquals('mocked', $viewTrickHandlerMock->getViewedTricks()); } /** @@ -140,31 +139,31 @@ public function testGetViewedTricks() */ public function testStoreViewedTrick() { - $id = 2; + $id = 2; - $trickMock = Mockery::mock('Tricks\Trick') + $trickMock = Mockery::mock('Tricks\Trick') ->makePartial(); - $trickMock->id = $id; + $trickMock->id = $id; - $trickRepositoryMock = Mockery::mock('Tricks\Repositories\TrickRepositoryInterface'); + $trickRepositoryMock = Mockery::mock('Tricks\Repositories\TrickRepositoryInterface'); - $storeMock = Mockery::mock('Illuminate\Session\Store') + $storeMock = Mockery::mock('Illuminate\Session\Store') ->makePartial(); - $storeMock + $storeMock ->shouldReceive('put') ->atLeast()->once() - ->with('viewed_tricks.' . $id, Mockery::type('int')) + ->with('viewed_tricks.'.$id, Mockery::type('int')) ->andReturn('mocked'); - $viewTrickHandlerMock = Mockery::mock('Tricks\Events\ViewTrickHandler', [ + $viewTrickHandlerMock = Mockery::mock('Tricks\Events\ViewTrickHandler', [ $trickRepositoryMock, - $storeMock + $storeMock, ]) ->shouldAllowMockingProtectedMethods() ->makePartial(); - $viewTrickHandlerMock->storeViewedTrick($trickMock); + $viewTrickHandlerMock->storeViewedTrick($trickMock); } } diff --git a/app/tests/Tricks/Filters/TrickOwnerFilterTest.php b/app/tests/Tricks/Filters/TrickOwnerFilterTest.php index 457b436..6cbf9f4 100644 --- a/app/tests/Tricks/Filters/TrickOwnerFilterTest.php +++ b/app/tests/Tricks/Filters/TrickOwnerFilterTest.php @@ -5,42 +5,41 @@ use Mockery; use TestCase; -class TrickOwnerFilterTest -extends TestCase +class TrickOwnerFilterTest extends TestCase { - public function tearDown() - { - Mockery::close(); - } + public function tearDown() + { + Mockery::close(); + } /** * @group tricks/filters */ public function testConstructor() { - $authManagerMock = Mockery::mock('Illuminate\Auth\AuthManager'); + $authManagerMock = Mockery::mock('Illuminate\Auth\AuthManager'); - $redirectorMock = Mockery::mock('Illuminate\Routing\Redirector'); + $redirectorMock = Mockery::mock('Illuminate\Routing\Redirector'); - $trickRepositoryMock = Mockery::mock('Tricks\Repositories\TrickRepositoryInterface'); + $trickRepositoryMock = Mockery::mock('Tricks\Repositories\TrickRepositoryInterface'); - $trickOwnerFilter = new TrickOwnerFilter( + $trickOwnerFilter = new TrickOwnerFilter( $authManagerMock, $redirectorMock, $trickRepositoryMock ); - $this->assertSame( + $this->assertSame( $authManagerMock, $this->getProtectedProperty($trickOwnerFilter, 'auth') ); - $this->assertSame( + $this->assertSame( $redirectorMock, $this->getProtectedProperty($trickOwnerFilter, 'redirect') ); - $this->assertSame( + $this->assertSame( $trickRepositoryMock, $this->getProtectedProperty($trickOwnerFilter, 'tricks') ); @@ -51,31 +50,31 @@ public function testConstructor() */ public function testFilter() { - $routeMock1 = Mockery::mock('Illuminate\Routing\Route'); + $routeMock1 = Mockery::mock('Illuminate\Routing\Route'); - $routeMock2 = Mockery::mock('Illuminate\Routing\Route'); + $routeMock2 = Mockery::mock('Illuminate\Routing\Route'); - $authManagerMock = Mockery::mock('Illuminate\Auth\AuthManager'); + $authManagerMock = Mockery::mock('Illuminate\Auth\AuthManager'); - $redirectorMock = Mockery::mock('Illuminate\Routing\Redirector'); + $redirectorMock = Mockery::mock('Illuminate\Routing\Redirector'); - $redirectorMock + $redirectorMock ->shouldReceive('route') ->atLeast()->once() ->with('browse.recent') ->andReturn('mocked route'); - $trickRepositoryMock = Mockery::mock('Tricks\Repositories\TrickRepositoryInterface'); + $trickRepositoryMock = Mockery::mock('Tricks\Repositories\TrickRepositoryInterface'); - $trickOwnerFilterMock = Mockery::mock('Tricks\Filters\TrickOwnerFilter', [ + $trickOwnerFilterMock = Mockery::mock('Tricks\Filters\TrickOwnerFilter', [ $authManagerMock, $redirectorMock, - $trickRepositoryMock + $trickRepositoryMock, ]) ->shouldAllowMockingProtectedMethods() ->makePartial(); - $trickOwnerFilterMock + $trickOwnerFilterMock ->shouldReceive('getSlug') ->atLeast()->once() ->with($routeMock1) @@ -87,28 +86,28 @@ public function testFilter() ->with($routeMock2) ->andReturn('mocked route2 getSlug'); - $trickOwnerFilterMock + $trickOwnerFilterMock ->shouldReceive('getUserId') ->atLeast()->once() ->andReturn(1); - $trickOwnerFilterMock + $trickOwnerFilterMock ->shouldReceive('isTrickOwnedByUser') ->atLeast()->once() ->with('mocked route1 getSlug', 1) ->andReturn(true); - $trickOwnerFilterMock + $trickOwnerFilterMock ->shouldReceive('isTrickOwnedByUser') ->atLeast()->once() ->with('mocked route2 getSlug', 1) ->andReturn(false); - $this->assertNull( + $this->assertNull( $trickOwnerFilterMock->filter($routeMock1) ); - $this->assertEquals( + $this->assertEquals( 'mocked route', $trickOwnerFilterMock->filter($routeMock2) ); @@ -119,28 +118,28 @@ public function testFilter() */ public function testGetUserId() { - $authManagerMock = Mockery::mock('Illuminate\Auth\AuthManager'); + $authManagerMock = Mockery::mock('Illuminate\Auth\AuthManager'); - $authManagerMock + $authManagerMock ->shouldReceive('user') ->atLeast()->once() ->andReturn($authManagerMock); - $authManagerMock->id = 1; + $authManagerMock->id = 1; - $redirectorMock = Mockery::mock('Illuminate\Routing\Redirector'); + $redirectorMock = Mockery::mock('Illuminate\Routing\Redirector'); - $trickRepositoryMock = Mockery::mock('Tricks\Repositories\TrickRepositoryInterface'); + $trickRepositoryMock = Mockery::mock('Tricks\Repositories\TrickRepositoryInterface'); - $trickOwnerFilterMock = Mockery::mock('Tricks\Filters\TrickOwnerFilter', [ + $trickOwnerFilterMock = Mockery::mock('Tricks\Filters\TrickOwnerFilter', [ $authManagerMock, $redirectorMock, - $trickRepositoryMock + $trickRepositoryMock, ]) ->shouldAllowMockingProtectedMethods() ->makePartial(); - $this->assertEquals( + $this->assertEquals( 1, $trickOwnerFilterMock->getUserId() ); @@ -151,23 +150,23 @@ public function testGetUserId() */ public function testGetSlug() { - $routeMock = Mockery::mock('Illuminate\Routing\Route'); + $routeMock = Mockery::mock('Illuminate\Routing\Route'); - $routeMock + $routeMock ->shouldReceive('getParameter') ->atLeast()->once() ->with('trick_slug') ->andReturn('mocked getParameter'); - $trickOwnerFilterMock = Mockery::mock('Tricks\Filters\TrickOwnerFilter', [ + $trickOwnerFilterMock = Mockery::mock('Tricks\Filters\TrickOwnerFilter', [ Mockery::mock('Illuminate\Auth\AuthManager'), Mockery::mock('Illuminate\Routing\Redirector'), - Mockery::mock('Tricks\Repositories\TrickRepositoryInterface') + Mockery::mock('Tricks\Repositories\TrickRepositoryInterface'), ]) ->shouldAllowMockingProtectedMethods() ->makePartial(); - $this->assertEquals( + $this->assertEquals( 'mocked getParameter', $trickOwnerFilterMock->getSlug($routeMock) ); @@ -178,27 +177,27 @@ public function testGetSlug() */ public function testIsTrickOwnedByUser() { - $authManagerMock = Mockery::mock('Illuminate\Auth\AuthManager'); + $authManagerMock = Mockery::mock('Illuminate\Auth\AuthManager'); - $redirectorMock = Mockery::mock('Illuminate\Routing\Redirector'); + $redirectorMock = Mockery::mock('Illuminate\Routing\Redirector'); - $trickRepositoryMock = Mockery::mock('Tricks\Repositories\TrickRepositoryInterface'); + $trickRepositoryMock = Mockery::mock('Tricks\Repositories\TrickRepositoryInterface'); - $trickRepositoryMock + $trickRepositoryMock ->shouldReceive('isTrickOwnedByUser') ->atLeast()->once() ->with('foo', 1) ->andReturn('mocked isTrickOwnedByUser'); - $trickOwnerFilterMock = Mockery::mock('Tricks\Filters\TrickOwnerFilter', [ + $trickOwnerFilterMock = Mockery::mock('Tricks\Filters\TrickOwnerFilter', [ $authManagerMock, $redirectorMock, - $trickRepositoryMock + $trickRepositoryMock, ]) ->shouldAllowMockingProtectedMethods() ->makePartial(); - $this->assertEquals( + $this->assertEquals( 'mocked isTrickOwnedByUser', $trickOwnerFilterMock->isTrickOwnedByUser('foo', 1) ); diff --git a/app/tests/Tricks/Filters/ViewThrottleFilterTest.php b/app/tests/Tricks/Filters/ViewThrottleFilterTest.php index c1fe283..2fd6db1 100644 --- a/app/tests/Tricks/Filters/ViewThrottleFilterTest.php +++ b/app/tests/Tricks/Filters/ViewThrottleFilterTest.php @@ -5,34 +5,33 @@ use Mockery; use TestCase; -class ViewThrottleFilterTest -extends TestCase +class ViewThrottleFilterTest extends TestCase { - public function tearDown() - { - Mockery::close(); - } + public function tearDown() + { + Mockery::close(); + } /** * @group tricks/filters */ public function testConstructor() { - $repositoryMock = Mockery::mock('Illuminate\Config\Repository'); + $repositoryMock = Mockery::mock('Illuminate\Config\Repository'); - $storeMock = Mockery::mock('Illuminate\Session\Store'); + $storeMock = Mockery::mock('Illuminate\Session\Store'); - $viewThrottleFilter = new ViewThrottleFilter( + $viewThrottleFilter = new ViewThrottleFilter( $repositoryMock, $storeMock ); - $this->assertSame( + $this->assertSame( $repositoryMock, $this->getProtectedProperty($viewThrottleFilter, 'config') ); - $this->assertSame( + $this->assertSame( $storeMock, $this->getProtectedProperty($viewThrottleFilter, 'session') ); @@ -43,38 +42,38 @@ public function testConstructor() */ public function testFilter() { - $viewThrottleFilterMock = Mockery::mock('Tricks\Filters\ViewThrottleFilter', [ + $viewThrottleFilterMock = Mockery::mock('Tricks\Filters\ViewThrottleFilter', [ Mockery::mock('Illuminate\Config\Repository'), - Mockery::mock('Illuminate\Session\Store') + Mockery::mock('Illuminate\Session\Store'), ]) ->shouldAllowMockingProtectedMethods() ->makePartial(); - $time = time(); + $time = time(); - $tricks = [ - "1" => $time - 50, - "2" => $time - 150, - "3" => $time + $tricks = [ + '1' => $time - 50, + '2' => $time - 150, + '3' => $time, ]; - $viewThrottleFilterMock + $viewThrottleFilterMock ->shouldReceive('getViewedTricks') ->atLeast()->once() ->andReturn($tricks); - $viewThrottleFilterMock + $viewThrottleFilterMock ->shouldReceive('purgeExpiredTricks') ->atLeast()->once() ->with($tricks) ->andReturn($tricks); - $viewThrottleFilterMock + $viewThrottleFilterMock ->shouldReceive('storeViewedTricks') ->atLeast()->once() ->with($tricks); - $viewThrottleFilterMock->filter(); + $viewThrottleFilterMock->filter(); } /** @@ -82,25 +81,25 @@ public function testFilter() */ public function testGetViewedTricks() { - $repositoryMock = Mockery::mock('Illuminate\Config\Repository'); + $repositoryMock = Mockery::mock('Illuminate\Config\Repository'); - $storeMock = Mockery::mock('Illuminate\Session\Store') + $storeMock = Mockery::mock('Illuminate\Session\Store') ->makePartial(); - $storeMock + $storeMock ->shouldReceive('get') ->atLeast()->once() ->with('viewed_tricks', null) ->andReturn('mocked'); - $viewThrottleFilterMock = Mockery::mock('Tricks\Filters\ViewThrottleFilter', [ + $viewThrottleFilterMock = Mockery::mock('Tricks\Filters\ViewThrottleFilter', [ $repositoryMock, - $storeMock + $storeMock, ]) ->shouldAllowMockingProtectedMethods() ->makePartial(); - $this->assertEquals('mocked', $viewThrottleFilterMock->getViewedTricks()); + $this->assertEquals('mocked', $viewThrottleFilterMock->getViewedTricks()); } /** @@ -108,25 +107,25 @@ public function testGetViewedTricks() */ public function testGetThrottleTime() { - $repositoryMock = Mockery::mock('Illuminate\Config\Repository') + $repositoryMock = Mockery::mock('Illuminate\Config\Repository') ->makePartial(); - $repositoryMock + $repositoryMock ->shouldReceive('get') ->atLeast()->once() ->with('config.view_throttle_time') ->andReturn('mocked'); - $storeMock = Mockery::mock('Illuminate\Session\Store'); + $storeMock = Mockery::mock('Illuminate\Session\Store'); - $viewThrottleFilterMock = Mockery::mock('Tricks\Filters\ViewThrottleFilter', [ + $viewThrottleFilterMock = Mockery::mock('Tricks\Filters\ViewThrottleFilter', [ $repositoryMock, - $storeMock + $storeMock, ]) ->shouldAllowMockingProtectedMethods() ->makePartial(); - $this->assertEquals('mocked', $viewThrottleFilterMock->getThrottleTime()); + $this->assertEquals('mocked', $viewThrottleFilterMock->getThrottleTime()); } /** @@ -134,32 +133,32 @@ public function testGetThrottleTime() */ public function testPurgeExpiredTricks() { - $time = time(); + $time = time(); - $tricks = [ - "1" => $time - 50, - "2" => $time - 150, - "3" => $time + $tricks = [ + '1' => $time - 50, + '2' => $time - 150, + '3' => $time, ]; - $purgedTricks = [ - "1" => $time - 50, - "3" => $time + $purgedTricks = [ + '1' => $time - 50, + '3' => $time, ]; - $viewThrottleFilterMock = Mockery::mock('Tricks\Filters\ViewThrottleFilter', [ + $viewThrottleFilterMock = Mockery::mock('Tricks\Filters\ViewThrottleFilter', [ Mockery::mock('Illuminate\Config\Repository'), - Mockery::mock('Illuminate\Session\Store') + Mockery::mock('Illuminate\Session\Store'), ]) ->shouldAllowMockingProtectedMethods() ->makePartial(); - $viewThrottleFilterMock + $viewThrottleFilterMock ->shouldReceive('getThrottleTime') ->atLeast()->once() ->andReturn(100); - $this->assertEquals($purgedTricks, $viewThrottleFilterMock->purgeExpiredTricks($tricks)); + $this->assertEquals($purgedTricks, $viewThrottleFilterMock->purgeExpiredTricks($tricks)); } /** @@ -167,31 +166,31 @@ public function testPurgeExpiredTricks() */ public function testStoreViewedTricks() { - $repositoryMock = Mockery::mock('Illuminate\Config\Repository'); + $repositoryMock = Mockery::mock('Illuminate\Config\Repository'); - $time = time(); + $time = time(); - $tricks = [ - "1" => $time - 50, - "2" => $time - 150, - "3" => $time + $tricks = [ + '1' => $time - 50, + '2' => $time - 150, + '3' => $time, ]; - $storeMock = Mockery::mock('Illuminate\Session\Store') + $storeMock = Mockery::mock('Illuminate\Session\Store') ->makePartial(); - $storeMock + $storeMock ->shouldReceive('put') ->atLeast()->once() ->with('viewed_tricks', $tricks); - $viewThrottleFilterMock = Mockery::mock('Tricks\Filters\ViewThrottleFilter', [ + $viewThrottleFilterMock = Mockery::mock('Tricks\Filters\ViewThrottleFilter', [ $repositoryMock, - $storeMock + $storeMock, ]) ->shouldAllowMockingProtectedMethods() ->makePartial(); - $viewThrottleFilterMock->storeViewedTricks($tricks); + $viewThrottleFilterMock->storeViewedTricks($tricks); } } diff --git a/app/tests/Tricks/Presenters/TrickPresenterTest.php b/app/tests/Tricks/Presenters/TrickPresenterTest.php index e93bd07..8953327 100644 --- a/app/tests/Tricks/Presenters/TrickPresenterTest.php +++ b/app/tests/Tricks/Presenters/TrickPresenterTest.php @@ -10,36 +10,35 @@ use Tricks\Trick; use URL; -class TrickPresenterTest -extends TestCase +class TrickPresenterTest extends TestCase { - public function tearDown() - { - Mockery::close(); - } - - protected function getTrickMockWithSlug() - { - $mock = Mockery::mock('Tricks\Trick') + public function tearDown() + { + Mockery::close(); + } + + protected function getTrickMockWithSlug() + { + $mock = Mockery::mock('Tricks\Trick') ->makePartial(); - $mock->slug = 'mocked'; + $mock->slug = 'mocked'; - return $mock; - } + return $mock; + } /** * @group tricks/presenters */ public function testConstructor() { - $mock = Mockery::mock('Tricks\Trick'); + $mock = Mockery::mock('Tricks\Trick'); - $trickPresenter = new TrickPresenter( + $trickPresenter = new TrickPresenter( $mock ); - $this->assertSame( + $this->assertSame( $mock, $this->getProtectedProperty($trickPresenter, 'resource') ); @@ -50,21 +49,21 @@ public function testConstructor() */ public function testEditLink() { - $urlMock = Mockery::mock('stdClass'); + $urlMock = Mockery::mock('stdClass'); - $urlMock + $urlMock ->shouldReceive('route') ->atLeast()->once() ->with('tricks.edit', ['mocked']) ->andReturn('mocked'); - URL::swap($urlMock); + URL::swap($urlMock); - $trickPresenter = new TrickPresenter( + $trickPresenter = new TrickPresenter( $this->getTrickMockWithSlug() ); - $this->assertEquals('mocked', $trickPresenter->editLink()); + $this->assertEquals('mocked', $trickPresenter->editLink()); } /** @@ -72,21 +71,21 @@ public function testEditLink() */ public function testDeleteLink() { - $urlMock = Mockery::mock('stdClass'); + $urlMock = Mockery::mock('stdClass'); - $urlMock + $urlMock ->shouldReceive('route') ->atLeast()->once() ->with('tricks.delete', ['mocked']) ->andReturn('mocked'); - URL::swap($urlMock); + URL::swap($urlMock); - $trickPresenter = new TrickPresenter( + $trickPresenter = new TrickPresenter( $this->getTrickMockWithSlug() ); - $this->assertEquals('mocked', $trickPresenter->deleteLink()); + $this->assertEquals('mocked', $trickPresenter->deleteLink()); } /** @@ -94,22 +93,22 @@ public function testDeleteLink() */ public function testTimeAgoLink() { - $trickMock = Mockery::mock('Tricks\Trick') + $trickMock = Mockery::mock('Tricks\Trick') ->shouldAllowMockingProtectedMethods() ->makePartial(); - $trickMock + $trickMock ->shouldReceive('getDateFormat') ->atLeast()->once() ->andReturn('Y-m-d H:i:s'); - $trickMock->created_at = Carbon::now(); + $trickMock->created_at = Carbon::now(); - $trickPresenter = new TrickPresenter( + $trickPresenter = new TrickPresenter( $trickMock ); - $this->assertEquals($trickMock->created_at->diffForHumans(), $trickPresenter->timeago()); + $this->assertEquals($trickMock->created_at->diffForHumans(), $trickPresenter->timeago()); } /** @@ -117,42 +116,42 @@ public function testTimeAgoLink() */ public function testLikedByUser() { - $userMock = Mockery::mock('Tricks\User') + $userMock = Mockery::mock('Tricks\User') ->makePartial(); - $userMock->id = 'mocked'; + $userMock->id = 'mocked'; - $trickMock = Mockery::mock('Tricks\Trick'); + $trickMock = Mockery::mock('Tricks\Trick'); - $trickMock + $trickMock ->shouldReceive('votes') ->atLeast()->once() ->andReturn($trickMock); - $trickMock + $trickMock ->shouldReceive('where') ->atLeast()->once() ->with('users.id', 'mocked') ->andReturn($trickMock); - $trickMock + $trickMock ->shouldReceive('exists') ->atLeast()->once() ->andReturn(true); - $trickPresenter = new TrickPresenter( + $trickPresenter = new TrickPresenter( $trickMock ); - $this->assertFalse( + $this->assertFalse( $trickPresenter->likedByUser(null) ); - $this->assertTrue( + $this->assertTrue( $trickPresenter->likedByUser($userMock) ); - $this->assertTrue( + $this->assertTrue( $this->getProtectedProperty($trickPresenter, 'likedByUser') ); } @@ -162,16 +161,16 @@ public function testLikedByUser() */ public function testAllCategories() { - $trickMock = Mockery::mock('Tricks\Trick') + $trickMock = Mockery::mock('Tricks\Trick') ->makePartial(); - $trickMock->categories = 'mocked'; + $trickMock->categories = 'mocked'; - $trickPresenter = new TrickPresenter( + $trickPresenter = new TrickPresenter( $trickMock ); - $this->assertEquals( + $this->assertEquals( 'mocked', $trickPresenter->allCategories() ); @@ -182,35 +181,35 @@ public function testAllCategories() */ public function testCategories() { - $categoryMock = Mockery::mock('Tricks\Category'); + $categoryMock = Mockery::mock('Tricks\Category'); - $trickMock = Mockery::mock('Tricks\Trick') + $trickMock = Mockery::mock('Tricks\Trick') ->makePartial(); - $trickMock->categories = [ + $trickMock->categories = [ + $categoryMock, $categoryMock, $categoryMock, - $categoryMock ]; - $trickPresenterMock = Mockery::mock('Tricks\Presenters\TrickPresenter', [ - $trickMock + $trickPresenterMock = Mockery::mock('Tricks\Presenters\TrickPresenter', [ + $trickMock, ]) ->shouldAllowMockingProtectedMethods() ->makePartial(); - $trickPresenterMock + $trickPresenterMock ->shouldReceive('hasCategories') ->atLeast()->once() ->andReturn(true); - $trickPresenterMock + $trickPresenterMock ->shouldReceive('getCategoryLink') ->atLeast()->once() ->with($categoryMock) ->andReturn('[category]'); - $this->assertEquals( + $this->assertEquals( 'in [category], [category], [category]', $trickPresenterMock->categories() ); @@ -221,21 +220,21 @@ public function testCategories() */ public function testHasCategories() { - $trick = new Trick(); + $trick = new Trick(); - $trick->categories = [ + $trick->categories = [ 'foo', 'bar', - 'baz' + 'baz', ]; - $trickPresenterMock = Mockery::mock('Tricks\Presenters\TrickPresenter', [ - $trick + $trickPresenterMock = Mockery::mock('Tricks\Presenters\TrickPresenter', [ + $trick, ]) ->shouldAllowMockingProtectedMethods() ->makePartial(); - $this->assertTrue($trickPresenterMock->hasCategories()); + $this->assertTrue($trickPresenterMock->hasCategories()); } /** @@ -243,29 +242,29 @@ public function testHasCategories() */ public function testGetCategoryLink() { - $category = new Category(); - $category->name = 'foo'; - $category->slug = 'bar'; + $category = new Category(); + $category->name = 'foo'; + $category->slug = 'bar'; - $htmlMock = Mockery::mock('stdClass'); + $htmlMock = Mockery::mock('stdClass'); - $htmlMock + $htmlMock ->shouldReceive('linkRoute') ->atLeast()->once() ->with('tricks.browse.category', 'foo', ['bar']) ->andReturn('mocked'); - HTML::swap($htmlMock); + HTML::swap($htmlMock); - $trickMock = Mockery::mock('Tricks\Trick'); + $trickMock = Mockery::mock('Tricks\Trick'); - $trickPresenterMock = Mockery::mock('Tricks\Presenters\TrickPresenter', [ - $trickMock + $trickPresenterMock = Mockery::mock('Tricks\Presenters\TrickPresenter', [ + $trickMock, ]) ->shouldAllowMockingProtectedMethods() ->makePartial(); - $this->assertEquals( + $this->assertEquals( 'mocked', $trickPresenterMock->getCategoryLink($category) ); @@ -276,26 +275,26 @@ public function testGetCategoryLink() */ public function testPageDescription() { - $trick = new Trick(); + $trick = new Trick(); - $trick->description = 'Lorem ipsum dolor sit amet, consectetur adipiscing + $trick->description = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec porta nisi sed euismod ornare. Integer dapibus, tortor sed malesuada ullamcorper, ante neque bibendum nulla, eget vulputate turpis urna et velit. Nam egestas, magna vel hendrerit egestas, leo sem gravida dui, in facilisis massa erat eget nisl.'; - $trickPresenterMock = Mockery::mock('Tricks\Presenters\TrickPresenter', [ - $trick + $trickPresenterMock = Mockery::mock('Tricks\Presenters\TrickPresenter', [ + $trick, ]) ->shouldAllowMockingProtectedMethods() ->makePartial(); - $trickPresenterMock + $trickPresenterMock ->shouldReceive('removeLastWord') ->atLeast()->once() ->andReturn('mocked'); - $this->assertEquals( + $this->assertEquals( 'mocked...', $trickPresenterMock->pageDescription() ); @@ -306,26 +305,26 @@ public function testPageDescription() */ public function testPageTitle() { - $trick = new Trick(); + $trick = new Trick(); - $trick->title = 'Lorem ipsum dolor sit amet, consectetur adipiscing + $trick->title = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec porta nisi sed euismod ornare. Integer dapibus, tortor sed malesuada ullamcorper, ante neque bibendum nulla, eget vulputate turpis urna et velit. Nam egestas, magna vel hendrerit egestas, leo sem gravida dui, in facilisis massa erat eget nisl.'; - $trickPresenterMock = Mockery::mock('Tricks\Presenters\TrickPresenter', [ - $trick + $trickPresenterMock = Mockery::mock('Tricks\Presenters\TrickPresenter', [ + $trick, ]) ->shouldAllowMockingProtectedMethods() ->makePartial(); - $trickPresenterMock + $trickPresenterMock ->shouldReceive('removeLastWord') ->atLeast()->once() ->andReturn('mocked'); - $this->assertEquals( + $this->assertEquals( 'mocked', $trickPresenterMock->pageTitle() ); @@ -336,15 +335,15 @@ public function testPageTitle() */ public function testRemoveLastWord() { - $before = 'foo bar baz'; + $before = 'foo bar baz'; - $trickPresenterMock = Mockery::mock('Tricks\Presenters\TrickPresenter', [ - Mockery::mock('Tricks\Trick') + $trickPresenterMock = Mockery::mock('Tricks\Presenters\TrickPresenter', [ + Mockery::mock('Tricks\Trick'), ]) ->shouldAllowMockingProtectedMethods() ->makePartial(); - $this->assertEquals( + $this->assertEquals( 'foo bar', $trickPresenterMock->removeLastWord($before) ); @@ -355,34 +354,34 @@ public function testRemoveLastWord() */ public function testTagUri() { - $urlMock = Mockery::mock('stdClass'); + $urlMock = Mockery::mock('stdClass'); - $urlMock + $urlMock ->shouldReceive('route') ->atLeast()->once() ->with('tricks.show', 'mocked') ->andReturn('http://foo.com/bar'); - URL::swap($urlMock); + URL::swap($urlMock); - $trickMock = Mockery::mock('Tricks\Trick') + $trickMock = Mockery::mock('Tricks\Trick') ->shouldAllowMockingProtectedMethods() ->makePartial(); - $trickMock + $trickMock ->shouldReceive('getDateFormat') ->atLeast()->once() ->andReturn('Y-m-d H:i:s'); - $trickMock->slug = 'mocked'; - $trickMock->created_at = Carbon::now(); + $trickMock->slug = 'mocked'; + $trickMock->created_at = Carbon::now(); - $trickPresenter = new TrickPresenter( + $trickPresenter = new TrickPresenter( $trickMock ); - $this->assertEquals( - 'tag:foo.com,' . $trickMock->created_at->format('Y-m-d') . ':/bar', + $this->assertEquals( + 'tag:foo.com,'.$trickMock->created_at->format('Y-m-d').':/bar', $trickPresenter->tagUri() ); } diff --git a/app/tests/Tricks/Presenters/UserPresenterTest.php b/app/tests/Tricks/Presenters/UserPresenterTest.php index a8c8047..a43a202 100644 --- a/app/tests/Tricks/Presenters/UserPresenterTest.php +++ b/app/tests/Tricks/Presenters/UserPresenterTest.php @@ -2,44 +2,38 @@ namespace Tricks\Presenters; -use Carbon\Carbon; -use HTML; use Mockery; use TestCase; -use Tricks\Category; -use Tricks\Trick; -use URL; -class UserPresenterTest -extends TestCase +class UserPresenterTest extends TestCase { - public function tearDown() - { - Mockery::close(); - } - - protected function getTrickMockWithSlug() - { - $mock = Mockery::mock('Tricks\Trick') + public function tearDown() + { + Mockery::close(); + } + + protected function getTrickMockWithSlug() + { + $mock = Mockery::mock('Tricks\Trick') ->makePartial(); - $mock->slug = 'mocked'; + $mock->slug = 'mocked'; - return $mock; - } + return $mock; + } /** * @group tricks/presenters */ public function testConstructor() { - $mock = Mockery::mock('Tricks\User'); + $mock = Mockery::mock('Tricks\User'); - $userPresenter = new UserPresenter( + $userPresenter = new UserPresenter( $mock ); - $this->assertSame( + $this->assertSame( $mock, $this->getProtectedProperty($userPresenter, 'resource') ); @@ -50,25 +44,25 @@ public function testConstructor() */ public function testLastActivity() { - $trickMock = Mockery::mock('stdClass'); + $trickMock = Mockery::mock('stdClass'); - $trickMock + $trickMock ->shouldReceive('diffForHumans') ->atLeast()->once() ->andReturn('mocked'); - $trickMock->created_at = $trickMock; + $trickMock->created_at = $trickMock; - $trickMock + $trickMock ->shouldReceive('getCollection') ->atLeast()->once() ->andReturn($trickMock); - $trickMock + $trickMock ->shouldReceive('sortBy') ->atLeast()->once() ->with( - Mockery::on(function($callback) { + Mockery::on(function ($callback) { $mock = Mockery::mock('stdClass'); $mock->created_at = 'mocked'; @@ -82,28 +76,28 @@ public function testLastActivity() ) ->andReturn($trickMock); - $trickMock + $trickMock ->shouldReceive('reverse') ->atLeast()->once() ->andReturn($trickMock); - $trickMock + $trickMock ->shouldReceive('first') ->atLeast()->once() ->andReturn($trickMock); - $userMock = Mockery::mock('Tricks\User'); + $userMock = Mockery::mock('Tricks\User'); - $userPresenter = new UserPresenter( + $userPresenter = new UserPresenter( $userMock ); - $this->assertEquals( + $this->assertEquals( 'No activity', $userPresenter->lastActivity([]) ); - $this->assertEquals( + $this->assertEquals( 'mocked', $userPresenter->lastActivity($trickMock) ); @@ -114,17 +108,17 @@ public function testLastActivity() */ public function testfullNameWithoutProfile() { - $userMock = Mockery::mock('Tricks\User') + $userMock = Mockery::mock('Tricks\User') ->makePartial(); - $userMock->username = 'foo'; - $userMock->profile = null; + $userMock->username = 'foo'; + $userMock->profile = null; - $userPresenter = new UserPresenter( + $userPresenter = new UserPresenter( $userMock ); - $this->assertEquals( + $this->assertEquals( 'foo', $userPresenter->fullName() ); @@ -135,21 +129,21 @@ public function testfullNameWithoutProfile() */ public function testfullNameWithProfile() { - $profileMock = Mockery::mock('Tricks\Profile') + $profileMock = Mockery::mock('Tricks\Profile') ->makePartial(); - $profileMock->name = 'foo'; + $profileMock->name = 'foo'; - $userMock = Mockery::mock('Tricks\User') + $userMock = Mockery::mock('Tricks\User') ->makePartial(); - - $userMock->profile = $profileMock; - $userPresenter = new UserPresenter( + $userMock->profile = $profileMock; + + $userPresenter = new UserPresenter( $userMock ); - $this->assertEquals( + $this->assertEquals( 'foo', $userPresenter->fullName() ); diff --git a/app/tests/Tricks/ProfileTest.php b/app/tests/Tricks/ProfileTest.php index 03e9984..970218b 100644 --- a/app/tests/Tricks/ProfileTest.php +++ b/app/tests/Tricks/ProfileTest.php @@ -5,28 +5,27 @@ use Mockery; use TestCase; -class ProfileTest -extends TestCase +class ProfileTest extends TestCase { - public function tearDown() - { - Mockery::close(); - } + public function tearDown() + { + Mockery::close(); + } /** * @group tricks */ public function testUser() { - $mock = Mockery::mock('Tricks\Profile') + $mock = Mockery::mock('Tricks\Profile') ->makePartial(); - $mock + $mock ->shouldReceive('belongsTo') ->atLeast()->once() ->with('Tricks\User') ->andReturn('mocked'); - $this->assertEquals('mocked', $mock->user()); + $this->assertEquals('mocked', $mock->user()); } } diff --git a/app/tests/Tricks/Providers/EventServiceProviderTest.php b/app/tests/Tricks/Providers/EventServiceProviderTest.php index f8ad115..f47543c 100644 --- a/app/tests/Tricks/Providers/EventServiceProviderTest.php +++ b/app/tests/Tricks/Providers/EventServiceProviderTest.php @@ -6,40 +6,39 @@ use Mockery; use TestCase; -class EventServiceProviderTest -extends TestCase +class EventServiceProviderTest extends TestCase { - public function tearDown() - { - Mockery::close(); - } + public function tearDown() + { + Mockery::close(); + } /** * @group tricks/providers */ public function testRegister() { - $dispatcherMock = Mockery::mock('Illuminate\Events\Dispatcher') + $dispatcherMock = Mockery::mock('Illuminate\Events\Dispatcher') ->makePartial(); - $dispatcherMock + $dispatcherMock ->shouldReceive('listen') ->atLeast()->once() ->with('trick.view', 'Tricks\Events\ViewTrickHandler'); - $applicationMock = Mockery::mock('Illuminate\Foundation\Application') + $applicationMock = Mockery::mock('Illuminate\Foundation\Application') ->makePartial(); - $applicationMock + $applicationMock ->shouldReceive('offsetGet') ->atLeast()->once() ->with('events') ->andReturn($dispatcherMock); - $provider = new EventServiceProvider( + $provider = new EventServiceProvider( $applicationMock ); - App::register($provider, [], true); + App::register($provider, [], true); } } diff --git a/app/tests/Tricks/Providers/NavigationServiceProviderTest.php b/app/tests/Tricks/Providers/NavigationServiceProviderTest.php index cb4f067..7a97994 100644 --- a/app/tests/Tricks/Providers/NavigationServiceProviderTest.php +++ b/app/tests/Tricks/Providers/NavigationServiceProviderTest.php @@ -6,26 +6,25 @@ use Mockery; use TestCase; -class NavigationServiceProviderTest -extends TestCase +class NavigationServiceProviderTest extends TestCase { - public function tearDown() - { - Mockery::close(); - } + public function tearDown() + { + Mockery::close(); + } /** * @group tricks/providers */ public function testRegister() { - $mock = Mockery::mock('Illuminate\Foundation\Application') + $mock = Mockery::mock('Illuminate\Foundation\Application') ->makePartial(); - $mock + $mock ->shouldReceive('share') ->atLeast()->once() - ->with(Mockery::on(function($callback) { + ->with(Mockery::on(function ($callback) { $mock = Mockery::mock('Illuminate\Foundation\Application') ->makePartial(); @@ -51,15 +50,15 @@ public function testRegister() })) ->andReturn('mocked'); - $mock + $mock ->shouldReceive('offsetSet') ->atLeast()->once() ->with('navigation.builder', 'mocked'); - $provider = new NavigationServiceProvider( + $provider = new NavigationServiceProvider( $mock ); - App::register($provider, [], true); + App::register($provider, [], true); } } diff --git a/app/tests/Tricks/Providers/RepositoryServiceProviderTest.php b/app/tests/Tricks/Providers/RepositoryServiceProviderTest.php index 1628444..09b6fdb 100644 --- a/app/tests/Tricks/Providers/RepositoryServiceProviderTest.php +++ b/app/tests/Tricks/Providers/RepositoryServiceProviderTest.php @@ -6,23 +6,22 @@ use Mockery; use TestCase; -class RepositoryServiceProviderTest -extends TestCase +class RepositoryServiceProviderTest extends TestCase { - public function tearDown() - { - Mockery::close(); - } + public function tearDown() + { + Mockery::close(); + } /** * @group tricks/providers */ public function testRegister() { - $mock = Mockery::mock('Illuminate\Foundation\Application') + $mock = Mockery::mock('Illuminate\Foundation\Application') ->makePartial(); - $mock + $mock ->shouldReceive('bind') ->atLeast()->once() ->with( @@ -30,7 +29,7 @@ public function testRegister() 'Tricks\Repositories\Eloquent\UserRepository' ); - $mock + $mock ->shouldReceive('bind') ->atLeast()->once() ->with( @@ -38,7 +37,7 @@ public function testRegister() 'Tricks\Repositories\Eloquent\ProfileRepository' ); - $mock + $mock ->shouldReceive('bind') ->atLeast()->once() ->with( @@ -46,7 +45,7 @@ public function testRegister() 'Tricks\Repositories\Eloquent\TrickRepository' ); - $mock + $mock ->shouldReceive('bind') ->atLeast()->once() ->with( @@ -54,7 +53,7 @@ public function testRegister() 'Tricks\Repositories\Eloquent\TagRepository' ); - $mock + $mock ->shouldReceive('bind') ->atLeast()->once() ->with( @@ -62,10 +61,10 @@ public function testRegister() 'Tricks\Repositories\Eloquent\CategoryRepository' ); - $provider = new RepositoryServiceProvider( + $provider = new RepositoryServiceProvider( $mock ); - App::register($provider, [], true); + App::register($provider, [], true); } } diff --git a/app/tests/Tricks/Providers/SitemapServiceProviderTest.php b/app/tests/Tricks/Providers/SitemapServiceProviderTest.php index 1fd3100..a3de48d 100644 --- a/app/tests/Tricks/Providers/SitemapServiceProviderTest.php +++ b/app/tests/Tricks/Providers/SitemapServiceProviderTest.php @@ -6,31 +6,30 @@ use Mockery; use TestCase; -class SitemapServiceProviderTest -extends TestCase +class SitemapServiceProviderTest extends TestCase { - public function tearDown() - { - Mockery::close(); - } + public function tearDown() + { + Mockery::close(); + } /** * @group tricks/providers */ public function testRegister() { - $mock = Mockery::mock('Illuminate\Foundation\Application') + $mock = Mockery::mock('Illuminate\Foundation\Application') ->makePartial(); - $mock + $mock ->shouldReceive('alias') ->atLeast()->once() ->with('sitemap', 'Roumen\Sitemap\Sitemap'); - $provider = new SitemapServiceProvider( + $provider = new SitemapServiceProvider( $mock ); - App::register($provider, [], true); + App::register($provider, [], true); } } diff --git a/app/tests/Tricks/Providers/SocialServiceProviderTest.php b/app/tests/Tricks/Providers/SocialServiceProviderTest.php index 87df2f3..33b0cf0 100644 --- a/app/tests/Tricks/Providers/SocialServiceProviderTest.php +++ b/app/tests/Tricks/Providers/SocialServiceProviderTest.php @@ -5,34 +5,33 @@ use Mockery; use TestCase; -class SocialServiceProviderTest -extends TestCase +class SocialServiceProviderTest extends TestCase { - public function tearDown() - { - Mockery::close(); - } + public function tearDown() + { + Mockery::close(); + } /** * @group tricks/providers */ public function testRegister() { - $mock = Mockery::mock('Tricks\Providers\SocialServiceProvider', [ - Mockery::mock('Illuminate\Foundation\Application') + $mock = Mockery::mock('Tricks\Providers\SocialServiceProvider', [ + Mockery::mock('Illuminate\Foundation\Application'), ]) ->shouldAllowMockingProtectedMethods() ->makePartial(); - $mock + $mock ->shouldReceive('registerGithub') ->atLeast()->once(); - $mock + $mock ->shouldReceive('registerDisqus') ->atLeast()->once(); - $mock->register(); + $mock->register(); } /** @@ -40,24 +39,24 @@ public function testRegister() */ public function testRegisterGithub() { - $applicationMock = Mockery::mock('Illuminate\Foundation\Application') + $applicationMock = Mockery::mock('Illuminate\Foundation\Application') ->makePartial(); - $applicationMock + $applicationMock ->shouldReceive('offsetSet') ->atLeast()->once() ->with('github.provider', 'mocked'); - $repositoryMock = Mockery::mock('Illuminate\Config\Repository') + $repositoryMock = Mockery::mock('Illuminate\Config\Repository') ->makePartial(); - $repositoryMock + $repositoryMock ->shouldReceive('get') ->atLeast()->once() ->with('social.github') ->andReturn([]); - $applicationMock + $applicationMock ->shouldReceive('offsetGet') ->atLeast()->once() ->with('config') @@ -65,11 +64,11 @@ public function testRegisterGithub() $repositoryMock ); - $applicationMock + $applicationMock ->shouldReceive('share') ->atLeast()->once() ->with( - Mockery::on(function($callback) use ($applicationMock) { + Mockery::on(function ($callback) use ($applicationMock) { $callback($applicationMock); return true; @@ -77,12 +76,12 @@ public function testRegisterGithub() ) ->andReturn('mocked'); - $applicationMock + $applicationMock ->shouldReceive('offsetSet') ->atLeast()->once() ->with('github', 'mocked'); - $applicationMock + $applicationMock ->shouldReceive('offsetGet') ->atLeast()->once() ->with('github.provider') @@ -90,7 +89,7 @@ public function testRegisterGithub() Mockery::mock('League\OAuth2\Client\Provider\Github') ); - $applicationMock + $applicationMock ->shouldReceive('offsetGet') ->atLeast()->once() ->with('Tricks\Repositories\UserRepositoryInterface') @@ -98,7 +97,7 @@ public function testRegisterGithub() Mockery::mock('Tricks\Repositories\UserRepositoryInterface') ); - $applicationMock + $applicationMock ->shouldReceive('offsetGet') ->atLeast()->once() ->with('Tricks\Repositories\ProfileRepositoryInterface') @@ -106,13 +105,13 @@ public function testRegisterGithub() Mockery::mock('Tricks\Repositories\ProfileRepositoryInterface') ); - $socialServiceProviderMock = Mockery::mock('Tricks\Providers\SocialServiceProvider', [ - $applicationMock + $socialServiceProviderMock = Mockery::mock('Tricks\Providers\SocialServiceProvider', [ + $applicationMock, ]) ->shouldAllowMockingProtectedMethods() ->makePartial(); - $socialServiceProviderMock->registerGithub(); + $socialServiceProviderMock->registerGithub(); } /** @@ -120,24 +119,24 @@ public function testRegisterGithub() */ public function testRegisterDisqus() { - $applicationMock = Mockery::mock('Illuminate\Foundation\Application') + $applicationMock = Mockery::mock('Illuminate\Foundation\Application') ->makePartial(); - $applicationMock + $applicationMock ->shouldReceive('offsetSet') ->atLeast()->once() ->with('disqus', 'mocked'); - $repositoryMock = Mockery::mock('Illuminate\Config\Repository') + $repositoryMock = Mockery::mock('Illuminate\Config\Repository') ->makePartial(); - $repositoryMock + $repositoryMock ->shouldReceive('get') ->atLeast()->once() ->with('social.disqus.requestUrl') ->andReturn('mocked'); - $applicationMock + $applicationMock ->shouldReceive('offsetGet') ->atLeast()->once() ->with('config') @@ -145,11 +144,11 @@ public function testRegisterDisqus() $repositoryMock ); - $applicationMock + $applicationMock ->shouldReceive('share') ->atLeast()->once() ->with( - Mockery::on(function($callback) use ($applicationMock) { + Mockery::on(function ($callback) use ($applicationMock) { $callback($applicationMock); return true; @@ -157,12 +156,12 @@ public function testRegisterDisqus() ) ->andReturn('mocked'); - $socialServiceProviderMock = Mockery::mock('Tricks\Providers\SocialServiceProvider', [ - $applicationMock + $socialServiceProviderMock = Mockery::mock('Tricks\Providers\SocialServiceProvider', [ + $applicationMock, ]) ->shouldAllowMockingProtectedMethods() ->makePartial(); - $socialServiceProviderMock->registerDisqus(); + $socialServiceProviderMock->registerDisqus(); } } diff --git a/app/tests/Tricks/Providers/UploadServiceProviderTest.php b/app/tests/Tricks/Providers/UploadServiceProviderTest.php index 712f5cb..f4e20c4 100644 --- a/app/tests/Tricks/Providers/UploadServiceProviderTest.php +++ b/app/tests/Tricks/Providers/UploadServiceProviderTest.php @@ -6,26 +6,25 @@ use Mockery; use TestCase; -class UploadServiceProviderTest -extends TestCase +class UploadServiceProviderTest extends TestCase { - public function tearDown() - { - Mockery::close(); - } + public function tearDown() + { + Mockery::close(); + } /** * @group tricks/providers */ public function testRegister() { - $mock = Mockery::mock('Illuminate\Foundation\Application') + $mock = Mockery::mock('Illuminate\Foundation\Application') ->makePartial(); - $mock + $mock ->shouldReceive('share') ->atLeast()->once() - ->with(Mockery::on(function($callback) { + ->with(Mockery::on(function ($callback) { $mock = Mockery::mock('Illuminate\Foundation\Application'); $mock @@ -42,15 +41,15 @@ public function testRegister() })) ->andReturn('mocked'); - $mock + $mock ->shouldReceive('offsetSet') ->atLeast()->once() ->with('upload.image', 'mocked'); - $provider = new UploadServiceProvider( + $provider = new UploadServiceProvider( $mock ); - App::register($provider, [], true); + App::register($provider, [], true); } } diff --git a/app/tests/Tricks/Repositories/Eloquent/AbstractRepositoryTest.php b/app/tests/Tricks/Repositories/Eloquent/AbstractRepositoryTest.php index 675b7d6..c977787 100644 --- a/app/tests/Tricks/Repositories/Eloquent/AbstractRepositoryTest.php +++ b/app/tests/Tricks/Repositories/Eloquent/AbstractRepositoryTest.php @@ -5,31 +5,28 @@ use Mockery; use TestCase; -class ConcreteRepository -extends AbstractRepository +class ConcreteRepository extends AbstractRepository { - } -class AbstractRepositoryTest -extends TestCase +class AbstractRepositoryTest extends TestCase { - public function tearDown() - { - Mockery::close(); - } + public function tearDown() + { + Mockery::close(); + } /** * @group tricks/repositories */ public function testConstructor() { - $modelMock = Mockery::mock('Illuminate\Database\Eloquent\Model') + $modelMock = Mockery::mock('Illuminate\Database\Eloquent\Model') ->makePartial(); - $concreteRepository = new ConcreteRepository($modelMock); + $concreteRepository = new ConcreteRepository($modelMock); - $this->assertSame( + $this->assertSame( $modelMock, $this->getProtectedProperty($concreteRepository, 'model') ); @@ -40,24 +37,24 @@ public function testConstructor() */ public function testGetNew() { - $data = [ + $data = [ 'foo' => 1, 'bar' => 2, - 'baz' => 3 + 'baz' => 3, ]; - $modelMock = Mockery::mock('Illuminate\Database\Eloquent\Model') + $modelMock = Mockery::mock('Illuminate\Database\Eloquent\Model') ->makePartial(); - $modelMock + $modelMock ->shouldReceive('newInstance') ->atLeast()->once() ->with($data) ->andReturn('mocked newInstance'); - $concreteRepository = new ConcreteRepository($modelMock); + $concreteRepository = new ConcreteRepository($modelMock); - $this->assertSame( + $this->assertSame( 'mocked newInstance', $concreteRepository->getNew($data) ); diff --git a/app/tests/Tricks/Repositories/Eloquent/CategoryRepositoryTest.php b/app/tests/Tricks/Repositories/Eloquent/CategoryRepositoryTest.php index 0e0a6a1..8206d28 100644 --- a/app/tests/Tricks/Repositories/Eloquent/CategoryRepositoryTest.php +++ b/app/tests/Tricks/Repositories/Eloquent/CategoryRepositoryTest.php @@ -6,25 +6,24 @@ use Mockery; use TestCase; -class CategoryRepositoryTest -extends TestCase +class CategoryRepositoryTest extends TestCase { - public function tearDown() - { - Mockery::close(); - } + public function tearDown() + { + Mockery::close(); + } /** * @group tricks/repositories */ public function testConstructor() { - $categoryMock = Mockery::mock('Tricks\Category') + $categoryMock = Mockery::mock('Tricks\Category') ->makePartial(); - $categoryRepository = new CategoryRepository($categoryMock); + $categoryRepository = new CategoryRepository($categoryMock); - $this->assertSame( + $this->assertSame( $categoryMock, $this->getProtectedProperty($categoryRepository, 'model') ); @@ -35,18 +34,18 @@ public function testConstructor() */ public function testListAll() { - $categoryMock = Mockery::mock('Tricks\Category') + $categoryMock = Mockery::mock('Tricks\Category') ->makePartial(); - $categoryMock + $categoryMock ->shouldReceive('lists') ->atLeast()->once() ->with('name', 'id') ->andReturn('mocked lists'); - $categoryRepository = new CategoryRepository($categoryMock); + $categoryRepository = new CategoryRepository($categoryMock); - $this->assertEquals( + $this->assertEquals( 'mocked lists', $categoryRepository->listAll() ); @@ -57,23 +56,23 @@ public function testListAll() */ public function testFindAll() { - $categoryMock = Mockery::mock('Tricks\Category') + $categoryMock = Mockery::mock('Tricks\Category') ->makePartial(); - $categoryMock + $categoryMock ->shouldReceive('orderBy') ->atLeast()->once() ->with('foo', 'bar') ->andReturn($categoryMock); - $categoryMock + $categoryMock ->shouldReceive('get') ->atLeast()->once() ->andReturn('mocked get'); - $categoryRepository = new CategoryRepository($categoryMock); + $categoryRepository = new CategoryRepository($categoryMock); - $this->assertEquals( + $this->assertEquals( 'mocked get', $categoryRepository->findAll('foo', 'bar') ); @@ -84,56 +83,56 @@ public function testFindAll() */ public function testFindAllWithTrickCount() { - $dbMock = Mockery::mock('stdClass'); + $dbMock = Mockery::mock('stdClass'); - $dbMock + $dbMock ->shouldReceive('raw') ->atLeast()->once() ->with('COUNT(tricks.id) as trick_count') ->andReturn('COUNT(tricks.id) as trick_count'); - DB::swap($dbMock); + DB::swap($dbMock); - $categoryMock = Mockery::mock('Tricks\Category') + $categoryMock = Mockery::mock('Tricks\Category') ->makePartial(); - $categoryMock + $categoryMock ->shouldReceive('leftJoin') ->atLeast()->once() ->with('category_trick', 'categories.id', '=', 'category_trick.category_id') ->andReturn($categoryMock); - $categoryMock + $categoryMock ->shouldReceive('leftJoin') ->atLeast()->once() ->with('tricks', 'tricks.id', '=', 'category_trick.trick_id') ->andReturn($categoryMock); - $categoryMock + $categoryMock ->shouldReceive('groupBy') ->atLeast()->once() ->with('categories.slug') ->andReturn($categoryMock); - $categoryMock + $categoryMock ->shouldReceive('orderBy') ->atLeast()->once() ->with('trick_count', 'desc') ->andReturn($categoryMock); - $categoryMock + $categoryMock ->shouldReceive('get') ->atLeast()->once() ->with([ 'categories.name', 'categories.slug', - 'COUNT(tricks.id) as trick_count' + 'COUNT(tricks.id) as trick_count', ]) ->andReturn('mocked get'); - $categoryRepository = new CategoryRepository($categoryMock); + $categoryRepository = new CategoryRepository($categoryMock); - $this->assertEquals( + $this->assertEquals( 'mocked get', $categoryRepository->findAllWithTrickCount() ); @@ -144,18 +143,18 @@ public function testFindAllWithTrickCount() */ public function testFindById() { - $categoryMock = Mockery::mock('Tricks\Category') + $categoryMock = Mockery::mock('Tricks\Category') ->makePartial(); - $categoryMock + $categoryMock ->shouldReceive('find') ->atLeast()->once() ->with(1) ->andReturn('mocked find'); - $categoryRepository = new CategoryRepository($categoryMock); + $categoryRepository = new CategoryRepository($categoryMock); - $this->assertEquals( + $this->assertEquals( 'mocked find', $categoryRepository->findById(1) ); @@ -166,50 +165,50 @@ public function testFindById() */ public function testCreate() { - $data = [ + $data = [ 'name' => 'a new foo', - 'description' => 'bar' + 'description' => 'bar', ]; - $categoryMock = Mockery::mock('Tricks\Category') + $categoryMock = Mockery::mock('Tricks\Category') ->makePartial(); - $categoryMock + $categoryMock ->shouldReceive('save') ->atLeast()->once(); - $categoryRepositoryMock = Mockery::mock('Tricks\Repositories\Eloquent\CategoryRepository', [ - $categoryMock + $categoryRepositoryMock = Mockery::mock('Tricks\Repositories\Eloquent\CategoryRepository', [ + $categoryMock, ]) ->shouldAllowMockingProtectedMethods() ->makePartial(); - $categoryRepositoryMock + $categoryRepositoryMock ->shouldReceive('getNew') ->atLeast()->once() ->andReturn($categoryMock); - $categoryRepositoryMock + $categoryRepositoryMock ->shouldReceive('getMaxOrder') ->atLeast()->once() ->andReturn(1); - $this->assertSame( + $this->assertSame( $categoryMock, $categoryRepositoryMock->create($data) ); - $this->assertEquals( + $this->assertEquals( 'bar', $categoryMock->description ); - $this->assertEquals( + $this->assertEquals( 2, $categoryMock->order ); - $this->incomplete('Need to mock e() and Str::slug()'); + $this->incomplete('Need to mock e() and Str::slug()'); } /** @@ -217,41 +216,41 @@ public function testCreate() */ public function testUpdate() { - $data = [ + $data = [ 'name' => 'a new foo', - 'description' => 'bar' + 'description' => 'bar', ]; - $categoryMock = Mockery::mock('Tricks\Category') + $categoryMock = Mockery::mock('Tricks\Category') ->makePartial(); - $categoryMock + $categoryMock ->shouldReceive('save') ->atLeast()->once(); - $categoryRepositoryMock = Mockery::mock('Tricks\Repositories\Eloquent\CategoryRepository', [ - $categoryMock + $categoryRepositoryMock = Mockery::mock('Tricks\Repositories\Eloquent\CategoryRepository', [ + $categoryMock, ]) ->shouldAllowMockingProtectedMethods() ->makePartial(); - $categoryRepositoryMock + $categoryRepositoryMock ->shouldReceive('findById') ->atLeast()->once() ->with(1) ->andReturn($categoryMock); - $this->assertSame( + $this->assertSame( $categoryMock, $categoryRepositoryMock->update(1, $data) ); - $this->assertEquals( + $this->assertEquals( 'bar', $categoryMock->description ); - $this->incomplete('Need to mock e() and Str::slug()'); + $this->incomplete('Need to mock e() and Str::slug()'); } /** @@ -259,18 +258,18 @@ public function testUpdate() */ public function testGetMaxOrder() { - $categoryMock = Mockery::mock('Tricks\Category') + $categoryMock = Mockery::mock('Tricks\Category') ->makePartial(); - $categoryMock + $categoryMock ->shouldReceive('max') ->atLeast()->once() ->with('order') ->andReturn('mocked max'); - $categoryRepository = new CategoryRepository($categoryMock); + $categoryRepository = new CategoryRepository($categoryMock); - $this->assertEquals( + $this->assertEquals( 'mocked max', $categoryRepository->getMaxOrder() ); @@ -281,35 +280,35 @@ public function testGetMaxOrder() */ public function testDelete() { - $categoryMock = Mockery::mock('Tricks\Category') + $categoryMock = Mockery::mock('Tricks\Category') ->makePartial(); - $categoryMock + $categoryMock ->shouldReceive('tricks') ->atLeast()->once() ->andReturn($categoryMock); - $categoryMock + $categoryMock ->shouldReceive('detach') ->atLeast()->once(); - $categoryMock + $categoryMock ->shouldReceive('delete') ->atLeast()->once(); - $categoryRepositoryMock = Mockery::mock('Tricks\Repositories\Eloquent\CategoryRepository', [ - $categoryMock + $categoryRepositoryMock = Mockery::mock('Tricks\Repositories\Eloquent\CategoryRepository', [ + $categoryMock, ]) ->shouldAllowMockingProtectedMethods() ->makePartial(); - $categoryRepositoryMock + $categoryRepositoryMock ->shouldReceive('findById') ->atLeast()->once() ->with(1) ->andReturn($categoryMock); - $categoryRepositoryMock->delete(1); + $categoryRepositoryMock->delete(1); } /** @@ -317,43 +316,42 @@ public function testDelete() */ public function testArrange() { - $data = [ - 11 => 1 + $data = [ + 11 => 1, ]; + $collectionMock = Mockery::mock('stdClass'); - $collectionMock = Mockery::mock('stdClass'); - - $categoryMock = Mockery::mock('Tricks\Category') + $categoryMock = Mockery::mock('Tricks\Category') ->makePartial(); - $categoryMock + $categoryMock ->shouldReceive('whereIn') ->atLeast()->once() ->with('id', array_values($data)) ->andReturn($categoryMock); - $categoryMock + $categoryMock ->shouldReceive('get') ->atLeast()->once() ->with(['id']) ->andReturn($collectionMock); - $categoryMock + $categoryMock ->shouldReceive('save') ->atLeast()->once(); - $collectionMock + $collectionMock ->shouldReceive('find') ->atLeast()->once() ->with(1) ->andReturn($categoryMock); - $categoryRepository = new CategoryRepository($categoryMock); + $categoryRepository = new CategoryRepository($categoryMock); - $categoryRepository->arrange($data); + $categoryRepository->arrange($data); - $this->assertSame( + $this->assertSame( 11, $categoryMock->order ); @@ -364,11 +362,11 @@ public function testArrange() */ public function testGetForm() { - $categoryRepository = new CategoryRepository( + $categoryRepository = new CategoryRepository( Mockery::mock('Tricks\Category') ); - $this->assertInstanceOf( + $this->assertInstanceOf( 'Tricks\Services\Forms\CategoryForm', $categoryRepository->getForm() ); diff --git a/app/tests/Tricks/Repositories/Eloquent/ProfileRepositoryTest.php b/app/tests/Tricks/Repositories/Eloquent/ProfileRepositoryTest.php index d0ecf6a..089300a 100644 --- a/app/tests/Tricks/Repositories/Eloquent/ProfileRepositoryTest.php +++ b/app/tests/Tricks/Repositories/Eloquent/ProfileRepositoryTest.php @@ -5,25 +5,24 @@ use Mockery; use TestCase; -class ProfileRepositoryTest -extends TestCase +class ProfileRepositoryTest extends TestCase { - public function tearDown() - { - Mockery::close(); - } + public function tearDown() + { + Mockery::close(); + } /** * @group tricks/repositories */ public function testConstructor() { - $profileMock = Mockery::mock('Tricks\Profile') + $profileMock = Mockery::mock('Tricks\Profile') ->makePartial(); - $profileRepository = new ProfileRepository($profileMock); + $profileRepository = new ProfileRepository($profileMock); - $this->assertSame( + $this->assertSame( $profileMock, $this->getProtectedProperty($profileRepository, 'model') ); @@ -34,23 +33,23 @@ public function testConstructor() */ public function testFindByUid() { - $profileMock = Mockery::mock('Tricks\Profile') + $profileMock = Mockery::mock('Tricks\Profile') ->makePartial(); - $profileMock + $profileMock ->shouldReceive('whereUid') ->atLeast()->once() ->with(1) ->andReturn($profileMock); - $profileMock + $profileMock ->shouldReceive('first') ->atLeast()->once() ->andReturn('mocked first'); - $profileRepository = new ProfileRepository($profileMock); + $profileRepository = new ProfileRepository($profileMock); - $this->assertEquals( + $this->assertEquals( 'mocked first', $profileRepository->findByUid(1) ); @@ -61,44 +60,44 @@ public function testFindByUid() */ public function testCreateFromGithubData() { - $userMock = Mockery::mock('Tricks\User') + $userMock = Mockery::mock('Tricks\User') ->makePartial(); - $userMock->id = 1; + $userMock->id = 1; - $profileMock = Mockery::mock('Tricks\Profile') + $profileMock = Mockery::mock('Tricks\Profile') ->makePartial(); - $profileMock + $profileMock ->shouldReceive('save') ->atLeast()->once(); - $detailsMock = Mockery::mock('League\OAuth2\Client\Provider\User') + $detailsMock = Mockery::mock('League\OAuth2\Client\Provider\User') ->makePartial(); - $detailsMock->uid = 1; - $detailsMock->nickname = 'foo'; - $detailsMock->name = 'bar'; - $detailsMock->email = 'foo@bar.com'; - $detailsMock->first_name = 'foobert'; - $detailsMock->lastName = 'barman'; - $detailsMock->location = 'bazton'; - $detailsMock->description = 'foo'; - $detailsMock->image_url = 'bar'; - $detailsMock->access_token = 'baz'; - - $profileRepositoryMock = Mockery::mock('Tricks\Repositories\Eloquent\ProfileRepository', [ - $profileMock + $detailsMock->uid = 1; + $detailsMock->nickname = 'foo'; + $detailsMock->name = 'bar'; + $detailsMock->email = 'foo@bar.com'; + $detailsMock->first_name = 'foobert'; + $detailsMock->lastName = 'barman'; + $detailsMock->location = 'bazton'; + $detailsMock->description = 'foo'; + $detailsMock->image_url = 'bar'; + $detailsMock->access_token = 'baz'; + + $profileRepositoryMock = Mockery::mock('Tricks\Repositories\Eloquent\ProfileRepository', [ + $profileMock, ]) ->shouldAllowMockingProtectedMethods() ->makePartial(); - $profileRepositoryMock + $profileRepositoryMock ->shouldReceive('getNew') ->atLeast()->once() ->andReturn($profileMock); - $this->assertSame( + $this->assertSame( $profileMock, $profileRepositoryMock->createFromGithubData( $detailsMock, @@ -107,7 +106,7 @@ public function testCreateFromGithubData() ) ); - $this->assertSame( + $this->assertSame( $userMock->id, $profileMock->user_id ); @@ -118,21 +117,21 @@ public function testCreateFromGithubData() */ public function testUpdateToken() { - $profileMock = Mockery::mock('Tricks\Profile') + $profileMock = Mockery::mock('Tricks\Profile') ->makePartial(); - $profileMock + $profileMock ->shouldReceive('save') ->atLeast()->once(); - $profileRepository = new ProfileRepository($profileMock); + $profileRepository = new ProfileRepository($profileMock); - $this->assertSame( + $this->assertSame( $profileMock, $profileRepository->updateToken($profileMock, 'foo') ); - $this->assertEquals( + $this->assertEquals( 'foo', $profileMock->access_token ); diff --git a/app/tests/Tricks/Services/Feeds/BuilderTest.php b/app/tests/Tricks/Services/Feeds/BuilderTest.php index 035a50f..d8bfc08 100644 --- a/app/tests/Tricks/Services/Feeds/BuilderTest.php +++ b/app/tests/Tricks/Services/Feeds/BuilderTest.php @@ -5,42 +5,41 @@ use Mockery; use TestCase; -class BuilderTest -extends TestCase +class BuilderTest extends TestCase { - public function tearDown() - { - Mockery::close(); - } + public function tearDown() + { + Mockery::close(); + } /** * @group tricks/services */ public function testConstructor() { - $trickRepositoryInterfaceMock = Mockery::mock('Tricks\Repositories\TrickRepositoryInterface'); + $trickRepositoryInterfaceMock = Mockery::mock('Tricks\Repositories\TrickRepositoryInterface'); - $responseMock = Mockery::mock('Illuminate\Http\Response'); + $responseMock = Mockery::mock('Illuminate\Http\Response'); - $environmentMock = Mockery::mock('Illuminate\View\Environment'); + $environmentMock = Mockery::mock('Illuminate\View\Environment'); - $builder = new Builder( + $builder = new Builder( $trickRepositoryInterfaceMock, $responseMock, $environmentMock ); - $this->assertSame( + $this->assertSame( $trickRepositoryInterfaceMock, $this->getProtectedProperty($builder, 'tricks') ); - $this->assertSame( + $this->assertSame( $responseMock, $this->getProtectedProperty($builder, 'response') ); - $this->assertSame( + $this->assertSame( $environmentMock, $this->getProtectedProperty($builder, 'view') ); @@ -51,15 +50,15 @@ public function testConstructor() */ public function testSetType() { - $builder = new Builder( + $builder = new Builder( Mockery::mock('Tricks\Repositories\TrickRepositoryInterface'), Mockery::mock('Illuminate\Http\Response'), Mockery::mock('Illuminate\View\Environment') ); - $builder->setType('Foo'); + $builder->setType('Foo'); - $this->assertSame( + $this->assertSame( 'foo', $this->getProtectedProperty($builder, 'type') ); @@ -70,15 +69,15 @@ public function testSetType() */ public function testSetCharset() { - $builder = new Builder( + $builder = new Builder( Mockery::mock('Tricks\Repositories\TrickRepositoryInterface'), Mockery::mock('Illuminate\Http\Response'), Mockery::mock('Illuminate\View\Environment') ); - $builder->setCharset('foo'); + $builder->setCharset('foo'); - $this->assertSame( + $this->assertSame( 'foo', $this->getProtectedProperty($builder, 'charset') ); @@ -89,46 +88,45 @@ public function testSetCharset() */ public function testRender() { - $environmentMock = Mockery::mock('Illuminate\View\Environment'); + $environmentMock = Mockery::mock('Illuminate\View\Environment'); - $responseMock = Mockery::mock('Illuminate\Http\Response') + $responseMock = Mockery::mock('Illuminate\Http\Response') ->makePartial(); - $responseMock + $responseMock ->shouldReceive('setContent') ->atLeast()->once() ->with($environmentMock); - $builderMock = Mockery::mock('Tricks\Services\Feeds\Builder', [ + $builderMock = Mockery::mock('Tricks\Services\Feeds\Builder', [ Mockery::mock('Tricks\Repositories\TrickRepositoryInterface'), $responseMock, - $environmentMock + $environmentMock, ]) ->shouldAllowMockingProtectedMethods() ->makePartial(); - $builderMock + $builderMock ->shouldReceive('setType') ->atLeast()->once() ->with('foo'); - $builderMock + $builderMock ->shouldReceive('getFeedData') ->atLeast()->once() ->andReturn([]); - $builderMock + $builderMock ->shouldReceive('prepareView') ->atLeast()->once() ->with([]) ->andReturn($environmentMock); - - $builderMock + $builderMock ->shouldReceive('prepareHeaders') ->atLeast()->once(); - $this->assertSame( + $this->assertSame( $responseMock, $builderMock->render('foo') ); @@ -139,23 +137,23 @@ public function testRender() */ public function testGetFeedData() { - $trickRepositoryInterfaceMock = Mockery::mock('Tricks\Repositories\TrickRepositoryInterface') + $trickRepositoryInterfaceMock = Mockery::mock('Tricks\Repositories\TrickRepositoryInterface') ->makePartial(); - $trickRepositoryInterfaceMock + $trickRepositoryInterfaceMock ->shouldReceive('findForFeed') ->atLeast()->once() ->andReturn('mocked'); - $builderMock = Mockery::mock('Tricks\Services\Feeds\Builder', [ + $builderMock = Mockery::mock('Tricks\Services\Feeds\Builder', [ $trickRepositoryInterfaceMock, Mockery::mock('Illuminate\Http\Response'), - Mockery::mock('Illuminate\View\Environment') + Mockery::mock('Illuminate\View\Environment'), ]) ->shouldAllowMockingProtectedMethods() ->makePartial(); - $this->assertEquals( + $this->assertEquals( ['tricks' => 'mocked'], $builderMock->getFeedData() ); @@ -166,30 +164,30 @@ public function testGetFeedData() */ public function testPrepareHeaders() { - $responseMock = Mockery::mock('Illuminate\Http\Response') + $responseMock = Mockery::mock('Illuminate\Http\Response') ->makePartial(); - $responseMock + $responseMock ->shouldReceive('header') ->atLeast()->once() ->with('Content-Type', 'bar; charset=foo'); - $builderMock = Mockery::mock('Tricks\Services\Feeds\Builder', [ + $builderMock = Mockery::mock('Tricks\Services\Feeds\Builder', [ Mockery::mock('Tricks\Repositories\TrickRepositoryInterface'), $responseMock, - Mockery::mock('Illuminate\View\Environment') + Mockery::mock('Illuminate\View\Environment'), ]) ->shouldAllowMockingProtectedMethods() ->makePartial(); - $this->setProtectedProperty($builderMock, 'charset', 'foo'); + $this->setProtectedProperty($builderMock, 'charset', 'foo'); - $builderMock + $builderMock ->shouldReceive('getContentType') ->atLeast()->once() ->andReturn('bar'); - $builderMock->prepareHeaders(); + $builderMock->prepareHeaders(); } /** @@ -197,24 +195,24 @@ public function testPrepareHeaders() */ public function testGetContentType() { - $builderMock = Mockery::mock('Tricks\Services\Feeds\Builder', [ + $builderMock = Mockery::mock('Tricks\Services\Feeds\Builder', [ Mockery::mock('Tricks\Repositories\TrickRepositoryInterface'), Mockery::mock('Illuminate\Http\Response'), - Mockery::mock('Illuminate\View\Environment') + Mockery::mock('Illuminate\View\Environment'), ]) ->shouldAllowMockingProtectedMethods() ->makePartial(); - $this->setProtectedProperty($builderMock, 'type', 'rss'); + $this->setProtectedProperty($builderMock, 'type', 'rss'); - $this->assertSame( + $this->assertSame( 'application/rss+xml', $builderMock->getContentType() ); - $this->setProtectedProperty($builderMock, 'type', 'atom'); + $this->setProtectedProperty($builderMock, 'type', 'atom'); - $this->assertSame( + $this->assertSame( 'application/atom+xml', $builderMock->getContentType() ); @@ -225,31 +223,31 @@ public function testGetContentType() */ public function testPrepareView() { - $data = ['foo' => 'bar']; + $data = ['foo' => 'bar']; - $environmentMock = Mockery::mock('Illuminate\View\Environment') + $environmentMock = Mockery::mock('Illuminate\View\Environment') ->makePartial(); - $environmentMock + $environmentMock ->shouldReceive('make') ->atLeast()->once() ->with('mocked', $data) ->andReturn('mocked'); - $builderMock = Mockery::mock('Tricks\Services\Feeds\Builder', [ + $builderMock = Mockery::mock('Tricks\Services\Feeds\Builder', [ Mockery::mock('Tricks\Repositories\TrickRepositoryInterface'), Mockery::mock('Illuminate\Http\Response'), - $environmentMock + $environmentMock, ]) ->shouldAllowMockingProtectedMethods() ->makePartial(); - $builderMock + $builderMock ->shouldReceive('getViewName') ->atLeast()->once() ->andReturn('mocked'); - $this->assertEquals( + $this->assertEquals( 'mocked', $builderMock->prepareView($data) ); @@ -260,24 +258,24 @@ public function testPrepareView() */ public function testGetViewName() { - $builderMock = Mockery::mock('Tricks\Services\Feeds\Builder', [ + $builderMock = Mockery::mock('Tricks\Services\Feeds\Builder', [ Mockery::mock('Tricks\Repositories\TrickRepositoryInterface'), Mockery::mock('Illuminate\Http\Response'), - Mockery::mock('Illuminate\View\Environment') + Mockery::mock('Illuminate\View\Environment'), ]) ->shouldAllowMockingProtectedMethods() ->makePartial(); - $this->setProtectedProperty($builderMock, 'type', 'rss'); + $this->setProtectedProperty($builderMock, 'type', 'rss'); - $this->assertSame( + $this->assertSame( 'feeds.rss', $builderMock->getViewName() ); - $this->setProtectedProperty($builderMock, 'type', 'atom'); + $this->setProtectedProperty($builderMock, 'type', 'atom'); - $this->assertSame( + $this->assertSame( 'feeds.atom', $builderMock->getViewName() ); diff --git a/app/tests/Tricks/Services/Forms/AbstractFormTest.php b/app/tests/Tricks/Services/Forms/AbstractFormTest.php index af8903c..31f7966 100644 --- a/app/tests/Tricks/Services/Forms/AbstractFormTest.php +++ b/app/tests/Tricks/Services/Forms/AbstractFormTest.php @@ -7,43 +7,40 @@ use TestCase; use Validator; -class ConcreteForm -extends AbstractForm +class ConcreteForm extends AbstractForm { - } -class AbstractFormTest -extends TestCase +class AbstractFormTest extends TestCase { - public function tearDown() - { - Mockery::close(); - } + public function tearDown() + { + Mockery::close(); + } /** * @group tricks/services */ public function testConstructor() { - $mock = Mockery::mock('stdClass'); + $mock = Mockery::mock('stdClass'); - $mock + $mock ->shouldReceive('make') ->atLeast()->once() ->with('request') ->andReturn($mock); - $mock + $mock ->shouldReceive('all') ->atLeast()->once() ->andReturn('mocked'); - App::swap($mock); + App::swap($mock); - $concreteForm = new ConcreteForm(); + $concreteForm = new ConcreteForm(); - $this->assertEquals( + $this->assertEquals( 'mocked', $this->getProtectedProperty($concreteForm, 'inputData') ); @@ -54,11 +51,11 @@ public function testConstructor() */ public function testGetInputData() { - $concreteForm = new ConcreteForm(); + $concreteForm = new ConcreteForm(); - $this->setProtectedProperty($concreteForm, 'inputData', 'mocked'); + $this->setProtectedProperty($concreteForm, 'inputData', 'mocked'); - $this->assertEquals( + $this->assertEquals( 'mocked', $concreteForm->getInputData() ); @@ -69,28 +66,28 @@ public function testGetInputData() */ public function testIsValid() { - $concreteFormMock = Mockery::mock('Tricks\Services\Forms\ConcreteForm') + $concreteFormMock = Mockery::mock('Tricks\Services\Forms\ConcreteForm') ->shouldAllowMockingProtectedMethods() ->makePartial(); - $concreteFormMock + $concreteFormMock ->shouldReceive('getInputData') ->atLeast()->once() ->andReturn(['mocked']); - $concreteFormMock + $concreteFormMock ->shouldReceive('getPreparedRules') ->atLeast()->once() ->andReturn(['mocked']); - $concreteFormMock + $concreteFormMock ->shouldReceive('getMessages') ->atLeast()->once() ->andReturn(['mocked']); - $mock = Mockery::mock('stdClass'); + $mock = Mockery::mock('stdClass'); - $mock + $mock ->shouldReceive('make') ->atLeast()->once() ->with( @@ -100,19 +97,19 @@ public function testIsValid() ) ->andReturn($mock); - $mock + $mock ->shouldReceive('passes') ->atLeast()->once() ->andReturn('mocked'); - Validator::swap($mock); + Validator::swap($mock); - $this->assertEquals( + $this->assertEquals( 'mocked', $concreteFormMock->isValid() ); - $this->assertSame( + $this->assertSame( $mock, $this->getProtectedProperty($concreteFormMock, 'validator') ); @@ -123,18 +120,18 @@ public function testIsValid() */ public function testGetErrors() { - $mock = Mockery::mock('stdClass'); + $mock = Mockery::mock('stdClass'); - $mock + $mock ->shouldReceive('errors') ->atLeast()->once() ->andReturn('mocked'); - $concreteForm = new ConcreteForm(); + $concreteForm = new ConcreteForm(); - $this->setProtectedProperty($concreteForm, 'validator', $mock); + $this->setProtectedProperty($concreteForm, 'validator', $mock); - $this->assertEquals( + $this->assertEquals( 'mocked', $concreteForm->getErrors() ); @@ -145,13 +142,13 @@ public function testGetErrors() */ public function testGetPreparedRules() { - $concreteFormMock = Mockery::mock('Tricks\Services\Forms\ConcreteForm') + $concreteFormMock = Mockery::mock('Tricks\Services\Forms\ConcreteForm') ->shouldAllowMockingProtectedMethods() ->makePartial(); - $this->setProtectedProperty($concreteFormMock, 'rules', 'mocked'); + $this->setProtectedProperty($concreteFormMock, 'rules', 'mocked'); - $this->assertEquals( + $this->assertEquals( 'mocked', $concreteFormMock->getPreparedRules() ); @@ -162,13 +159,13 @@ public function testGetPreparedRules() */ public function testGetMessages() { - $concreteFormMock = Mockery::mock('Tricks\Services\Forms\ConcreteForm') + $concreteFormMock = Mockery::mock('Tricks\Services\Forms\ConcreteForm') ->shouldAllowMockingProtectedMethods() ->makePartial(); - $this->setProtectedProperty($concreteFormMock, 'messages', 'mocked'); + $this->setProtectedProperty($concreteFormMock, 'messages', 'mocked'); - $this->assertEquals( + $this->assertEquals( 'mocked', $concreteFormMock->getMessages() ); diff --git a/app/tests/Tricks/Services/Forms/RegistrationFormTest.php b/app/tests/Tricks/Services/Forms/RegistrationFormTest.php index 884ca8b..c322d05 100644 --- a/app/tests/Tricks/Services/Forms/RegistrationFormTest.php +++ b/app/tests/Tricks/Services/Forms/RegistrationFormTest.php @@ -5,24 +5,23 @@ use Mockery; use TestCase; -class RegistrationFormTest -extends TestCase +class RegistrationFormTest extends TestCase { - public function tearDown() - { - Mockery::close(); - } + public function tearDown() + { + Mockery::close(); + } /** * @group tricks/services */ public function testConstructor() { - $repositoryMock = Mockery::mock('Illuminate\Config\Repository'); + $repositoryMock = Mockery::mock('Illuminate\Config\Repository'); - $registrationForm = new RegistrationForm($repositoryMock); + $registrationForm = new RegistrationForm($repositoryMock); - $this->assertEquals( + $this->assertEquals( $repositoryMock, $this->getProtectedProperty($registrationForm, 'config') ); @@ -33,29 +32,29 @@ public function testConstructor() */ public function testGetPreparedRules() { - $repositoryMock = Mockery::mock('Illuminate\Config\Repository'); + $repositoryMock = Mockery::mock('Illuminate\Config\Repository'); - $repositoryMock + $repositoryMock ->shouldReceive('get') ->atLeast()->once() ->with('config.forbidden_usernames') ->andReturn([ 'first', - 'second' + 'second', ]); - $registrationFormMock = Mockery::mock('Tricks\Services\Forms\RegistrationForm', [ - $repositoryMock + $registrationFormMock = Mockery::mock('Tricks\Services\Forms\RegistrationForm', [ + $repositoryMock, ]) ->shouldAllowMockingProtectedMethods() ->makePartial(); - $before = $this->getProtectedProperty($registrationFormMock, 'rules'); + $before = $this->getProtectedProperty($registrationFormMock, 'rules'); - $after = $before; - $after["username"] .= '|not_in:first,second'; + $after = $before; + $after['username'] .= '|not_in:first,second'; - $this->assertEquals( + $this->assertEquals( $after, $registrationFormMock->getPreparedRules() ); diff --git a/app/tests/Tricks/Services/Forms/SettingsFormTest.php b/app/tests/Tricks/Services/Forms/SettingsFormTest.php index 3ee981b..eb1d6aa 100644 --- a/app/tests/Tricks/Services/Forms/SettingsFormTest.php +++ b/app/tests/Tricks/Services/Forms/SettingsFormTest.php @@ -5,34 +5,33 @@ use Mockery; use TestCase; -class SettingsFormTest -extends TestCase +class SettingsFormTest extends TestCase { - public function tearDown() - { - Mockery::close(); - } + public function tearDown() + { + Mockery::close(); + } /** * @group tricks/services */ public function testConstructor() { - $repositoryMock = Mockery::mock('Illuminate\Config\Repository'); + $repositoryMock = Mockery::mock('Illuminate\Config\Repository'); - $authManagerMock = Mockery::mock('Illuminate\Auth\AuthManager'); + $authManagerMock = Mockery::mock('Illuminate\Auth\AuthManager'); - $settingsForm = new SettingsForm( + $settingsForm = new SettingsForm( $repositoryMock, $authManagerMock ); - $this->assertEquals( + $this->assertEquals( $repositoryMock, $this->getProtectedProperty($settingsForm, 'config') ); - $this->assertEquals( + $this->assertEquals( $authManagerMock, $this->getProtectedProperty($settingsForm, 'auth') ); @@ -43,39 +42,39 @@ public function testConstructor() */ public function testGetPreparedRules() { - $repositoryMock = Mockery::mock('Illuminate\Config\Repository'); + $repositoryMock = Mockery::mock('Illuminate\Config\Repository'); - $repositoryMock + $repositoryMock ->shouldReceive('get') ->atLeast()->once() ->with('config.forbidden_usernames') ->andReturn([ 'first', - 'second' + 'second', ]); - $authManagerMock = Mockery::mock('Illuminate\Auth\AuthManager'); + $authManagerMock = Mockery::mock('Illuminate\Auth\AuthManager'); - $authManagerMock + $authManagerMock ->shouldReceive('user') ->atLeast()->once() ->andReturn($authManagerMock); - $authManagerMock->id = 1; + $authManagerMock->id = 1; - $settingsFormMock = Mockery::mock('Tricks\Services\Forms\SettingsForm', [ + $settingsFormMock = Mockery::mock('Tricks\Services\Forms\SettingsForm', [ $repositoryMock, - $authManagerMock + $authManagerMock, ]) ->shouldAllowMockingProtectedMethods() ->makePartial(); - $before = $this->getProtectedProperty($settingsFormMock, 'rules'); + $before = $this->getProtectedProperty($settingsFormMock, 'rules'); - $after = $before; - $after["username"] .= '|not_in:first,second|unique:users,username,1'; + $after = $before; + $after['username'] .= '|not_in:first,second|unique:users,username,1'; - $this->assertEquals( + $this->assertEquals( $after, $settingsFormMock->getPreparedRules() ); @@ -86,27 +85,27 @@ public function testGetPreparedRules() */ public function testGetInputData() { - $before = [ + $before = [ 'username' => 'foo', 'password' => 'bar', 'password_confirmation' => '1,2,3', - 'invalid' => 'YOU SHALL NOT PASS' + 'invalid' => 'YOU SHALL NOT PASS', ]; - $after = [ + $after = [ 'username' => 'foo', 'password' => 'bar', - 'password_confirmation' => '1,2,3' + 'password_confirmation' => '1,2,3', ]; - $settingsForm = new SettingsForm( + $settingsForm = new SettingsForm( Mockery::mock('Illuminate\Config\Repository'), Mockery::mock('Illuminate\Auth\AuthManager') ); - $this->setProtectedProperty($settingsForm, 'inputData', $before); + $this->setProtectedProperty($settingsForm, 'inputData', $before); - $this->assertEquals( + $this->assertEquals( array_keys($after), array_keys($settingsForm->getInputData()) ); diff --git a/app/tests/Tricks/Services/Forms/TrickEditFormTest.php b/app/tests/Tricks/Services/Forms/TrickEditFormTest.php index 3aa4616..aedecd4 100644 --- a/app/tests/Tricks/Services/Forms/TrickEditFormTest.php +++ b/app/tests/Tricks/Services/Forms/TrickEditFormTest.php @@ -5,22 +5,21 @@ use Mockery; use TestCase; -class TrickEditFormTest -extends TestCase +class TrickEditFormTest extends TestCase { - public function tearDown() - { - Mockery::close(); - } + public function tearDown() + { + Mockery::close(); + } /** * @group tricks/services */ public function testConstructor() { - $trickEditForm = new TrickEditForm(1); + $trickEditForm = new TrickEditForm(1); - $this->assertEquals( + $this->assertEquals( 1, $this->getProtectedProperty($trickEditForm, 'id') ); @@ -31,18 +30,18 @@ public function testConstructor() */ public function testGetPreparedRules() { - $trickEditFormMock = Mockery::mock('Tricks\Services\Forms\TrickEditForm', [ - 1 + $trickEditFormMock = Mockery::mock('Tricks\Services\Forms\TrickEditForm', [ + 1, ]) ->shouldAllowMockingProtectedMethods() ->makePartial(); - $before = $this->getProtectedProperty($trickEditFormMock, 'rules'); + $before = $this->getProtectedProperty($trickEditFormMock, 'rules'); - $after = $before; - $after["title"] .= ',1'; + $after = $before; + $after['title'] .= ',1'; - $this->assertEquals( + $this->assertEquals( $after, $trickEditFormMock->getPreparedRules() ); @@ -53,28 +52,28 @@ public function testGetPreparedRules() */ public function testGetInputData() { - $before = [ + $before = [ 'title' => 'foo', 'description' => 'bar', 'tags' => '1,2,3', 'categories' => '1,2,3', 'code' => 'baz', - 'invalid' => 'YOU SHALL NOT PASS' + 'invalid' => 'YOU SHALL NOT PASS', ]; - $after = [ + $after = [ 'title' => 'foo', 'description' => 'bar', 'tags' => '1,2,3', 'categories' => '1,2,3', - 'code' => 'baz' + 'code' => 'baz', ]; - $trickEditForm = new TrickEditForm(1); + $trickEditForm = new TrickEditForm(1); - $this->setProtectedProperty($trickEditForm, 'inputData', $before); + $this->setProtectedProperty($trickEditForm, 'inputData', $before); - $this->assertEquals( + $this->assertEquals( array_keys($after), array_keys($trickEditForm->getInputData()) ); diff --git a/app/tests/Tricks/Services/Forms/TrickFormTest.php b/app/tests/Tricks/Services/Forms/TrickFormTest.php index 2876cb0..6753883 100644 --- a/app/tests/Tricks/Services/Forms/TrickFormTest.php +++ b/app/tests/Tricks/Services/Forms/TrickFormTest.php @@ -5,41 +5,40 @@ use Mockery; use TestCase; -class TrickFormTest -extends TestCase +class TrickFormTest extends TestCase { - public function tearDown() - { - Mockery::close(); - } + public function tearDown() + { + Mockery::close(); + } /** * @group tricks/services */ public function testGetInputData() { - $before = [ + $before = [ 'title' => 'foo', 'description' => 'bar', 'tags' => '1,2,3', 'categories' => '1,2,3', 'code' => 'baz', - 'invalid' => 'YOU SHALL NOT PASS' + 'invalid' => 'YOU SHALL NOT PASS', ]; - $after = [ + $after = [ 'title' => 'foo', 'description' => 'bar', 'tags' => '1,2,3', 'categories' => '1,2,3', - 'code' => 'baz' + 'code' => 'baz', ]; - $trickForm = new TrickForm(); + $trickForm = new TrickForm(); - $this->setProtectedProperty($trickForm, 'inputData', $before); + $this->setProtectedProperty($trickForm, 'inputData', $before); - $this->assertEquals( + $this->assertEquals( array_keys($after), array_keys($trickForm->getInputData()) ); diff --git a/app/tests/Tricks/Services/Upload/ImageUploadServiceTest.php b/app/tests/Tricks/Services/Upload/ImageUploadServiceTest.php index 2dab06f..5734e8e 100644 --- a/app/tests/Tricks/Services/Upload/ImageUploadServiceTest.php +++ b/app/tests/Tricks/Services/Upload/ImageUploadServiceTest.php @@ -2,51 +2,51 @@ namespace Tricks\Services\Upload; -use Intervention\Image\Image as Base; use Image; +use Intervention\Image\Image as Base; use Mockery; -use ReflectionMethod; use TestCase; $headers = []; -function header($value) { - global $headers; - $headers[] = $value; +function header($value) +{ + global $headers; + $headers[] = $value; } -function get_headers() { - global $headers; - return $headers; +function get_headers() +{ + global $headers; + + return $headers; } -class MockableImage -extends Base +class MockableImage extends Base { - public function __construct($path) - { - // nothing to see here - } + public function __construct($path) + { + // nothing to see here + } } -class ImageUploadServiceTest -extends TestCase +class ImageUploadServiceTest extends TestCase { - public function tearDown() - { - Mockery::close(); - } + public function tearDown() + { + Mockery::close(); + } /** * @group tricks/services */ public function testConstructor() { - $filesystemMock = Mockery::mock('Illuminate\Filesystem\Filesystem'); + $filesystemMock = Mockery::mock('Illuminate\Filesystem\Filesystem'); - $imageUploadService = new ImageUploadService($filesystemMock); + $imageUploadService = new ImageUploadService($filesystemMock); - $this->assertEquals( + $this->assertEquals( $filesystemMock, $this->getProtectedProperty($imageUploadService, 'filesystem') ); @@ -57,24 +57,24 @@ public function testConstructor() */ public function testEnableCORS() { - $filesystemMock = Mockery::mock('Illuminate\Filesystem\Filesystem'); + $filesystemMock = Mockery::mock('Illuminate\Filesystem\Filesystem'); - $imageUploadService = new ImageUploadService($filesystemMock); + $imageUploadService = new ImageUploadService($filesystemMock); - $imageUploadService->enableCORS('foo'); - $headers = get_headers(); + $imageUploadService->enableCORS('foo'); + $headers = get_headers(); - $this->assertContains( + $this->assertContains( 'Access-Control-Allow-Origin: foo', $headers ); - $this->assertContains( + $this->assertContains( 'Access-Control-Allow-Methods: POST, GET, OPTIONS', $headers ); - $this->assertContains( + $this->assertContains( 'Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Range, Content-Disposition, Content-Type', $headers ); @@ -85,16 +85,16 @@ public function testEnableCORS() */ public function testGetFullPath() { - $filesystemMock = Mockery::mock('Illuminate\Filesystem\Filesystem'); + $filesystemMock = Mockery::mock('Illuminate\Filesystem\Filesystem'); - $imageUploadServiceMock = Mockery::mock('Tricks\Services\Upload\ImageUploadService', [ - $filesystemMock + $imageUploadServiceMock = Mockery::mock('Tricks\Services\Upload\ImageUploadService', [ + $filesystemMock, ]) ->shouldAllowMockingProtectedMethods() ->makePartial(); - $this->assertEquals( - realpath(__DIR__ . '/../../../../../public/favicon.ico'), + $this->assertEquals( + realpath(__DIR__.'/../../../../../public/favicon.ico'), $imageUploadServiceMock->getFullPath('favicon.ico') ); } @@ -104,17 +104,17 @@ public function testGetFullPath() */ public function testMakeFilename() { - $filesystemMock = Mockery::mock('Illuminate\Filesystem\Filesystem'); + $filesystemMock = Mockery::mock('Illuminate\Filesystem\Filesystem'); - $imageUploadServiceMock = Mockery::mock('Tricks\Services\Upload\ImageUploadService', [ - $filesystemMock + $imageUploadServiceMock = Mockery::mock('Tricks\Services\Upload\ImageUploadService', [ + $filesystemMock, ]) ->shouldAllowMockingProtectedMethods() ->makePartial(); - $this->setProtectedProperty($imageUploadServiceMock, 'extension', 'foo'); + $this->setProtectedProperty($imageUploadServiceMock, 'extension', 'foo'); - $this->assertRegExp( + $this->assertRegExp( '/[0-9a-f]{40}\.foo/', $imageUploadServiceMock->makeFilename() ); @@ -125,22 +125,22 @@ public function testMakeFilename() */ public function testGetFile() { - $filesystemMock = Mockery::mock('Illuminate\Filesystem\Filesystem') + $filesystemMock = Mockery::mock('Illuminate\Filesystem\Filesystem') ->makePartial(); - $filesystemMock + $filesystemMock ->shouldReceive('get') ->atLeast()->once() ->with('foo') ->andReturn('mocked'); - $imageUploadServiceMock = Mockery::mock('Tricks\Services\Upload\ImageUploadService', [ - $filesystemMock + $imageUploadServiceMock = Mockery::mock('Tricks\Services\Upload\ImageUploadService', [ + $filesystemMock, ]) ->shouldAllowMockingProtectedMethods() ->makePartial(); - $this->assertEquals( + $this->assertEquals( 'mocked', $imageUploadServiceMock->getFile('foo') ); @@ -151,22 +151,22 @@ public function testGetFile() */ public function testGetFileSize() { - $filesystemMock = Mockery::mock('Illuminate\Filesystem\Filesystem') + $filesystemMock = Mockery::mock('Illuminate\Filesystem\Filesystem') ->makePartial(); - $filesystemMock + $filesystemMock ->shouldReceive('size') ->atLeast()->once() ->with('foo') ->andReturn('mocked'); - $imageUploadServiceMock = Mockery::mock('Tricks\Services\Upload\ImageUploadService', [ - $filesystemMock + $imageUploadServiceMock = Mockery::mock('Tricks\Services\Upload\ImageUploadService', [ + $filesystemMock, ]) ->shouldAllowMockingProtectedMethods() ->makePartial(); - $this->assertEquals( + $this->assertEquals( 'mocked', $imageUploadServiceMock->getFileSize('foo') ); @@ -177,21 +177,21 @@ public function testGetFileSize() */ public function testGetDataUrl() { - $filesystemMock = Mockery::mock('Illuminate\Filesystem\Filesystem'); + $filesystemMock = Mockery::mock('Illuminate\Filesystem\Filesystem'); - $imageUploadServiceMock = Mockery::mock('Tricks\Services\Upload\ImageUploadService', [ - $filesystemMock + $imageUploadServiceMock = Mockery::mock('Tricks\Services\Upload\ImageUploadService', [ + $filesystemMock, ]) ->shouldAllowMockingProtectedMethods() ->makePartial(); - $imageUploadServiceMock + $imageUploadServiceMock ->shouldReceive('getFile') ->atLeast()->once() ->andReturn('bar'); - $this->assertEquals( - 'data:foo;base64,' . base64_encode('bar'), + $this->assertEquals( + 'data:foo;base64,'.base64_encode('bar'), $imageUploadServiceMock->getDataUrl('foo', 'bar') ); } @@ -201,34 +201,34 @@ public function testGetDataUrl() */ public function testsGetJsonBody() { - $filesystemMock = Mockery::mock('Illuminate\Filesystem\Filesystem'); + $filesystemMock = Mockery::mock('Illuminate\Filesystem\Filesystem'); - $imageUploadServiceMock = Mockery::mock('Tricks\Services\Upload\ImageUploadService', [ - $filesystemMock + $imageUploadServiceMock = Mockery::mock('Tricks\Services\Upload\ImageUploadService', [ + $filesystemMock, ]) ->shouldAllowMockingProtectedMethods() ->makePartial(); - $imageUploadServiceMock + $imageUploadServiceMock ->shouldReceive('getFileSize') ->atLeast()->once() ->with('foo') ->andReturn('mocked'); - $imageUploadServiceMock + $imageUploadServiceMock ->shouldReceive('getDataUrl') ->atLeast()->once() ->with('bar', 'foo') ->andReturn('mocked'); - $this->assertEquals( + $this->assertEquals( [ 'images' => [ 'filename' => 'baz', 'mime' => 'bar', 'size' => 'mocked', - 'dataURL' => 'mocked' - ] + 'dataURL' => 'mocked', + ], ], $imageUploadServiceMock->getJsonBody('baz', 'bar', 'foo') ); @@ -239,6 +239,6 @@ public function testsGetJsonBody() */ public function testHandle() { - $this->incomplete('Need to mock Image::make()'); + $this->incomplete('Need to mock Image::make()'); } } diff --git a/app/tests/Tricks/TagTest.php b/app/tests/Tricks/TagTest.php index dc8e70f..d03e3b6 100644 --- a/app/tests/Tricks/TagTest.php +++ b/app/tests/Tricks/TagTest.php @@ -5,28 +5,27 @@ use Mockery; use TestCase; -class TagTest -extends TestCase +class TagTest extends TestCase { - public function tearDown() - { - Mockery::close(); - } + public function tearDown() + { + Mockery::close(); + } /** * @group tricks */ public function testTricks() { - $mock = Mockery::mock('Tricks\Tag') + $mock = Mockery::mock('Tricks\Tag') ->makePartial(); - $mock + $mock ->shouldReceive('belongsToMany') ->atLeast()->once() ->with('Tricks\Trick') ->andReturn('mocked'); - $this->assertEquals('mocked', $mock->tricks()); + $this->assertEquals('mocked', $mock->tricks()); } } diff --git a/app/tests/Tricks/TrickTest.php b/app/tests/Tricks/TrickTest.php index 61fcd87..127e44c 100644 --- a/app/tests/Tricks/TrickTest.php +++ b/app/tests/Tricks/TrickTest.php @@ -5,29 +5,28 @@ use Mockery; use TestCase; -class TrickTest -extends TestCase +class TrickTest extends TestCase { - public function tearDown() - { - Mockery::close(); - } + public function tearDown() + { + Mockery::close(); + } /** * @group tricks */ public function testVotes() { - $mock = Mockery::mock('Tricks\Trick') + $mock = Mockery::mock('Tricks\Trick') ->makePartial(); - $mock + $mock ->shouldReceive('belongsToMany') ->atLeast()->once() ->with('Tricks\User', 'votes') ->andReturn('mocked'); - $this->assertEquals('mocked', $mock->votes()); + $this->assertEquals('mocked', $mock->votes()); } /** @@ -35,16 +34,16 @@ public function testVotes() */ public function testUser() { - $mock = Mockery::mock('Tricks\Trick') + $mock = Mockery::mock('Tricks\Trick') ->makePartial(); - $mock + $mock ->shouldReceive('belongsTo') ->atLeast()->once() ->with('Tricks\User') ->andReturn('mocked'); - $this->assertEquals('mocked', $mock->user()); + $this->assertEquals('mocked', $mock->user()); } /** @@ -52,16 +51,16 @@ public function testUser() */ public function testTags() { - $mock = Mockery::mock('Tricks\Trick') + $mock = Mockery::mock('Tricks\Trick') ->makePartial(); - $mock + $mock ->shouldReceive('belongsToMany') ->atLeast()->once() ->with('Tricks\Tag') ->andReturn('mocked'); - $this->assertEquals('mocked', $mock->tags()); + $this->assertEquals('mocked', $mock->tags()); } /** @@ -69,15 +68,15 @@ public function testTags() */ public function testCategories() { - $mock = Mockery::mock('Tricks\Trick') + $mock = Mockery::mock('Tricks\Trick') ->makePartial(); - $mock + $mock ->shouldReceive('belongsToMany') ->atLeast()->once() ->with('Tricks\Category') ->andReturn('mocked'); - $this->assertEquals('mocked', $mock->categories()); + $this->assertEquals('mocked', $mock->categories()); } } diff --git a/app/tests/Tricks/UserTest.php b/app/tests/Tricks/UserTest.php index 5b714b6..b2b63de 100644 --- a/app/tests/Tricks/UserTest.php +++ b/app/tests/Tricks/UserTest.php @@ -6,29 +6,28 @@ use Mockery; use TestCase; -class UserTest -extends TestCase +class UserTest extends TestCase { - public function tearDown() - { - Mockery::close(); - } + public function tearDown() + { + Mockery::close(); + } /** * @group tricks */ public function testProfile() { - $mock = Mockery::mock('Tricks\User') + $mock = Mockery::mock('Tricks\User') ->makePartial(); - $mock + $mock ->shouldReceive('hasOne') ->atLeast()->once() ->with('Tricks\Profile') ->andReturn('mocked'); - $this->assertEquals('mocked', $mock->profile()); + $this->assertEquals('mocked', $mock->profile()); } /** @@ -36,16 +35,16 @@ public function testProfile() */ public function testTricks() { - $mock = Mockery::mock('Tricks\User') + $mock = Mockery::mock('Tricks\User') ->makePartial(); - $mock + $mock ->shouldReceive('hasMany') ->atLeast()->once() ->with('Tricks\Trick') ->andReturn('mocked'); - $this->assertEquals('mocked', $mock->tricks()); + $this->assertEquals('mocked', $mock->tricks()); } /** @@ -53,16 +52,16 @@ public function testTricks() */ public function testVotes() { - $mock = Mockery::mock('Tricks\User') + $mock = Mockery::mock('Tricks\User') ->makePartial(); - $mock + $mock ->shouldReceive('belongsToMany') ->atLeast()->once() ->with('Tricks\Trick', 'votes') ->andReturn('mocked'); - $this->assertEquals('mocked', $mock->votes()); + $this->assertEquals('mocked', $mock->votes()); } /** @@ -70,15 +69,15 @@ public function testVotes() */ public function testGetAuthIdentifier() { - $mock = Mockery::mock('Tricks\User') + $mock = Mockery::mock('Tricks\User') ->makePartial(); - $mock + $mock ->shouldReceive('getKey') ->atLeast()->once() ->andReturn('mocked'); - $this->assertEquals('mocked', $mock->getAuthIdentifier()); + $this->assertEquals('mocked', $mock->getAuthIdentifier()); } /** @@ -86,12 +85,12 @@ public function testGetAuthIdentifier() */ public function testGetAuthPassword() { - $password = 'foo'; + $password = 'foo'; - $user = new User(); - $user->password = $password; + $user = new User(); + $user->password = $password; - $this->assertEquals($password, $user->getAuthPassword()); + $this->assertEquals($password, $user->getAuthPassword()); } /** @@ -99,12 +98,12 @@ public function testGetAuthPassword() */ public function testGetPhotoCssAttribute() { - $photo = 'foo'; + $photo = 'foo'; - $user = new User(); - $user->photo = $photo; + $user = new User(); + $user->photo = $photo; - $this->assertEquals(url('img/avatar/' . $user->photo), $user->getPhotocssAttribute()); + $this->assertEquals(url('img/avatar/'.$user->photo), $user->getPhotocssAttribute()); } /** @@ -112,22 +111,22 @@ public function testGetPhotoCssAttribute() */ public function testGetGravatarPhotoCssAttribute() { - $email = 'foo'; + $email = 'foo'; - $mock = Mockery::mock('stdClass'); + $mock = Mockery::mock('stdClass'); - $mock + $mock ->shouldReceive('src') ->atLeast()->once() ->with($email, 100) ->andReturn('mocked'); - Gravatar::swap($mock); + Gravatar::swap($mock); - $user = new User(); - $user->email = $email; + $user = new User(); + $user->email = $email; - $this->assertEquals('mocked', $user->getPhotocssAttribute()); + $this->assertEquals('mocked', $user->getPhotocssAttribute()); } /** @@ -135,12 +134,12 @@ public function testGetGravatarPhotoCssAttribute() */ public function testGetReminderEmail() { - $email = 'foo'; + $email = 'foo'; - $user = new User(); - $user->email = $email; + $user = new User(); + $user->email = $email; - $this->assertEquals($email, $user->getReminderEmail()); + $this->assertEquals($email, $user->getReminderEmail()); } /** @@ -148,16 +147,16 @@ public function testGetReminderEmail() */ public function testIsAdmin() { - $user = new User(); + $user = new User(); - $this->assertFalse($user->isAdmin()); + $this->assertFalse($user->isAdmin()); - $user->is_admin = false; + $user->is_admin = false; - $this->assertFalse($user->isAdmin()); + $this->assertFalse($user->isAdmin()); - $user->is_admin = true; + $user->is_admin = true; - $this->assertTrue($user->isAdmin()); + $this->assertTrue($user->isAdmin()); } } diff --git a/bootstrap/autoload.php b/bootstrap/autoload.php index 555347c..a9fdfca 100644 --- a/bootstrap/autoload.php +++ b/bootstrap/autoload.php @@ -27,9 +27,8 @@ | */ -if (file_exists($compiled = __DIR__.'/compiled.php')) -{ - require $compiled; +if (file_exists($compiled = __DIR__.'/compiled.php')) { + require $compiled; } /* diff --git a/bootstrap/paths.php b/bootstrap/paths.php index 5a1f640..0f52811 100644 --- a/bootstrap/paths.php +++ b/bootstrap/paths.php @@ -1,57 +1,57 @@ __DIR__.'/../app', - - /* - |-------------------------------------------------------------------------- - | Public Path - |-------------------------------------------------------------------------- - | - | The public path contains the assets for your web application, such as - | your JavaScript and CSS files, and also contains the primary entry - | point for web requests into these applications from the outside. - | - */ - - 'public' => __DIR__.'/../public', - - /* - |-------------------------------------------------------------------------- - | Base Path - |-------------------------------------------------------------------------- - | - | The base path is the root of the Laravel installation. Most likely you - | will not need to change this value. But, if for some wild reason it - | is necessary you will do so here, just proceed with some caution. - | - */ - - 'base' => __DIR__.'/..', - - /* - |-------------------------------------------------------------------------- - | Storage Path - |-------------------------------------------------------------------------- - | - | The storage path is used by Laravel to store cached Blade views, logs - | and other pieces of information. You may modify the path here when - | you want to change the location of this directory for your apps. - | - */ - - 'storage' => __DIR__.'/../app/storage', - -); +return [ + + /* + |-------------------------------------------------------------------------- + | Application Path + |-------------------------------------------------------------------------- + | + | Here we just defined the path to the application directory. Most likely + | you will never need to change this value as the default setup should + | work perfectly fine for the vast majority of all our applications. + | + */ + + 'app' => __DIR__.'/../app', + + /* + |-------------------------------------------------------------------------- + | Public Path + |-------------------------------------------------------------------------- + | + | The public path contains the assets for your web application, such as + | your JavaScript and CSS files, and also contains the primary entry + | point for web requests into these applications from the outside. + | + */ + + 'public' => __DIR__.'/../public', + + /* + |-------------------------------------------------------------------------- + | Base Path + |-------------------------------------------------------------------------- + | + | The base path is the root of the Laravel installation. Most likely you + | will not need to change this value. But, if for some wild reason it + | is necessary you will do so here, just proceed with some caution. + | + */ + + 'base' => __DIR__.'/..', + + /* + |-------------------------------------------------------------------------- + | Storage Path + |-------------------------------------------------------------------------- + | + | The storage path is used by Laravel to store cached Blade views, logs + | and other pieces of information. You may modify the path here when + | you want to change the location of this directory for your apps. + | + */ + + 'storage' => __DIR__.'/../app/storage', + +]; diff --git a/bootstrap/start.php b/bootstrap/start.php index e133acb..a9b249e 100644 --- a/bootstrap/start.php +++ b/bootstrap/start.php @@ -11,7 +11,7 @@ | */ -$app = new Illuminate\Foundation\Application; +$app = new Illuminate\Foundation\Application(); /* |-------------------------------------------------------------------------- @@ -24,11 +24,11 @@ | */ -$env = $app->detectEnvironment(array( +$env = $app->detectEnvironment([ - 'local' => array('stijn-PC', 'Maxoffsky-PC','Maksim-Surguys-MacBook-Pro.local'), + 'local' => ['stijn-PC', 'Maxoffsky-PC', 'Maksim-Surguys-MacBook-Pro.local'], -)); +]); /* |-------------------------------------------------------------------------- diff --git a/bootstrap/testing.php b/bootstrap/testing.php index 8fa2b0d..165f9db 100644 --- a/bootstrap/testing.php +++ b/bootstrap/testing.php @@ -1,11 +1,11 @@ init([ 'debug' => true, 'includePaths' => [ - __DIR__ . "/../app" // testing constructors - ] + __DIR__.'/../app', // testing constructors + ], ]); diff --git a/public/img/avatar/index.php b/public/img/avatar/index.php index 73dd276..36bfa89 100644 --- a/public/img/avatar/index.php +++ b/public/img/avatar/index.php @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file + \ No newline at end of file + */ diff --git a/server.php b/server.php index 5f187f3..9b94ed3 100644 --- a/server.php +++ b/server.php @@ -11,9 +11,8 @@ // This file allows us to emulate Apache's "mod_rewrite" functionality from the // built-in PHP web server. This provides a convenient way to test a Laravel // application without having installed a "real" web server software here. -if ($uri !== '/' and file_exists($requested)) -{ - return false; +if ($uri !== '/' and file_exists($requested)) { + return false; } require_once $paths['public'].'/index.php';