From 273ccc648d53bcafb8843e6fd64f16c34288819f Mon Sep 17 00:00:00 2001 From: Nabeel Shahzad Date: Mon, 19 Mar 2018 21:01:32 -0500 Subject: [PATCH] Set some more methods as final in interfaces --- app/Interfaces/Controller.php | 2 -- app/Interfaces/Enum.php | 24 ++++++++++++++---------- app/Interfaces/Migration.php | 5 +++++ app/Interfaces/Model.php | 4 ++++ app/Interfaces/Repository.php | 4 ++++ app/Interfaces/Service.php | 4 ++++ 6 files changed, 31 insertions(+), 12 deletions(-) diff --git a/app/Interfaces/Controller.php b/app/Interfaces/Controller.php index 24ae7eb2..98c68583 100755 --- a/app/Interfaces/Controller.php +++ b/app/Interfaces/Controller.php @@ -6,8 +6,6 @@ use Illuminate\Foundation\Auth\Access\AuthorizesRequests; use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Foundation\Validation\ValidatesRequests; use Illuminate\Http\Request; -use Illuminate\Support\Facades\Validator; -use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; /** * Class Controller diff --git a/app/Interfaces/Enum.php b/app/Interfaces/Enum.php index 017b61c9..d580f1d1 100644 --- a/app/Interfaces/Enum.php +++ b/app/Interfaces/Enum.php @@ -3,15 +3,17 @@ namespace App\Interfaces; /** - * Class EnumBase - * Borrowing some features from https://github.com/myclabs/php-enum - * after this was created :) + * Borrowed some ideas from myclabs/php-enum after this was created * @package App\Models\Enums */ abstract class Enum { protected static $labels = []; protected static $cache = []; + + /** + * @var integer + */ protected $value; /** @@ -27,7 +29,7 @@ abstract class Enum * Return the value that's been set if this is an instance * @return mixed */ - public function getValue() + final public function getValue() { return $this->value; } @@ -37,7 +39,7 @@ abstract class Enum * @param $value * @return mixed */ - public static function label($value) + final public static function label($value) { if (isset(static::$labels[$value])) { return trans(static::$labels[$value]); @@ -47,7 +49,7 @@ abstract class Enum /** * Return all of the (translated) labels */ - public static function labels() + final public static function labels(): array { $labels = []; foreach (static::$labels as $key => $label) { @@ -58,9 +60,11 @@ abstract class Enum } /** - * Select box + * Select box entry items + * @param bool $add_blank + * @return array */ - public static function select($add_blank = false) + public static function select($add_blank = false): array { $labels = []; if ($add_blank) { @@ -79,7 +83,7 @@ abstract class Enum * @return array Constant name in key, constant value in value * @throws \ReflectionException */ - public static function toArray() + public static function toArray(): array { $class = static::class; if (!array_key_exists($class, static::$cache)) { @@ -94,7 +98,7 @@ abstract class Enum * @param Enum $enum * @return bool */ - protected function equals(Enum $enum): bool + final public function equals(Enum $enum): bool { return $this->getValue() === $enum->getValue() && get_called_class() == get_class($enum); } diff --git a/app/Interfaces/Migration.php b/app/Interfaces/Migration.php index c8212146..9fa1b437 100644 --- a/app/Interfaces/Migration.php +++ b/app/Interfaces/Migration.php @@ -2,6 +2,11 @@ namespace App\Interfaces; +/** + * Class Migration + * @package App\Interfaces + */ abstract class Migration extends \Illuminate\Database\Migrations\Migration { + } diff --git a/app/Interfaces/Model.php b/app/Interfaces/Model.php index 8c249ed2..5d9e0945 100644 --- a/app/Interfaces/Model.php +++ b/app/Interfaces/Model.php @@ -2,6 +2,10 @@ namespace App\Interfaces; +/** + * Class Model + * @package App\Interfaces + */ abstract class Model extends \Illuminate\Database\Eloquent\Model { diff --git a/app/Interfaces/Repository.php b/app/Interfaces/Repository.php index 8e427401..d29b7d6b 100644 --- a/app/Interfaces/Repository.php +++ b/app/Interfaces/Repository.php @@ -4,6 +4,10 @@ namespace App\Interfaces; use Illuminate\Validation\Validator; +/** + * Class Repository + * @package App\Interfaces + */ abstract class Repository extends \Prettus\Repository\Eloquent\BaseRepository { /** diff --git a/app/Interfaces/Service.php b/app/Interfaces/Service.php index 8fecf53a..2d3a6e76 100644 --- a/app/Interfaces/Service.php +++ b/app/Interfaces/Service.php @@ -2,6 +2,10 @@ namespace App\Interfaces; +/** + * Class Service + * @package App\Interfaces + */ abstract class Service {