Skip to content

Commit

Permalink
Adopt PSR-2 coding style
Browse files Browse the repository at this point in the history
The Laravel framework adopts the PSR-2 coding style in version 5.1.
Laravel apps *should* adopt this coding style as well. Read the
[PSR-2 coding style guide][1] for more details and check out [PHPCS][2]
to use as a code formatting tool.

[1]: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md
[2]: https://github.com/squizlabs/PHP_CodeSniffer
  • Loading branch information
laravel-shift committed Nov 23, 2018
1 parent 8beeb3f commit 82e9460
Show file tree
Hide file tree
Showing 42 changed files with 67 additions and 73 deletions.
2 changes: 1 addition & 1 deletion app/Console/Commands/ImportBusinessesCommand.php
Expand Up @@ -35,7 +35,7 @@ public function handle(CommandBus $commandBus)
$this->output->writeln('Reading ' . $file);
$csv = Reader::createFromPath($file);
$rows = $csv->fetchAssoc();
foreach($rows as $row) {
foreach ($rows as $row) {
$commandBus->handle(new ImportFromCsvRowCommand($row));
}
$this->output->writeln('Complete');
Expand Down
9 changes: 6 additions & 3 deletions app/Http/Controllers/Admin/BusinessController.php
Expand Up @@ -26,10 +26,12 @@ public function edit($id = null, BusinessRepository $repository, DoctrineUserRep
{
$business = $id ? $repository->findById($id) : new Business();

if (!empty($business->getCreatedBy()))
if (!empty($business->getCreatedBy())) {
$business->userWhoCreated = $userRepository->find($business->getCreatedBy());
if (!empty($business->getUpdatedBy()))
}
if (!empty($business->getUpdatedBy())) {
$business->userWhoLastUpdated = $userRepository->find($business->getUpdatedBy());
}

$this->authorize('view', $business);

Expand Down Expand Up @@ -120,7 +122,8 @@ public function scrapeReview(Request $request, ReviewManager $reviewManager)
return response('', 404);
}

private function renderEdit(Business $business, $errors) {
private function renderEdit(Business $business, $errors)
{
$isCreate = $business->getUid() === null;

$formAction = $isCreate ? route('admin.business.create') : route('admin.business.update', ['id' => $business->getUid()]);
Expand Down
3 changes: 1 addition & 2 deletions app/Http/Controllers/BusinessController.php
Expand Up @@ -14,8 +14,7 @@ class BusinessController extends Controller
{
public function view($id, BusinessRepository $repository)
{
if ($this->isIpRestricted())
{
if ($this->isIpRestricted()) {
return response('', 403);
}

Expand Down
1 change: 0 additions & 1 deletion app/Http/Controllers/Controller.php
Expand Up @@ -11,5 +11,4 @@
class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;

}
3 changes: 1 addition & 2 deletions app/Http/Controllers/MapController.php
Expand Up @@ -9,8 +9,7 @@ class MapController extends Controller
{
public function index(Request $request)
{
if ($this->isIpRestricted())
{
if ($this->isIpRestricted()) {
return response('', 403);
}

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Middleware/RedirectIfAuthenticated.php
Expand Up @@ -18,7 +18,7 @@ class RedirectIfAuthenticated
public function handle($request, Closure $next, $guard = null)
{
if (Auth::guard($guard)->check()) {
return redirect('/');
return redirect('/');
}

return $next($request);
Expand Down
4 changes: 2 additions & 2 deletions app/Providers/AuthServiceProvider.php
Expand Up @@ -41,7 +41,7 @@ public function boot()
// the 'accessAdmin' right. The 'can' middleware is used in routes/web.php
// on the admin routes to check for presence of the 'accessAdmin' right
// for the current user.
Gate::define('accessAdmin', function($user) {
Gate::define('accessAdmin', function ($user) {
$allowedUsersEmails = getenv('ALLOWED_USERS');
$currentUserEmail = $user->getEmail();
if ($allowedUsersEmails && $currentUserEmail) {
Expand Down Expand Up @@ -72,7 +72,7 @@ public function register()
{
$this->app->singleton(UserRepository::class, DoctrineUserRepository::class);
$this->app->singleton(FixometerSessionRepository::class, DoctrineFixometerSessionRepository::class);
$this->app->singleton(FixometerSessionService::class, function($app) {
$this->app->singleton(FixometerSessionService::class, function ($app) {
return new FixometerSessionService(
'PHPSESSID',
$app->make(CommandBus::class),
Expand Down
1 change: 0 additions & 1 deletion app/Providers/BusinessServiceProvider.php
Expand Up @@ -39,5 +39,4 @@ public function register()
$this->app->singleton(BusinessValidator::class, CustomBusinessValidator::class);
$this->app->singleton(ImportBusinessAuthorizer::class, LaravelImportBusinessAuthorizer::class);
}

}
2 changes: 1 addition & 1 deletion app/Providers/GeocoderServiceProvider.php
Expand Up @@ -30,4 +30,4 @@ public function register()
return new GeocoderImpl($this->app->make('geocoder'));
});
}
}
}
1 change: 0 additions & 1 deletion app/Providers/LocationServiceProvider.php
Expand Up @@ -29,5 +29,4 @@ public function register()
return new PlacesApi($key);
});
}

}
1 change: 0 additions & 1 deletion app/Providers/PhantomServiceProvider.php
Expand Up @@ -37,5 +37,4 @@ public function register()
return $phantom;
});
}

}
2 changes: 0 additions & 2 deletions app/Providers/RouteServiceProvider.php
Expand Up @@ -63,8 +63,6 @@ protected function mapWebRoutes()
Route::prefix('')
->group(base_path('routes/web.php'));
});


}

/**
Expand Down
1 change: 0 additions & 1 deletion app/Providers/SuggestionServiceProvider.php
Expand Up @@ -39,5 +39,4 @@ public function register()
{
$this->app->singleton(SuggestionRepository::class, DoctrineSuggestionRepository::class);
}

}
2 changes: 1 addition & 1 deletion config/business-criteria.php
Expand Up @@ -36,4 +36,4 @@
'value' => PublishingStatus::PUBLISHED
]
]
];
];
2 changes: 1 addition & 1 deletion config/doctrine-mappings.php
Expand Up @@ -159,4 +159,4 @@
]
]
]
];
];
2 changes: 1 addition & 1 deletion config/fixometer.php
Expand Up @@ -4,4 +4,4 @@
'path_to_fixometer_config' => env('FIXOMETER_CONFIG_PATH', 'fixometer/config/config.php'),
'fixometer.map_admin_roles' => [1, 2, 3],
'fixometer.map_restarter_roles' => [4]
];
];
2 changes: 1 addition & 1 deletion config/google-analytics.php
Expand Up @@ -2,4 +2,4 @@

return [
'id' => env('GA_TRACKING_ID')
];
];
4 changes: 2 additions & 2 deletions config/map.php
Expand Up @@ -4,9 +4,9 @@
'radiuses' => [
1,
2,
//3,
//3,
5,
//7,
//7,
10,
18,
],
Expand Down
3 changes: 1 addition & 2 deletions config/tactician.php
Expand Up @@ -9,7 +9,6 @@
use TheRestartProject\RepairDirectory\Application\Commands\Business\DeleteBusiness;
use \TheRestartProject\RepairDirectory\Application\Commands\Business\ImportFromHttpRequest;


return [

'handlers' => [
Expand All @@ -35,4 +34,4 @@
'authorizers' => [
ImportFromHttpRequest\ImportFromHttpRequestCommand::class => ImportFromHttpRequest\ImportFromHttpRequestAuthorizer::class,
]
];
];
2 changes: 1 addition & 1 deletion database/migrations/Version20170809101734.php
Expand Up @@ -26,4 +26,4 @@ public function down(Schema $schema)

$this->addSql('ALTER TABLE businesses DROP city');
}
}
}
6 changes: 3 additions & 3 deletions database/seeds/BusinessesTableSeeder.php
Expand Up @@ -20,7 +20,7 @@ public function run()
'description' => 'PC repairs',
'address' => '203 Mawney Road',
'postcode' => 'RM7 8BX',
'geolocation' => new Point(51.583626,0.163757),
'geolocation' => new Point(51.583626, 0.163757),
'categories' => [Category::DESKTOP],
'positiveReviewPc' => 82,
'publishingStatus' => PublishingStatus::PUBLISHED,
Expand All @@ -32,7 +32,7 @@ public function run()
'description' => 'Laptop repairs',
'address' => '203 Mawney Road',
'postcode' => 'RM7 8BX',
'geolocation' => new Point(51.583626,0.163757),
'geolocation' => new Point(51.583626, 0.163757),
'categories' => [Category::LAPTOP],
'positiveReviewPc' => 82,
'publishingStatus' => PublishingStatus::PUBLISHED,
Expand All @@ -44,7 +44,7 @@ public function run()
'description' => 'Mobile phone shop',
'address' => '7 Cranbrook Road, Ilford',
'postcode' => 'IG1 4DU',
'geolocation' => new Point(51.5589297,-0.1090134),
'geolocation' => new Point(51.5589297, -0.1090134),
'categories' => [Category::DESKTOP],
'positiveReviewPc' => 81,
'publishingStatus' => PublishingStatus::PUBLISHED,
Expand Down
1 change: 0 additions & 1 deletion routes/api.php
Expand Up @@ -19,4 +19,3 @@
Route::get('suggestion/search', 'SuggestionController@search')->name('suggestion.search');
Route::post('suggestion/add', 'SuggestionController@add')->name('suggestion.add');
});

1 change: 0 additions & 1 deletion tests/Browser/Admin/BusinessListTest.php
Expand Up @@ -102,5 +102,4 @@ function (Browser $browser) use ($user) {
}
);
}

}
1 change: 0 additions & 1 deletion tests/Browser/HomePageTest.php
Expand Up @@ -32,7 +32,6 @@ public function setUp()
{
parent::setUp();
$this->app->make('session')->flush();

}


Expand Down
5 changes: 2 additions & 3 deletions tests/DuskTestCase.php
Expand Up @@ -42,7 +42,8 @@ public static function prepare()
protected function driver()
{
return RemoteWebDriver::create(
'http://selenium:4444/wd/hub', DesiredCapabilities::chrome()
'http://selenium:4444/wd/hub',
DesiredCapabilities::chrome()
);
}

Expand All @@ -65,6 +66,4 @@ protected function setUpTraits()

return $uses;
}


}
6 changes: 4 additions & 2 deletions tests/Feature/Commands/ImportBusinessesCommandTest.php
Expand Up @@ -28,13 +28,15 @@ class ImportBusinessesCommandTest extends IntegrationTestCase
public function it_persists_businesses()
{
Artisan::call(
'restart:import:businesses', [
'restart:import:businesses',
[
'file' => base_path('data/test.csv')
]
);

$this->assertDatabaseHas(
'businesses', [
'businesses',
[
'name' => 'iRepair Centre Bath',
'address' => '12 Westgate St',
'city' => 'Bath',
Expand Down
Expand Up @@ -52,7 +52,8 @@ public function i_can_create()
$response->assertStatus(302);

$this->assertDatabaseHas(
'businesses', [
'businesses',
[
'uid' => 1,
'name' => $business->getName()
]
Expand Down Expand Up @@ -92,7 +93,8 @@ public function i_can_update()
$response->assertStatus(302);

$this->assertDatabaseHas(
'businesses', [
'businesses',
[
'uid' => 1,
'name' => 'This is a new name',
'description' => 'This is a new description.'
Expand Down
9 changes: 6 additions & 3 deletions tests/Feature/Http/Controllers/Api/BusinessControllerTest.php
Expand Up @@ -63,7 +63,8 @@ public function i_can_search_with_category()
{
$response = $this->get(
route(
'business.search', [
'business.search',
[
'category' => Category::DESKTOP
]
)
Expand Down Expand Up @@ -96,7 +97,8 @@ public function i_can_search_with_location()
{
$response = $this->get(
route(
'business.search', [
'business.search',
[
'location' => 'RM7 7JN'
]
)
Expand Down Expand Up @@ -141,7 +143,8 @@ public function i_can_search_with_category_and_location()
{
$response = $this->get(
route(
'business.search', [
'business.search',
[
'category' => Category::DESKTOP,
'location' => 'RM7 7JN'
]
Expand Down
Expand Up @@ -44,7 +44,8 @@ public function i_can_search()

$response = $this->get(
route(
'suggestion.search', [
'suggestion.search',
[
'field' => 'foo'
]
)
Expand All @@ -53,7 +54,8 @@ public function i_can_search()

$response = $this->get(
route(
'suggestion.search', [
'suggestion.search',
[
'prefix' => 'foo'
]
)
Expand All @@ -62,7 +64,8 @@ public function i_can_search()

$response = $this->get(
route(
'suggestion.search', [
'suggestion.search',
[
'field' => 'test',
'prefix' => 'foo'
]
Expand Down
Expand Up @@ -26,7 +26,7 @@ class AddSuggestionsListenerTest extends IntegrationTestCase
* be used to create and update entities and persist
* the changes.
*
* @var EntityManager
* @var EntityManager
*/
private $entityManager;

Expand Down Expand Up @@ -117,5 +117,4 @@ private function assertTestSuggestions()
]
);
}

}
Expand Up @@ -46,7 +46,8 @@ public function it_can_check_if_a_service_exists_in_the_container()
{
$container = new Container();
$container->singleton(
'existingService', function () {
'existingService',
function () {
return new \stdClass();
}
);
Expand All @@ -67,7 +68,8 @@ public function it_can_get_a_service_out_of_the_container()
{
$container = new Container();
$container->singleton(
'service', function () {
'service',
function () {
$service = new \stdClass();
$service->foo = 'bar';
return $service;
Expand Down Expand Up @@ -111,7 +113,8 @@ public function it_throws_an_exception_if_the_container_cannot_produce_the_servi

$container = new Container();
$container->singleton(
'existingService', function () {
'existingService',
function () {
throw new \RuntimeException('Something went wrong');
}
);
Expand Down

0 comments on commit 82e9460

Please sign in to comment.