diff --git a/src/Context.php b/src/Context.php index a4c04262..affa7892 100644 --- a/src/Context.php +++ b/src/Context.php @@ -3,6 +3,7 @@ namespace Castor; use Castor\Console\Output\VerbosityLevel; +use Castor\VerbosityLevel as LegacyVerbosityLevel; class Context implements \ArrayAccess { @@ -23,7 +24,7 @@ public function __construct( public readonly bool $quiet = false, public readonly bool $allowFailure = false, public readonly bool $notify = false, - public readonly VerbosityLevel $verbosityLevel = VerbosityLevel::NOT_CONFIGURED, + public readonly VerbosityLevel|LegacyVerbosityLevel $verbosityLevel = VerbosityLevel::NOT_CONFIGURED, // Do not use this argument, it is only used internally by the application public readonly string $name = '', ) { @@ -225,7 +226,7 @@ public function withNotify(bool $notify = true): self ); } - public function withVerbosityLevel(VerbosityLevel $verbosityLevel): self + public function withVerbosityLevel(VerbosityLevel|LegacyVerbosityLevel $verbosityLevel): self { return new self( $this->data, diff --git a/src/VerbosityLevel.php b/src/VerbosityLevel.php new file mode 100644 index 00000000..fce29238 --- /dev/null +++ b/src/VerbosityLevel.php @@ -0,0 +1,56 @@ +getVerbosity()) { + OutputInterface::VERBOSITY_QUIET => self::QUIET, + OutputInterface::VERBOSITY_NORMAL => self::NORMAL, + OutputInterface::VERBOSITY_VERBOSE => self::VERBOSE, + OutputInterface::VERBOSITY_VERY_VERBOSE => self::VERY_VERBOSE, + OutputInterface::VERBOSITY_DEBUG => self::DEBUG, + }; + } + + public function isNotConfigured(): bool + { + return self::NOT_CONFIGURED === $this; + } + + public function isQuiet(): bool + { + return self::QUIET->value === $this->value; + } + + public function isVerbose(): bool + { + return self::VERBOSE->value <= $this->value; + } + + public function isVeryVerbose(): bool + { + return self::VERY_VERBOSE->value <= $this->value; + } + + public function isDebug(): bool + { + return self::DEBUG->value <= $this->value; + } +}