Skip to content

Commit

Permalink
Merge pull request #23 from cranleighschool/analysis-J2lR3V
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
fredbradley authored Jul 29, 2021
2 parents c56dd99 + 81e03c0 commit 363409a
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/Controllers/AdmissionApplicantContactController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace spkm\isams\Controllers;

use Illuminate\Http\Response;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Response;
use Illuminate\Support\Collection;
use spkm\isams\Endpoint;
use spkm\isams\Wrappers\PupilContact;
Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/AdmissionApplicantController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class AdmissionApplicantController extends Endpoint
* @return void
* @throws \Exception
*/
protected function setEndpoint():void
protected function setEndpoint(): void
{
$this->endpoint = $this->getDomain() . '/api/admissions/applicants';
}
Expand Down
8 changes: 4 additions & 4 deletions src/Endpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,13 @@ protected function response(int $expectedStatusCode, $response, $data, array $er
'errors' => $errors,
];

if (isset($response->getHeaders()[ 'Location' ])) {
$location = $response->getHeaders()[ 'Location' ][ 0 ];
if (isset($response->getHeaders()['Location'])) {
$location = $response->getHeaders()['Location'][0];
$id = ltrim(str_replace($this->endpoint, '', $location), '\//');

$json[ 'location' ] = $location;
$json['location'] = $location;
if (! empty($id)) {
$json[ 'id' ] = $id;
$json['id'] = $id;
}
}

Expand Down
1 change: 0 additions & 1 deletion src/Exceptions/ControllerNotFound.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@

class ControllerNotFound extends \Exception
{

}
1 change: 0 additions & 1 deletion src/Exceptions/MethodNotFound.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@

class MethodNotFound extends \Exception
{

}
20 changes: 7 additions & 13 deletions src/Facade.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
<?php


namespace spkm\isams;


use Illuminate\Support\Str;
use spkm\isams\Contracts\Institution;
use spkm\isams\Exceptions\ControllerNotFound;
use spkm\isams\Exceptions\MethodNotFound;

class Facade
{
/**
*
*/
private const CONTROLLER_NAMESPACE = "spkm\\isams\\Controllers\\";
private const CONTROLLER_NAMESPACE = 'spkm\\isams\\Controllers\\';
/**
* @var Institution
*/
Expand Down Expand Up @@ -47,11 +42,12 @@ public function endpoint(string $controller): self
{
$controllerClass = $this->getController($controller);
$this->controller = new $controllerClass($this->institution);

return $this;
}

/**
* Sanatizes the controller name for us, so people can use ::class notation if they wish
* Sanatizes the controller name for us, so people can use ::class notation if they wish.
*
* @param string $controllerClassName
*
Expand All @@ -64,11 +60,11 @@ private function getController(string $controllerClassName): string
return $controllerClassName;
}

if (class_exists(self::CONTROLLER_NAMESPACE.$controllerClassName)) {
return self::CONTROLLER_NAMESPACE.$controllerClassName;
if (class_exists(self::CONTROLLER_NAMESPACE . $controllerClassName)) {
return self::CONTROLLER_NAMESPACE . $controllerClassName;
}

throw new ControllerNotFound("Could not find Controller: ".$controllerClassName,
throw new ControllerNotFound('Could not find Controller: ' . $controllerClassName,
500);
}

Expand All @@ -82,11 +78,9 @@ private function getController(string $controllerClassName): string
public function callMethod(string $method, array $args = [])
{
if (! method_exists($this->controller, $method)) {
throw new MethodNotFound("Method ".$method." not found on ".get_class($this->controller));
throw new MethodNotFound('Method ' . $method . ' not found on ' . get_class($this->controller));
}

return call_user_func_array([$this->controller, $method], $args);
}


}
2 changes: 0 additions & 2 deletions src/Facades/Isams.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<?php


namespace spkm\isams\Facades;


use Illuminate\Support\Facades\Facade;

class Isams extends Facade
Expand Down
3 changes: 2 additions & 1 deletion src/IsamsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ public function boot(): void
__DIR__ . '/Config/config.php' => config_path('isams.php'),
], 'config');
}

public function register()
{
$this->app->bind('isams', function($app) {
$this->app->bind('isams', function ($app) {
return new Facade();
});
}
Expand Down

0 comments on commit 363409a

Please sign in to comment.