Remove static instance trait, remove codeCoverageIgnore annotations
This commit is contained in:
parent
47f260b5f0
commit
4c3b75c3d6
@ -26,14 +26,12 @@ use ReflectionClass;
|
|||||||
*/
|
*/
|
||||||
abstract class Enum {
|
abstract class Enum {
|
||||||
|
|
||||||
use StaticInstance;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the list of constant values for the Enum
|
* Return the list of constant values for the Enum
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected static function getConstList(): array
|
public static function getConstList(): array
|
||||||
{
|
{
|
||||||
static $self;
|
static $self;
|
||||||
|
|
||||||
@ -49,10 +47,11 @@ abstract class Enum {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Verify that a constant value is valid
|
* Verify that a constant value is valid
|
||||||
|
*
|
||||||
* @param mixed $key
|
* @param mixed $key
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
protected static function isValid($key): bool
|
public static function isValid($key): bool
|
||||||
{
|
{
|
||||||
$values = array_values(static::getConstList());
|
$values = array_values(static::getConstList());
|
||||||
return in_array($key, $values);
|
return in_array($key, $values);
|
||||||
|
@ -112,7 +112,6 @@ class Friend {
|
|||||||
/**
|
/**
|
||||||
* Iterates over parent classes to get a ReflectionProperty
|
* Iterates over parent classes to get a ReflectionProperty
|
||||||
*
|
*
|
||||||
* @codeCoverageIgnore
|
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @return ReflectionProperty|null
|
* @return ReflectionProperty|null
|
||||||
*/
|
*/
|
||||||
|
@ -1,66 +0,0 @@
|
|||||||
<?php declare(strict_types=1);
|
|
||||||
/**
|
|
||||||
* Ion
|
|
||||||
*
|
|
||||||
* Building blocks for web development
|
|
||||||
*
|
|
||||||
* PHP version 7
|
|
||||||
*
|
|
||||||
* @package Ion
|
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
|
||||||
* @copyright 2015 - 2017 Timothy J. Warren
|
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
|
||||||
* @version 2.0.0
|
|
||||||
* @link https://git.timshomepage.net/timw4mail/ion
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Aviat\Ion;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Trait to allow calling a method statically,
|
|
||||||
* as well as with an instance
|
|
||||||
*/
|
|
||||||
trait StaticInstance {
|
|
||||||
/**
|
|
||||||
* Instance for 'faking' static methods
|
|
||||||
*
|
|
||||||
* @var object
|
|
||||||
*/
|
|
||||||
private static $instance = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Call protected methods to allow for
|
|
||||||
* static and instance calling
|
|
||||||
*
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
* @param string $method
|
|
||||||
* @param array $args
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function __call(string $method, array $args)
|
|
||||||
{
|
|
||||||
$class = \get_called_class();
|
|
||||||
if (method_exists($this, $method))
|
|
||||||
{
|
|
||||||
return call_user_func_array([$this, $method], $args);
|
|
||||||
}
|
|
||||||
else if(method_exists($class, $method))
|
|
||||||
{
|
|
||||||
return static::__callStatic($method, $args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Call non-static methods statically, so that
|
|
||||||
* an instance of the class isn't required
|
|
||||||
*
|
|
||||||
* @param string $method
|
|
||||||
* @param array $args
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function __callStatic(string $method, array $args)
|
|
||||||
{
|
|
||||||
return call_user_func_array([\get_called_class(), $method], $args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// End of StaticInstance.php
|
|
@ -36,7 +36,6 @@ class HttpView extends BaseView {
|
|||||||
/**
|
/**
|
||||||
* Do a redirect
|
* Do a redirect
|
||||||
*
|
*
|
||||||
* @codeCoverageIgnore
|
|
||||||
* @param string $url
|
* @param string $url
|
||||||
* @param int $code
|
* @param int $code
|
||||||
* @return void
|
* @return void
|
||||||
@ -86,7 +85,6 @@ class HttpView extends BaseView {
|
|||||||
/**
|
/**
|
||||||
* Send the appropriate response
|
* Send the appropriate response
|
||||||
*
|
*
|
||||||
* @codeCoverageIgnore
|
|
||||||
* @throws DoubleRenderException
|
* @throws DoubleRenderException
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user