Skip to content

Commit

Permalink
Remove code that is not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Sep 14, 2022
1 parent 4930e1e commit 4c656d3
Showing 1 changed file with 4 additions and 30 deletions.
34 changes: 4 additions & 30 deletions src/Exporter.php
Expand Up @@ -9,7 +9,6 @@
*/
namespace SebastianBergmann\Exporter;

use const PHP_VERSION;
use function bin2hex;
use function count;
use function get_class;
Expand All @@ -31,7 +30,6 @@
use function str_repeat;
use function str_replace;
use function var_export;
use function version_compare;
use BackedEnum;
use SebastianBergmann\RecursionContext\Context;
use SplObjectStorage;
Expand Down Expand Up @@ -121,7 +119,7 @@ public function shortenedExport(mixed $value): string
return $string;
}

if ($this->isBackedEnum($value)) {
if ($value instanceof BackedEnum) {
return sprintf(
'%s Enum (%s, %s)',
get_class($value),
Expand All @@ -130,7 +128,7 @@ public function shortenedExport(mixed $value): string
);
}

if ($this->isUnitEnum($value)) {
if ($value instanceof UnitEnum) {
return sprintf(
'%s Enum (%s)',
get_class($value),
Expand Down Expand Up @@ -254,7 +252,7 @@ private function recursiveExport(mixed &$value, int $indentation, ?Context $proc
);
}

if ($this->isBackedEnum($value)) {
if ($value instanceof BackedEnum) {
return sprintf(
'%s Enum #%d (%s, %s)',
get_class($value),
Expand All @@ -264,7 +262,7 @@ private function recursiveExport(mixed &$value, int $indentation, ?Context $proc
);
}

if ($this->isUnitEnum($value)) {
if ($value instanceof UnitEnum) {
return sprintf(
'%s Enum #%d (%s)',
get_class($value),
Expand Down Expand Up @@ -352,28 +350,4 @@ private function recursiveExport(mixed &$value, int $indentation, ?Context $proc

return var_export($value, true);
}

/**
* @todo Refactor when PHP >= 8.1 is required
*/
private function isBackedEnum(mixed $value): bool
{
if (version_compare('8.1.0', PHP_VERSION, '>')) {
return false;
}

return $value instanceof BackedEnum;
}

/**
* @todo Refactor when PHP >= 8.1 is required
*/
private function isUnitEnum(mixed $value): bool
{
if (version_compare('8.1.0', PHP_VERSION, '>')) {
return false;
}

return $value instanceof UnitEnum;
}
}

0 comments on commit 4c656d3

Please sign in to comment.