petrknap / shorts
Set of short PHP helpers
Fund package maintenance!
Other
Installs: 31 527
Dependents: 14
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=8.1
Requires (Dev)
- ext-zlib: *
- nunomaduro/phpinsights: ^2.11
- phpstan/phpstan: ^1.12
- phpunit/phpunit: ^10.5
- squizlabs/php_codesniffer: ^3.7
Suggests
- phpunit/phpunit: Required by PHP Unit helpers
Conflicts
- phpunit/phpunit: <9|>=12
README
Exception\CouldNotProcessData
template
Template for an exception that indicates that the data could not be processed.
namespace PetrKnap\Shorts; interface ImageResizerException extends \Throwable {} /** @extends Exception\CouldNotProcessData<string> */ final class ImageResizerCouldNotResizeImage extends Exception\CouldNotProcessData implements ImageResizerException {} final class ImageResizer { public function resize(string $image) { throw new ImageResizerCouldNotResizeImage(__METHOD__, $image); } }
Exception\NotImplemented
Simple exception for prototyping purposes.
namespace PetrKnap\Shorts; final class StringablePrototype implements \Stringable { public function __toString(): string { Exception\NotImplemented::throw(__METHOD__); } }
HasRequirements
trait
Simple trait to check if requirements of your code are fulfilled.
namespace PetrKnap\Shorts; final class ServiceWithRequirements { use HasRequirements; public function __construct() { self::checkRequirements(functions: ['required_function']); } public function do(): void { required_function(); } }
It should not replace Composers require
s,
but it could improve them and check suggest
s.
Run composer require petrknap/shorts
to install it.
You can support this project via donation.
The project is licensed under the terms of the LGPL-3.0-or-later
.