Set some more methods as final in interfaces
This commit is contained in:
@@ -6,8 +6,6 @@ use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
|||||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Validator;
|
|
||||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Controller
|
* Class Controller
|
||||||
|
|||||||
@@ -3,15 +3,17 @@
|
|||||||
namespace App\Interfaces;
|
namespace App\Interfaces;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class EnumBase
|
* Borrowed some ideas from myclabs/php-enum after this was created
|
||||||
* Borrowing some features from https://github.com/myclabs/php-enum
|
|
||||||
* after this was created :)
|
|
||||||
* @package App\Models\Enums
|
* @package App\Models\Enums
|
||||||
*/
|
*/
|
||||||
abstract class Enum
|
abstract class Enum
|
||||||
{
|
{
|
||||||
protected static $labels = [];
|
protected static $labels = [];
|
||||||
protected static $cache = [];
|
protected static $cache = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var integer
|
||||||
|
*/
|
||||||
protected $value;
|
protected $value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -27,7 +29,7 @@ abstract class Enum
|
|||||||
* Return the value that's been set if this is an instance
|
* Return the value that's been set if this is an instance
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function getValue()
|
final public function getValue()
|
||||||
{
|
{
|
||||||
return $this->value;
|
return $this->value;
|
||||||
}
|
}
|
||||||
@@ -37,7 +39,7 @@ abstract class Enum
|
|||||||
* @param $value
|
* @param $value
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public static function label($value)
|
final public static function label($value)
|
||||||
{
|
{
|
||||||
if (isset(static::$labels[$value])) {
|
if (isset(static::$labels[$value])) {
|
||||||
return trans(static::$labels[$value]);
|
return trans(static::$labels[$value]);
|
||||||
@@ -47,7 +49,7 @@ abstract class Enum
|
|||||||
/**
|
/**
|
||||||
* Return all of the (translated) labels
|
* Return all of the (translated) labels
|
||||||
*/
|
*/
|
||||||
public static function labels()
|
final public static function labels(): array
|
||||||
{
|
{
|
||||||
$labels = [];
|
$labels = [];
|
||||||
foreach (static::$labels as $key => $label) {
|
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 = [];
|
$labels = [];
|
||||||
if ($add_blank) {
|
if ($add_blank) {
|
||||||
@@ -79,7 +83,7 @@ abstract class Enum
|
|||||||
* @return array Constant name in key, constant value in value
|
* @return array Constant name in key, constant value in value
|
||||||
* @throws \ReflectionException
|
* @throws \ReflectionException
|
||||||
*/
|
*/
|
||||||
public static function toArray()
|
public static function toArray(): array
|
||||||
{
|
{
|
||||||
$class = static::class;
|
$class = static::class;
|
||||||
if (!array_key_exists($class, static::$cache)) {
|
if (!array_key_exists($class, static::$cache)) {
|
||||||
@@ -94,7 +98,7 @@ abstract class Enum
|
|||||||
* @param Enum $enum
|
* @param Enum $enum
|
||||||
* @return bool
|
* @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);
|
return $this->getValue() === $enum->getValue() && get_called_class() == get_class($enum);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,11 @@
|
|||||||
|
|
||||||
namespace App\Interfaces;
|
namespace App\Interfaces;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Migration
|
||||||
|
* @package App\Interfaces
|
||||||
|
*/
|
||||||
abstract class Migration extends \Illuminate\Database\Migrations\Migration
|
abstract class Migration extends \Illuminate\Database\Migrations\Migration
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
namespace App\Interfaces;
|
namespace App\Interfaces;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Model
|
||||||
|
* @package App\Interfaces
|
||||||
|
*/
|
||||||
abstract class Model extends \Illuminate\Database\Eloquent\Model
|
abstract class Model extends \Illuminate\Database\Eloquent\Model
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,10 @@ namespace App\Interfaces;
|
|||||||
|
|
||||||
use Illuminate\Validation\Validator;
|
use Illuminate\Validation\Validator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Repository
|
||||||
|
* @package App\Interfaces
|
||||||
|
*/
|
||||||
abstract class Repository extends \Prettus\Repository\Eloquent\BaseRepository
|
abstract class Repository extends \Prettus\Repository\Eloquent\BaseRepository
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
namespace App\Interfaces;
|
namespace App\Interfaces;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Service
|
||||||
|
* @package App\Interfaces
|
||||||
|
*/
|
||||||
abstract class Service
|
abstract class Service
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user