Skip to content

Commit

Permalink
Merge pull request #45 from benjam-es/feature/refactor
Browse files Browse the repository at this point in the history
Clean up service provider and run phpcs
  • Loading branch information
JustSteveKing authored Dec 28, 2021
2 parents 8146ea6 + e8dc545 commit cf8b869
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/Facades/Postcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Postcode extends Facade
*
* @return string
*/
protected static function getFacadeAccessor()
protected static function getFacadeAccessor(): string
{
return PostcodeService::class;
}
Expand Down
11 changes: 4 additions & 7 deletions src/PostcodesServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
namespace JustSteveKing\LaravelPostcodes;

use GuzzleHttp\Client;
use Illuminate\Validation\Rule;
use Illuminate\Support\ServiceProvider;
use JustSteveKing\LaravelPostcodes\Rules\Postcode;
use JustSteveKing\LaravelPostcodes\Service\PostcodeService;

class PostcodesServiceProvider extends ServiceProvider
Expand All @@ -28,13 +30,8 @@ public function register()
);
});

\Illuminate\Validation\Rule::macro('postcode', function () {
return new \JustSteveKing\LaravelPostcodes\Rules\Postcode(resolve(PostcodeService::class));
Rule::macro('postcode', function () {
return new Postcode(resolve(PostcodeService::class));
});
}

public function boot()
{
//
}
}
6 changes: 3 additions & 3 deletions src/Service/PostcodeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function __construct(Client $client)
public function validate(string $postcode, bool $preValidate = false): bool
{
if ($preValidate) {
return !! preg_match(config('postcodes.regex.postcode'), $postcode);
return !!preg_match(config('postcodes.regex.postcode'), $postcode);
}

return $this->getResponse("postcodes/$postcode/validate");
Expand All @@ -62,7 +62,7 @@ public function validate(string $postcode, bool $preValidate = false): bool
*/
public function validateOutcode(string $postcode): bool
{
return !! preg_match(config('postcodes.regex.outcode'), $postcode);
return !!preg_match(config('postcodes.regex.outcode'), $postcode);
}

/**
Expand Down Expand Up @@ -121,7 +121,7 @@ public function getOutwardCode(string $outwardcode): object
*/
public function getRandomPostcode()
{
return $this->getResponse("random/postcodes");
return $this->getResponse('random/postcodes');
}

/**
Expand Down

0 comments on commit cf8b869

Please sign in to comment.