-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #336 from jolicode/code-grooming
chore: fix BC break about VerbosityLevel
- Loading branch information
Showing
2 changed files
with
59 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
namespace Castor; | ||
|
||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
trigger_deprecation('castor/console', '0.15', 'The "%s" enum is deprecated and will be removed in 1.0. Use "%s" instead.', VerbosityLevel::class, Console\Output\VerbosityLevel::class); | ||
|
||
/** | ||
* @deprecated since castor/console 0.15, to be removed in 1.0. Use \Castor\Console\Output\VerbosityLevel instead. | ||
*/ | ||
enum VerbosityLevel: int | ||
{ | ||
case NOT_CONFIGURED = -1; | ||
case QUIET = 0; | ||
case NORMAL = 1; | ||
case VERBOSE = 2; | ||
case VERY_VERBOSE = 3; | ||
case DEBUG = 4; | ||
|
||
public static function fromSymfonyOutput(OutputInterface $output): self | ||
{ | ||
return match ($output->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; | ||
} | ||
} |