mirror of
https://github.com/wiosna-dev/common-library.git
synced 2026-03-12 17:41:50 +01:00
BaseType::isCorrectType() method > make static
This commit is contained in:
@@ -187,7 +187,7 @@ trait BaseTestCaseTrait
|
||||
int $requiredArgumentsCount = 0
|
||||
): void {
|
||||
// Type of visibility is not correct?
|
||||
if (!(new OopVisibilityType())->isCorrectType($visibilityType)) {
|
||||
if (!OopVisibilityType::isCorrectType($visibilityType)) {
|
||||
throw UnknownOopVisibilityTypeException::createException($visibilityType);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,14 +33,14 @@ trait BaseTypeTestCaseTrait
|
||||
/**
|
||||
* Verifies whether given type is correct or not
|
||||
*
|
||||
* @param null|string $type Type to verify
|
||||
* @param bool $expected Information if given type is correct or not
|
||||
* @param bool $isCorrect Information if processed type is correct
|
||||
* @param bool $expected Expected information if processed type is correct
|
||||
*
|
||||
* @dataProvider provideTypeToVerify
|
||||
*/
|
||||
public function testIfGivenTypeIsCorrect(?string $type, bool $expected): void
|
||||
public function testIfGivenTypeIsCorrect(bool $isCorrect, bool $expected): void
|
||||
{
|
||||
static::assertEquals($expected, $this->getTestedTypeInstance()->isCorrectType($type));
|
||||
static::assertEquals($expected, $isCorrect);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,6 +26,17 @@ abstract class BaseType
|
||||
*/
|
||||
private $all;
|
||||
|
||||
/**
|
||||
* Returns information if given type is correct
|
||||
*
|
||||
* @param null|string $type The type to check
|
||||
* @return bool
|
||||
*/
|
||||
public static function isCorrectType(?string $type): bool
|
||||
{
|
||||
return in_array($type, (new static())->getAll(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all types
|
||||
*
|
||||
@@ -39,15 +50,4 @@ abstract class BaseType
|
||||
|
||||
return $this->all;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns information if given type is correct
|
||||
*
|
||||
* @param null|string $type The type to check
|
||||
* @return bool
|
||||
*/
|
||||
public function isCorrectType(?string $type): bool
|
||||
{
|
||||
return in_array($type, $this->getAll(), true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ class Date
|
||||
* Type of period is incorrect?
|
||||
* Nothing to do
|
||||
*/
|
||||
if (!(new DatePeriod())->isCorrectType($period)) {
|
||||
if (!DatePeriod::isCorrectType($period)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user