Set some more methods as final in interfaces

This commit is contained in:
Nabeel Shahzad
2018-03-19 21:01:32 -05:00
parent ccf56ddec1
commit 273ccc648d
6 changed files with 31 additions and 12 deletions

View File

@@ -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

View File

@@ -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);
}

View File

@@ -2,6 +2,11 @@
namespace App\Interfaces;
/**
* Class Migration
* @package App\Interfaces
*/
abstract class Migration extends \Illuminate\Database\Migrations\Migration
{
}

View File

@@ -2,6 +2,10 @@
namespace App\Interfaces;
/**
* Class Model
* @package App\Interfaces
*/
abstract class Model extends \Illuminate\Database\Eloquent\Model
{

View File

@@ -4,6 +4,10 @@ namespace App\Interfaces;
use Illuminate\Validation\Validator;
/**
* Class Repository
* @package App\Interfaces
*/
abstract class Repository extends \Prettus\Repository\Eloquent\BaseRepository
{
/**

View File

@@ -2,6 +2,10 @@
namespace App\Interfaces;
/**
* Class Service
* @package App\Interfaces
*/
abstract class Service
{