-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
issue #155 - better dependency management in composer.json file
- Loading branch information
Showing
3 changed files
with
48 additions
and
4 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
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,32 @@ | ||
<?php | ||
|
||
declare (strict_types=1); | ||
|
||
namespace MakinaCorpus\DbToolsBundle\Error; | ||
|
||
class MissingDependencyException extends \RuntimeException | ||
{ | ||
/** | ||
* Create new missing dependency exception. | ||
*/ | ||
public static function create(string $package, ?string $className = null): self | ||
{ | ||
if ($className) { | ||
$message = \sprintf("'%s' dependency is missing in order to use '%s' class, please consider running 'composer require %s'", $package, $className, $package); | ||
} else { | ||
$message = \sprintf("'%s' dependency is missing, please consider running 'composer require %s'", $package, $package); | ||
} | ||
|
||
return new self($message); | ||
} | ||
|
||
/** | ||
* Check class exists, raise missing dependency exception if not. | ||
*/ | ||
public static function check(string $package, string $className): void | ||
{ | ||
if (!\class_exists($className)) { | ||
throw self::create($package, $className); | ||
} | ||
} | ||
} |