allow vendord
All checks were successful
Build, Push and Deploy / build-and-push (push) Successful in 3m3s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 16s
Build, Push and Deploy / deploy-staging (push) Successful in 32s
Build, Push and Deploy / deploy-production (push) Has been skipped
Build, Push and Deploy / cleanup (push) Successful in 1s
All checks were successful
Build, Push and Deploy / build-and-push (push) Successful in 3m3s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 16s
Build, Push and Deploy / deploy-staging (push) Successful in 32s
Build, Push and Deploy / deploy-production (push) Has been skipped
Build, Push and Deploy / cleanup (push) Successful in 1s
This commit is contained in:
21
vendor/spatie/backtrace/LICENSE.md
vendored
Normal file
21
vendor/spatie/backtrace/LICENSE.md
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Spatie bvba <info@spatie.be>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
216
vendor/spatie/backtrace/README.md
vendored
Normal file
216
vendor/spatie/backtrace/README.md
vendored
Normal file
@@ -0,0 +1,216 @@
|
||||
# A better PHP backtrace
|
||||
|
||||
[](https://packagist.org/packages/spatie/backtrace)
|
||||

|
||||
[](https://packagist.org/packages/spatie/backtrace)
|
||||
|
||||
To get the backtrace in PHP you can use the `debug_backtrace` function. By default, it can be hard to work with. The
|
||||
reported function name for a frame is skewed: it belongs to the previous frame. Also, options need to be passed using a bitmask.
|
||||
|
||||
This package provides a better way than `debug_backtrace` to work with a back trace. Here's an example:
|
||||
|
||||
```php
|
||||
// returns an array with `Spatie\Backtrace\Frame` instances
|
||||
$frames = Spatie\Backtrace\Backtrace::create()->frames();
|
||||
|
||||
$firstFrame = $frames[0];
|
||||
|
||||
$firstFrame->file; // returns the file name
|
||||
$firstFrame->lineNumber; // returns the line number
|
||||
$firstFrame->class; // returns the class name
|
||||
```
|
||||
|
||||
## Support us
|
||||
|
||||
[<img src="https://github-ads.s3.eu-central-1.amazonaws.com/backtrace.jpg?t=1" width="419px" />](https://spatie.be/github-ad-click/backtrace)
|
||||
|
||||
We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can
|
||||
support us by [buying one of our paid products](https://spatie.be/open-source/support-us).
|
||||
|
||||
We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using.
|
||||
You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards
|
||||
on [our virtual postcard wall](https://spatie.be/open-source/postcards).
|
||||
|
||||
## Installation
|
||||
|
||||
You can install the package via composer:
|
||||
|
||||
```bash
|
||||
composer require spatie/backtrace
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
This is how you can create a backtrace instance:
|
||||
|
||||
```php
|
||||
$backtrace = Spatie\Backtrace\Backtrace::create();
|
||||
```
|
||||
|
||||
### Getting the frames
|
||||
|
||||
To get all the frames you can call `frames`.
|
||||
|
||||
```php
|
||||
$frames = $backtrace->frames(); // contains an array with `Spatie\Backtrace\Frame` instances
|
||||
```
|
||||
|
||||
A `Spatie\Backtrace\Frame` has these properties:
|
||||
|
||||
- `file`: the name of the file
|
||||
- `lineNumber`: the line number
|
||||
- `arguments`: the arguments used for this frame. Will be `null` if `withArguments` was not used.
|
||||
- `class`: the class name for this frame. Will be `null` if the frame concerns a function.
|
||||
- `method`: the method used in this frame
|
||||
- `object`: the object when the frame is in an object context (method call, closure bound to object, arrow function which captured `$this`, etc.). Will be `null` if `withObject` was not used.
|
||||
- `applicationFrame`: contains `true` is this frame belongs to your application, and `false` if it belongs to a file in
|
||||
the vendor directory. A couple edge cases exist, see "application frames" below.
|
||||
|
||||
### Collecting arguments and objects
|
||||
|
||||
For performance reasons, the frames of the back trace will not contain the arguments of the called functions and the
|
||||
object. If you want to add those, use the `withArguments` and `withObject` methods.
|
||||
|
||||
```php
|
||||
$backtrace = Spatie\Backtrace\Backtrace::create()->withArguments()->withObject();
|
||||
```
|
||||
|
||||
#### Reducing arguments
|
||||
|
||||
For viewing purposes, arguments can be reduced to a string:
|
||||
|
||||
```php
|
||||
$backtrace = Spatie\Backtrace\Backtrace::create()->withArguments()->reduceArguments();
|
||||
```
|
||||
|
||||
By default, some typical types will be reduced to a string. You can define your own reduction algorithm per type by implementing an `ArgumentReducer`:
|
||||
|
||||
```php
|
||||
class DateTimeWithOtherFormatArgumentReducer implements ArgumentReducer
|
||||
{
|
||||
public function execute($argument): ReducedArgumentContract
|
||||
{
|
||||
if (! $argument instanceof DateTimeInterface) {
|
||||
return UnReducedArgument::create();
|
||||
}
|
||||
|
||||
return new ReducedArgument(
|
||||
$argument->format('d/m/y H:i'),
|
||||
get_class($argument),
|
||||
);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
This is a copy of the built-in argument reducer for `DateTimeInterface` where we've updated the format. An `UnReducedArgument` object is returned when the argument is not of the expected type. A `ReducedArgument` object is returned with the reduced value of the argument and the original type of the argument.
|
||||
|
||||
The reducer can be used as such:
|
||||
|
||||
```php
|
||||
$backtrace = Spatie\Backtrace\Backtrace::create()->withArguments()->reduceArguments(
|
||||
Spatie\Backtrace\Arguments\ArgumentReducers::default([
|
||||
new DateTimeWithOtherFormatArgumentReducer()
|
||||
])
|
||||
);
|
||||
```
|
||||
|
||||
Which will first execute the new reducer and then the default ones.
|
||||
|
||||
### Setting the application path
|
||||
|
||||
You can use the `applicationPath` to pass the base path of your app. This value will be used to determine whether a
|
||||
frame is an application frame, or a vendor frame. Here's an example using a Laravel specific function.
|
||||
|
||||
```php
|
||||
$backtrace = Spatie\Backtrace\Backtrace::create()->applicationPath(base_path());
|
||||
```
|
||||
### Removing the application path from the file name
|
||||
|
||||
You can use `trimFilePaths` to remove the base path of your app from the file. This will only work if you use it in conjunction with the `applicationPath` method re above. Here's an example using a Laravel specific function. This will ensure the Frame has the trimmedFilePath property set.
|
||||
|
||||
```php
|
||||
$backtrace = Backtrace::create()->applicationPath(base_path())->trimFilePaths());
|
||||
```
|
||||
|
||||
### Application frames
|
||||
|
||||
By default, a frame is considered an application frame when the file of the frame is not in the vendor directory. The following edge cases apply:
|
||||
|
||||
- Laravel's `artisan` CLI file (generally found in the root of the project) is considered a vendor file and frame
|
||||
- Statamic's `please` CLI file (generally found in the root of the project) is considered a vendor file and frame
|
||||
|
||||
### Getting a certain part of a trace
|
||||
|
||||
If you only want to have the frames starting from a particular frame in the backtrace you can use
|
||||
the `startingFromFrame` method:
|
||||
|
||||
```php
|
||||
use Spatie\Backtrace\Backtrace;
|
||||
use Spatie\Backtrace\Frame;
|
||||
|
||||
$frames = Backtrace::create()
|
||||
->startingFromFrame(function (Frame $frame) {
|
||||
return $frame->class === MyClass::class;
|
||||
})
|
||||
->frames();
|
||||
```
|
||||
|
||||
With this code, all frames before the frame that concerns `MyClass` will have been filtered out.
|
||||
|
||||
Alternatively, you can use the `offset` method, which will skip the given number of frames. In this example the first 2 frames will not end up in `$frames`.
|
||||
|
||||
```php
|
||||
$frames = Spatie\Backtrace\Backtrace::create()
|
||||
->offset(2)
|
||||
->frames();
|
||||
```
|
||||
|
||||
### Limiting the number of frames
|
||||
|
||||
To only get a specific number of frames use the `limit` function. In this example, we'll only get the first two frames.
|
||||
|
||||
```php
|
||||
$frames = Spatie\Backtrace\Backtrace::create()
|
||||
->limit(2)
|
||||
->frames();
|
||||
```
|
||||
|
||||
### Getting a backtrace for a throwable
|
||||
|
||||
Here's how you can get a backtrace for a throwable.
|
||||
|
||||
```php
|
||||
$frames = Spatie\Backtrace\Backtrace::createForThrowable($throwable)
|
||||
```
|
||||
|
||||
Because we will use the backtrace that is already available in the throwable, the frames will contain the arguments used
|
||||
in the backtrace as long as the `zend.exception_ignore_args` INI option is disabled (set to `0`) *before* the throwable
|
||||
is thrown. On the other hand, objects will never be included in the backtrace.
|
||||
[More information](https://www.php.net/manual/en/throwable.gettrace.php#129087).
|
||||
|
||||
## Testing
|
||||
|
||||
``` bash
|
||||
composer test
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
|
||||
|
||||
## Contributing
|
||||
|
||||
Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.
|
||||
|
||||
## Security Vulnerabilities
|
||||
|
||||
Please review [our security policy](../../security/policy) on how to report security vulnerabilities.
|
||||
|
||||
## Credits
|
||||
|
||||
- [Freek Van de Herten](https://github.com/freekmurze)
|
||||
- [All Contributors](../../contributors)
|
||||
|
||||
## License
|
||||
|
||||
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
|
||||
59
vendor/spatie/backtrace/composer.json
vendored
Normal file
59
vendor/spatie/backtrace/composer.json
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
{
|
||||
"name": "spatie/backtrace",
|
||||
"description": "A better backtrace",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"spatie",
|
||||
"backtrace"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Freek Van de Herten",
|
||||
"email": "freek@spatie.be",
|
||||
"homepage": "https://spatie.be",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"homepage": "https://github.com/spatie/backtrace",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/spatie"
|
||||
},
|
||||
{
|
||||
"type": "other",
|
||||
"url": "https://spatie.be/open-source/support-us"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.3 || ^8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"ext-json": "*",
|
||||
"laravel/serializable-closure": "^1.3 || ^2.0",
|
||||
"phpunit/phpunit": "^9.3 || ^11.4.3",
|
||||
"spatie/phpunit-snapshot-assertions": "^4.2 || ^5.1.6",
|
||||
"symfony/var-dumper": "^5.1 || ^6.0 || ^7.0"
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true,
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Spatie\\Backtrace\\": "src"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Spatie\\Backtrace\\Tests\\": "tests"
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"sort-packages": true
|
||||
},
|
||||
"scripts": {
|
||||
"format": "vendor/bin/php-cs-fixer fix --allow-risky=yes",
|
||||
"psalm": "vendor/bin/psalm",
|
||||
"test": "vendor/bin/phpunit",
|
||||
"test-coverage": "vendor/bin/phpunit --coverage-html coverage"
|
||||
}
|
||||
}
|
||||
81
vendor/spatie/backtrace/src/Arguments/ArgumentReducers.php
vendored
Normal file
81
vendor/spatie/backtrace/src/Arguments/ArgumentReducers.php
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Backtrace\Arguments;
|
||||
|
||||
use Spatie\Backtrace\Arguments\Reducers\ArgumentReducer;
|
||||
use Spatie\Backtrace\Arguments\Reducers\ArrayArgumentReducer;
|
||||
use Spatie\Backtrace\Arguments\Reducers\BaseTypeArgumentReducer;
|
||||
use Spatie\Backtrace\Arguments\Reducers\ClosureArgumentReducer;
|
||||
use Spatie\Backtrace\Arguments\Reducers\DateTimeArgumentReducer;
|
||||
use Spatie\Backtrace\Arguments\Reducers\DateTimeZoneArgumentReducer;
|
||||
use Spatie\Backtrace\Arguments\Reducers\EnumArgumentReducer;
|
||||
use Spatie\Backtrace\Arguments\Reducers\MinimalArrayArgumentReducer;
|
||||
use Spatie\Backtrace\Arguments\Reducers\SensitiveParameterArrayReducer;
|
||||
use Spatie\Backtrace\Arguments\Reducers\StdClassArgumentReducer;
|
||||
use Spatie\Backtrace\Arguments\Reducers\StringableArgumentReducer;
|
||||
use Spatie\Backtrace\Arguments\Reducers\SymphonyRequestArgumentReducer;
|
||||
|
||||
class ArgumentReducers
|
||||
{
|
||||
/** @var array<int, ArgumentReducer> */
|
||||
public $argumentReducers = [];
|
||||
|
||||
/**
|
||||
* @param array<ArgumentReducer|class-string<ArgumentReducer>> $argumentReducers
|
||||
*/
|
||||
public static function create(array $argumentReducers): self
|
||||
{
|
||||
return new self(array_map(
|
||||
function ($argumentReducer) {
|
||||
/** @var $argumentReducer ArgumentReducer|class-string<ArgumentReducer> */
|
||||
return $argumentReducer instanceof ArgumentReducer ? $argumentReducer : new $argumentReducer();
|
||||
},
|
||||
$argumentReducers
|
||||
));
|
||||
}
|
||||
|
||||
public static function default(array $extra = []): self
|
||||
{
|
||||
return new self(static::defaultReducers($extra));
|
||||
}
|
||||
|
||||
public static function minimal(array $extra = []): self
|
||||
{
|
||||
return new self(static::minimalReducers($extra));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, ArgumentReducer> $argumentReducers
|
||||
*/
|
||||
protected function __construct(array $argumentReducers)
|
||||
{
|
||||
$this->argumentReducers = $argumentReducers;
|
||||
}
|
||||
|
||||
protected static function defaultReducers(array $extra = []): array
|
||||
{
|
||||
return array_merge($extra, [
|
||||
new BaseTypeArgumentReducer(),
|
||||
new ArrayArgumentReducer(),
|
||||
new StdClassArgumentReducer(),
|
||||
new EnumArgumentReducer(),
|
||||
new ClosureArgumentReducer(),
|
||||
new SensitiveParameterArrayReducer(),
|
||||
new DateTimeArgumentReducer(),
|
||||
new DateTimeZoneArgumentReducer(),
|
||||
new SymphonyRequestArgumentReducer(),
|
||||
new StringableArgumentReducer(),
|
||||
]);
|
||||
}
|
||||
|
||||
protected static function minimalReducers(array $extra = []): array
|
||||
{
|
||||
return array_merge($extra, [
|
||||
new BaseTypeArgumentReducer(),
|
||||
new MinimalArrayArgumentReducer(),
|
||||
new EnumArgumentReducer(),
|
||||
new ClosureArgumentReducer(),
|
||||
new SensitiveParameterArrayReducer(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
118
vendor/spatie/backtrace/src/Arguments/ProvidedArgument.php
vendored
Normal file
118
vendor/spatie/backtrace/src/Arguments/ProvidedArgument.php
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Backtrace\Arguments;
|
||||
|
||||
use ReflectionParameter;
|
||||
use Spatie\Backtrace\Arguments\ReducedArgument\ReducedArgument;
|
||||
use Spatie\Backtrace\Arguments\ReducedArgument\TruncatedReducedArgument;
|
||||
|
||||
class ProvidedArgument
|
||||
{
|
||||
/** @var string */
|
||||
public $name;
|
||||
|
||||
/** @var bool */
|
||||
public $passedByReference = false;
|
||||
|
||||
/** @var bool */
|
||||
public $isVariadic = false;
|
||||
|
||||
/** @var bool */
|
||||
public $hasDefaultValue = false;
|
||||
|
||||
/** @var mixed */
|
||||
public $defaultValue = null;
|
||||
|
||||
/** @var bool */
|
||||
public $defaultValueUsed = false;
|
||||
|
||||
/** @var bool */
|
||||
public $truncated = false;
|
||||
|
||||
/** @var mixed */
|
||||
public $reducedValue = null;
|
||||
|
||||
/** @var string|null */
|
||||
public $originalType = null;
|
||||
|
||||
public static function fromReflectionParameter(ReflectionParameter $parameter): self
|
||||
{
|
||||
return new self(
|
||||
$parameter->getName(),
|
||||
$parameter->isPassedByReference(),
|
||||
$parameter->isVariadic(),
|
||||
$parameter->isDefaultValueAvailable(),
|
||||
$parameter->isDefaultValueAvailable() ? $parameter->getDefaultValue() : null,
|
||||
);
|
||||
}
|
||||
|
||||
public static function fromNonReflectableParameter(
|
||||
int $index
|
||||
): self {
|
||||
return new self(
|
||||
"arg{$index}",
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
||||
public function __construct(
|
||||
string $name,
|
||||
bool $passedByReference = false,
|
||||
bool $isVariadic = false,
|
||||
bool $hasDefaultValue = false,
|
||||
$defaultValue = null,
|
||||
bool $defaultValueUsed = false,
|
||||
bool $truncated = false,
|
||||
$reducedValue = null,
|
||||
?string $originalType = null
|
||||
) {
|
||||
$this->originalType = $originalType;
|
||||
$this->reducedValue = $reducedValue;
|
||||
$this->truncated = $truncated;
|
||||
$this->defaultValueUsed = $defaultValueUsed;
|
||||
$this->defaultValue = $defaultValue;
|
||||
$this->hasDefaultValue = $hasDefaultValue;
|
||||
$this->isVariadic = $isVariadic;
|
||||
$this->passedByReference = $passedByReference;
|
||||
$this->name = $name;
|
||||
|
||||
if ($this->isVariadic) {
|
||||
$this->defaultValue = [];
|
||||
}
|
||||
}
|
||||
|
||||
public function setReducedArgument(
|
||||
ReducedArgument $reducedArgument
|
||||
): self {
|
||||
$this->reducedValue = $reducedArgument->value;
|
||||
$this->originalType = $reducedArgument->originalType;
|
||||
|
||||
if ($reducedArgument instanceof TruncatedReducedArgument) {
|
||||
$this->truncated = true;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function defaultValueUsed(): self
|
||||
{
|
||||
$this->defaultValueUsed = true;
|
||||
$this->originalType = get_debug_type($this->defaultValue);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'name' => $this->name,
|
||||
'value' => $this->defaultValueUsed
|
||||
? $this->defaultValue
|
||||
: $this->reducedValue,
|
||||
'original_type' => $this->originalType,
|
||||
'passed_by_reference' => $this->passedByReference,
|
||||
'is_variadic' => $this->isVariadic,
|
||||
'truncated' => $this->truncated,
|
||||
];
|
||||
}
|
||||
}
|
||||
44
vendor/spatie/backtrace/src/Arguments/ReduceArgumentPayloadAction.php
vendored
Normal file
44
vendor/spatie/backtrace/src/Arguments/ReduceArgumentPayloadAction.php
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Backtrace\Arguments;
|
||||
|
||||
use Spatie\Backtrace\Arguments\ReducedArgument\ReducedArgument;
|
||||
|
||||
class ReduceArgumentPayloadAction
|
||||
{
|
||||
/** @var \Spatie\Backtrace\Arguments\ArgumentReducers */
|
||||
protected $argumentReducers;
|
||||
|
||||
public function __construct(
|
||||
ArgumentReducers $argumentReducers
|
||||
) {
|
||||
$this->argumentReducers = $argumentReducers;
|
||||
}
|
||||
|
||||
public function reduce($argument, bool $includeObjectType = false): ReducedArgument
|
||||
{
|
||||
foreach ($this->argumentReducers->argumentReducers as $reducer) {
|
||||
$reduced = $reducer->execute($argument);
|
||||
|
||||
if ($reduced instanceof ReducedArgument) {
|
||||
return $reduced;
|
||||
}
|
||||
}
|
||||
|
||||
if (gettype($argument) === 'object' && $includeObjectType) {
|
||||
return new ReducedArgument(
|
||||
'object ('.get_class($argument).')',
|
||||
get_debug_type($argument),
|
||||
);
|
||||
}
|
||||
|
||||
if (gettype($argument) === 'object') {
|
||||
return new ReducedArgument('object', get_debug_type($argument), );
|
||||
}
|
||||
|
||||
return new ReducedArgument(
|
||||
$argument,
|
||||
get_debug_type($argument),
|
||||
);
|
||||
}
|
||||
}
|
||||
117
vendor/spatie/backtrace/src/Arguments/ReduceArgumentsAction.php
vendored
Normal file
117
vendor/spatie/backtrace/src/Arguments/ReduceArgumentsAction.php
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Backtrace\Arguments;
|
||||
|
||||
use ReflectionException;
|
||||
use ReflectionFunction;
|
||||
use ReflectionMethod;
|
||||
use ReflectionParameter;
|
||||
use Spatie\Backtrace\Arguments\ReducedArgument\VariadicReducedArgument;
|
||||
use Throwable;
|
||||
|
||||
class ReduceArgumentsAction
|
||||
{
|
||||
/** @var ArgumentReducers */
|
||||
protected $argumentReducers;
|
||||
|
||||
/** @var ReduceArgumentPayloadAction */
|
||||
protected $reduceArgumentPayloadAction;
|
||||
|
||||
public function __construct(
|
||||
ArgumentReducers $argumentReducers
|
||||
) {
|
||||
$this->argumentReducers = $argumentReducers;
|
||||
$this->reduceArgumentPayloadAction = new ReduceArgumentPayloadAction($argumentReducers);
|
||||
}
|
||||
|
||||
public function execute(
|
||||
?string $class,
|
||||
?string $method,
|
||||
?array $frameArguments
|
||||
): ?array {
|
||||
try {
|
||||
if ($frameArguments === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$parameters = $this->getParameters($class, $method);
|
||||
|
||||
if ($parameters === null) {
|
||||
$arguments = [];
|
||||
|
||||
foreach ($frameArguments as $index => $argument) {
|
||||
$arguments[$index] = ProvidedArgument::fromNonReflectableParameter($index)
|
||||
->setReducedArgument($this->reduceArgumentPayloadAction->reduce($argument))
|
||||
->toArray();
|
||||
}
|
||||
|
||||
return $arguments;
|
||||
}
|
||||
|
||||
$arguments = array_map(
|
||||
function ($argument) {
|
||||
return $this->reduceArgumentPayloadAction->reduce($argument);
|
||||
},
|
||||
$frameArguments,
|
||||
);
|
||||
|
||||
$argumentsCount = count($arguments);
|
||||
$hasVariadicParameter = false;
|
||||
|
||||
foreach ($parameters as $index => $parameter) {
|
||||
if ($index + 1 > $argumentsCount) {
|
||||
$parameter->defaultValueUsed();
|
||||
} elseif ($parameter->isVariadic) {
|
||||
$parameter->setReducedArgument(new VariadicReducedArgument(array_slice($arguments, $index)));
|
||||
|
||||
$hasVariadicParameter = true;
|
||||
} else {
|
||||
$parameter->setReducedArgument($arguments[$index]);
|
||||
}
|
||||
|
||||
$parameters[$index] = $parameter->toArray();
|
||||
}
|
||||
|
||||
if ($this->moreArgumentsProvidedThanParameters($arguments, $parameters, $hasVariadicParameter)) {
|
||||
for ($i = count($parameters); $i < count($arguments); $i++) {
|
||||
$parameters[$i] = ProvidedArgument::fromNonReflectableParameter(count($parameters))
|
||||
->setReducedArgument($arguments[$i])
|
||||
->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
return $parameters;
|
||||
} catch (Throwable $e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/** @return null|Array<\Spatie\Backtrace\Arguments\ProvidedArgument> */
|
||||
protected function getParameters(
|
||||
?string $class,
|
||||
?string $method
|
||||
): ?array {
|
||||
try {
|
||||
$reflection = $class !== null
|
||||
? new ReflectionMethod($class, $method)
|
||||
: new ReflectionFunction($method);
|
||||
} catch (ReflectionException $e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return array_map(
|
||||
function (ReflectionParameter $reflectionParameter) {
|
||||
return ProvidedArgument::fromReflectionParameter($reflectionParameter);
|
||||
},
|
||||
$reflection->getParameters(),
|
||||
);
|
||||
}
|
||||
|
||||
protected function moreArgumentsProvidedThanParameters(
|
||||
array $arguments,
|
||||
array $parameters,
|
||||
bool $hasVariadicParameter
|
||||
): bool {
|
||||
return count($arguments) > count($parameters) && ! $hasVariadicParameter;
|
||||
}
|
||||
}
|
||||
23
vendor/spatie/backtrace/src/Arguments/ReducedArgument/ReducedArgument.php
vendored
Normal file
23
vendor/spatie/backtrace/src/Arguments/ReducedArgument/ReducedArgument.php
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Backtrace\Arguments\ReducedArgument;
|
||||
|
||||
class ReducedArgument implements ReducedArgumentContract
|
||||
{
|
||||
/** @var mixed */
|
||||
public $value;
|
||||
|
||||
/** @var string */
|
||||
public $originalType;
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function __construct(
|
||||
$value,
|
||||
string $originalType
|
||||
) {
|
||||
$this->originalType = $originalType;
|
||||
$this->value = $value;
|
||||
}
|
||||
}
|
||||
8
vendor/spatie/backtrace/src/Arguments/ReducedArgument/ReducedArgumentContract.php
vendored
Normal file
8
vendor/spatie/backtrace/src/Arguments/ReducedArgument/ReducedArgumentContract.php
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Backtrace\Arguments\ReducedArgument;
|
||||
|
||||
interface ReducedArgumentContract
|
||||
{
|
||||
|
||||
}
|
||||
8
vendor/spatie/backtrace/src/Arguments/ReducedArgument/TruncatedReducedArgument.php
vendored
Normal file
8
vendor/spatie/backtrace/src/Arguments/ReducedArgument/TruncatedReducedArgument.php
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Backtrace\Arguments\ReducedArgument;
|
||||
|
||||
class TruncatedReducedArgument extends ReducedArgument
|
||||
{
|
||||
|
||||
}
|
||||
22
vendor/spatie/backtrace/src/Arguments/ReducedArgument/UnReducedArgument.php
vendored
Normal file
22
vendor/spatie/backtrace/src/Arguments/ReducedArgument/UnReducedArgument.php
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Backtrace\Arguments\ReducedArgument;
|
||||
|
||||
class UnReducedArgument implements ReducedArgumentContract
|
||||
{
|
||||
/** @var self|null */
|
||||
private static $instance = null;
|
||||
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public static function create(): self
|
||||
{
|
||||
if (self::$instance !== null) {
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
return self::$instance = new self();
|
||||
}
|
||||
}
|
||||
21
vendor/spatie/backtrace/src/Arguments/ReducedArgument/VariadicReducedArgument.php
vendored
Normal file
21
vendor/spatie/backtrace/src/Arguments/ReducedArgument/VariadicReducedArgument.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Backtrace\Arguments\ReducedArgument;
|
||||
|
||||
use Exception;
|
||||
|
||||
class VariadicReducedArgument extends ReducedArgument
|
||||
{
|
||||
public function __construct(array $value)
|
||||
{
|
||||
foreach ($value as $key => $item) {
|
||||
if (! $item instanceof ReducedArgument) {
|
||||
throw new Exception('VariadicReducedArgument must be an array of ReducedArgument');
|
||||
}
|
||||
|
||||
$value[$key] = $item->value;
|
||||
}
|
||||
|
||||
parent::__construct($value, 'array');
|
||||
}
|
||||
}
|
||||
13
vendor/spatie/backtrace/src/Arguments/Reducers/ArgumentReducer.php
vendored
Normal file
13
vendor/spatie/backtrace/src/Arguments/Reducers/ArgumentReducer.php
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Backtrace\Arguments\Reducers;
|
||||
|
||||
use Spatie\Backtrace\Arguments\ReducedArgument\ReducedArgumentContract;
|
||||
|
||||
interface ArgumentReducer
|
||||
{
|
||||
/**
|
||||
* @param mixed $argument
|
||||
*/
|
||||
public function execute($argument): ReducedArgumentContract;
|
||||
}
|
||||
52
vendor/spatie/backtrace/src/Arguments/Reducers/ArrayArgumentReducer.php
vendored
Normal file
52
vendor/spatie/backtrace/src/Arguments/Reducers/ArrayArgumentReducer.php
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Backtrace\Arguments\Reducers;
|
||||
|
||||
use Spatie\Backtrace\Arguments\ArgumentReducers;
|
||||
use Spatie\Backtrace\Arguments\ReduceArgumentPayloadAction;
|
||||
use Spatie\Backtrace\Arguments\ReducedArgument\ReducedArgument;
|
||||
use Spatie\Backtrace\Arguments\ReducedArgument\ReducedArgumentContract;
|
||||
use Spatie\Backtrace\Arguments\ReducedArgument\TruncatedReducedArgument;
|
||||
use Spatie\Backtrace\Arguments\ReducedArgument\UnReducedArgument;
|
||||
|
||||
class ArrayArgumentReducer implements ReducedArgumentContract
|
||||
{
|
||||
/** @var int */
|
||||
protected $maxArraySize = 25;
|
||||
|
||||
/** @var \Spatie\Backtrace\Arguments\ReduceArgumentPayloadAction */
|
||||
protected $reduceArgumentPayloadAction;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->reduceArgumentPayloadAction = new ReduceArgumentPayloadAction(ArgumentReducers::minimal());
|
||||
}
|
||||
|
||||
public function execute($argument): ReducedArgumentContract
|
||||
{
|
||||
if (! is_array($argument)) {
|
||||
return UnReducedArgument::create();
|
||||
}
|
||||
|
||||
return $this->reduceArgument($argument, 'array');
|
||||
}
|
||||
|
||||
protected function reduceArgument(array $argument, string $originalType): ReducedArgumentContract
|
||||
{
|
||||
foreach ($argument as $key => $value) {
|
||||
$argument[$key] = $this->reduceArgumentPayloadAction->reduce(
|
||||
$value,
|
||||
true
|
||||
)->value;
|
||||
}
|
||||
|
||||
if (count($argument) > $this->maxArraySize) {
|
||||
return new TruncatedReducedArgument(
|
||||
array_slice($argument, 0, $this->maxArraySize),
|
||||
'array'
|
||||
);
|
||||
}
|
||||
|
||||
return new ReducedArgument($argument, $originalType);
|
||||
}
|
||||
}
|
||||
24
vendor/spatie/backtrace/src/Arguments/Reducers/BaseTypeArgumentReducer.php
vendored
Normal file
24
vendor/spatie/backtrace/src/Arguments/Reducers/BaseTypeArgumentReducer.php
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Backtrace\Arguments\Reducers;
|
||||
|
||||
use Spatie\Backtrace\Arguments\ReducedArgument\ReducedArgument;
|
||||
use Spatie\Backtrace\Arguments\ReducedArgument\ReducedArgumentContract;
|
||||
use Spatie\Backtrace\Arguments\ReducedArgument\UnReducedArgument;
|
||||
|
||||
class BaseTypeArgumentReducer implements ArgumentReducer
|
||||
{
|
||||
public function execute($argument): ReducedArgumentContract
|
||||
{
|
||||
if (is_int($argument)
|
||||
|| is_float($argument)
|
||||
|| is_bool($argument)
|
||||
|| is_string($argument)
|
||||
|| $argument === null
|
||||
) {
|
||||
return new ReducedArgument($argument, get_debug_type($argument));
|
||||
}
|
||||
|
||||
return UnReducedArgument::create();
|
||||
}
|
||||
}
|
||||
30
vendor/spatie/backtrace/src/Arguments/Reducers/ClosureArgumentReducer.php
vendored
Normal file
30
vendor/spatie/backtrace/src/Arguments/Reducers/ClosureArgumentReducer.php
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Backtrace\Arguments\Reducers;
|
||||
|
||||
use Closure;
|
||||
use ReflectionFunction;
|
||||
use Spatie\Backtrace\Arguments\ReducedArgument\ReducedArgument;
|
||||
use Spatie\Backtrace\Arguments\ReducedArgument\ReducedArgumentContract;
|
||||
use Spatie\Backtrace\Arguments\ReducedArgument\UnReducedArgument;
|
||||
|
||||
class ClosureArgumentReducer implements ArgumentReducer
|
||||
{
|
||||
public function execute($argument): ReducedArgumentContract
|
||||
{
|
||||
if (! $argument instanceof Closure) {
|
||||
return UnReducedArgument::create();
|
||||
}
|
||||
|
||||
$reflection = new ReflectionFunction($argument);
|
||||
|
||||
if ($reflection->getFileName() && $reflection->getStartLine() && $reflection->getEndLine()) {
|
||||
return new ReducedArgument(
|
||||
"{$reflection->getFileName()}:{$reflection->getStartLine()}-{$reflection->getEndLine()}",
|
||||
'Closure'
|
||||
);
|
||||
}
|
||||
|
||||
return new ReducedArgument("{$reflection->getFileName()}", 'Closure');
|
||||
}
|
||||
}
|
||||
23
vendor/spatie/backtrace/src/Arguments/Reducers/DateTimeArgumentReducer.php
vendored
Normal file
23
vendor/spatie/backtrace/src/Arguments/Reducers/DateTimeArgumentReducer.php
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Backtrace\Arguments\Reducers;
|
||||
|
||||
use DateTimeInterface;
|
||||
use Spatie\Backtrace\Arguments\ReducedArgument\ReducedArgument;
|
||||
use Spatie\Backtrace\Arguments\ReducedArgument\ReducedArgumentContract;
|
||||
use Spatie\Backtrace\Arguments\ReducedArgument\UnReducedArgument;
|
||||
|
||||
class DateTimeArgumentReducer implements ArgumentReducer
|
||||
{
|
||||
public function execute($argument): ReducedArgumentContract
|
||||
{
|
||||
if (! $argument instanceof DateTimeInterface) {
|
||||
return UnReducedArgument::create();
|
||||
}
|
||||
|
||||
return new ReducedArgument(
|
||||
$argument->format('d M Y H:i:s e'),
|
||||
get_class($argument),
|
||||
);
|
||||
}
|
||||
}
|
||||
23
vendor/spatie/backtrace/src/Arguments/Reducers/DateTimeZoneArgumentReducer.php
vendored
Normal file
23
vendor/spatie/backtrace/src/Arguments/Reducers/DateTimeZoneArgumentReducer.php
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Backtrace\Arguments\Reducers;
|
||||
|
||||
use DateTimeZone;
|
||||
use Spatie\Backtrace\Arguments\ReducedArgument\ReducedArgument;
|
||||
use Spatie\Backtrace\Arguments\ReducedArgument\ReducedArgumentContract;
|
||||
use Spatie\Backtrace\Arguments\ReducedArgument\UnReducedArgument;
|
||||
|
||||
class DateTimeZoneArgumentReducer implements ArgumentReducer
|
||||
{
|
||||
public function execute($argument): ReducedArgumentContract
|
||||
{
|
||||
if (! $argument instanceof DateTimeZone) {
|
||||
return UnReducedArgument::create();
|
||||
}
|
||||
|
||||
return new ReducedArgument(
|
||||
$argument->getName(),
|
||||
get_class($argument),
|
||||
);
|
||||
}
|
||||
}
|
||||
23
vendor/spatie/backtrace/src/Arguments/Reducers/EnumArgumentReducer.php
vendored
Normal file
23
vendor/spatie/backtrace/src/Arguments/Reducers/EnumArgumentReducer.php
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Backtrace\Arguments\Reducers;
|
||||
|
||||
use Spatie\Backtrace\Arguments\ReducedArgument\ReducedArgument;
|
||||
use Spatie\Backtrace\Arguments\ReducedArgument\ReducedArgumentContract;
|
||||
use Spatie\Backtrace\Arguments\ReducedArgument\UnReducedArgument;
|
||||
use UnitEnum;
|
||||
|
||||
class EnumArgumentReducer implements ArgumentReducer
|
||||
{
|
||||
public function execute($argument): ReducedArgumentContract
|
||||
{
|
||||
if (! $argument instanceof UnitEnum) {
|
||||
return UnReducedArgument::create();
|
||||
}
|
||||
|
||||
return new ReducedArgument(
|
||||
get_class($argument).'::'.$argument->name,
|
||||
get_class($argument),
|
||||
);
|
||||
}
|
||||
}
|
||||
22
vendor/spatie/backtrace/src/Arguments/Reducers/MinimalArrayArgumentReducer.php
vendored
Normal file
22
vendor/spatie/backtrace/src/Arguments/Reducers/MinimalArrayArgumentReducer.php
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Backtrace\Arguments\Reducers;
|
||||
|
||||
use Spatie\Backtrace\Arguments\ReducedArgument\ReducedArgument;
|
||||
use Spatie\Backtrace\Arguments\ReducedArgument\ReducedArgumentContract;
|
||||
use Spatie\Backtrace\Arguments\ReducedArgument\UnReducedArgument;
|
||||
|
||||
class MinimalArrayArgumentReducer implements ArgumentReducer
|
||||
{
|
||||
public function execute($argument): ReducedArgumentContract
|
||||
{
|
||||
if (! is_array($argument)) {
|
||||
return UnReducedArgument::create();
|
||||
}
|
||||
|
||||
return new ReducedArgument(
|
||||
'array (size='.count($argument).')',
|
||||
'array'
|
||||
);
|
||||
}
|
||||
}
|
||||
23
vendor/spatie/backtrace/src/Arguments/Reducers/SensitiveParameterArrayReducer.php
vendored
Normal file
23
vendor/spatie/backtrace/src/Arguments/Reducers/SensitiveParameterArrayReducer.php
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Backtrace\Arguments\Reducers;
|
||||
|
||||
use SensitiveParameterValue;
|
||||
use Spatie\Backtrace\Arguments\ReducedArgument\ReducedArgument;
|
||||
use Spatie\Backtrace\Arguments\ReducedArgument\ReducedArgumentContract;
|
||||
use Spatie\Backtrace\Arguments\ReducedArgument\UnReducedArgument;
|
||||
|
||||
class SensitiveParameterArrayReducer implements ArgumentReducer
|
||||
{
|
||||
public function execute($argument): ReducedArgumentContract
|
||||
{
|
||||
if (! $argument instanceof SensitiveParameterValue) {
|
||||
return UnReducedArgument::create();
|
||||
}
|
||||
|
||||
return new ReducedArgument(
|
||||
'SensitiveParameterValue('.get_debug_type($argument->getValue()).')',
|
||||
get_class($argument)
|
||||
);
|
||||
}
|
||||
}
|
||||
19
vendor/spatie/backtrace/src/Arguments/Reducers/StdClassArgumentReducer.php
vendored
Normal file
19
vendor/spatie/backtrace/src/Arguments/Reducers/StdClassArgumentReducer.php
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Backtrace\Arguments\Reducers;
|
||||
|
||||
use Spatie\Backtrace\Arguments\ReducedArgument\ReducedArgumentContract;
|
||||
use Spatie\Backtrace\Arguments\ReducedArgument\UnReducedArgument;
|
||||
use stdClass;
|
||||
|
||||
class StdClassArgumentReducer extends ArrayArgumentReducer
|
||||
{
|
||||
public function execute($argument): ReducedArgumentContract
|
||||
{
|
||||
if (! $argument instanceof stdClass) {
|
||||
return UnReducedArgument::create();
|
||||
}
|
||||
|
||||
return parent::reduceArgument((array) $argument, stdClass::class);
|
||||
}
|
||||
}
|
||||
23
vendor/spatie/backtrace/src/Arguments/Reducers/StringableArgumentReducer.php
vendored
Normal file
23
vendor/spatie/backtrace/src/Arguments/Reducers/StringableArgumentReducer.php
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Backtrace\Arguments\Reducers;
|
||||
|
||||
use Spatie\Backtrace\Arguments\ReducedArgument\ReducedArgument;
|
||||
use Spatie\Backtrace\Arguments\ReducedArgument\ReducedArgumentContract;
|
||||
use Spatie\Backtrace\Arguments\ReducedArgument\UnReducedArgument;
|
||||
use Stringable;
|
||||
|
||||
class StringableArgumentReducer implements ArgumentReducer
|
||||
{
|
||||
public function execute($argument): ReducedArgumentContract
|
||||
{
|
||||
if (! $argument instanceof Stringable) {
|
||||
return UnReducedArgument::create();
|
||||
}
|
||||
|
||||
return new ReducedArgument(
|
||||
(string) $argument,
|
||||
get_class($argument),
|
||||
);
|
||||
}
|
||||
}
|
||||
23
vendor/spatie/backtrace/src/Arguments/Reducers/SymphonyRequestArgumentReducer.php
vendored
Normal file
23
vendor/spatie/backtrace/src/Arguments/Reducers/SymphonyRequestArgumentReducer.php
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Backtrace\Arguments\Reducers;
|
||||
|
||||
use Spatie\Backtrace\Arguments\ReducedArgument\ReducedArgument;
|
||||
use Spatie\Backtrace\Arguments\ReducedArgument\ReducedArgumentContract;
|
||||
use Spatie\Backtrace\Arguments\ReducedArgument\UnReducedArgument;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
class SymphonyRequestArgumentReducer implements ArgumentReducer
|
||||
{
|
||||
public function execute($argument): ReducedArgumentContract
|
||||
{
|
||||
if (! $argument instanceof Request) {
|
||||
return UnReducedArgument::create();
|
||||
}
|
||||
|
||||
return new ReducedArgument(
|
||||
"{$argument->getMethod()} {$argument->getUri()}",
|
||||
get_class($argument),
|
||||
);
|
||||
}
|
||||
}
|
||||
312
vendor/spatie/backtrace/src/Backtrace.php
vendored
Normal file
312
vendor/spatie/backtrace/src/Backtrace.php
vendored
Normal file
@@ -0,0 +1,312 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Backtrace;
|
||||
|
||||
use Closure;
|
||||
use Laravel\SerializableClosure\Support\ClosureStream;
|
||||
use Spatie\Backtrace\Arguments\ArgumentReducers;
|
||||
use Spatie\Backtrace\Arguments\ReduceArgumentsAction;
|
||||
use Spatie\Backtrace\Arguments\Reducers\ArgumentReducer;
|
||||
use Throwable;
|
||||
|
||||
class Backtrace
|
||||
{
|
||||
/** @var bool */
|
||||
protected $withArguments = false;
|
||||
|
||||
/** @var bool */
|
||||
protected $reduceArguments = false;
|
||||
|
||||
/** @var array<class-string<ArgumentReducer>|ArgumentReducer>|ArgumentReducers|null */
|
||||
protected $argumentReducers = null;
|
||||
|
||||
/** @var bool */
|
||||
protected $withObject = false;
|
||||
|
||||
/** @var bool */
|
||||
protected $trimFilePaths = false;
|
||||
|
||||
/** @var string|null */
|
||||
protected $applicationPath;
|
||||
|
||||
/** @var int */
|
||||
protected $offset = 0;
|
||||
|
||||
/** @var int */
|
||||
protected $limit = 0;
|
||||
|
||||
/** @var \Closure|null */
|
||||
protected $startingFromFrameClosure = null;
|
||||
|
||||
/** @var \Throwable|null */
|
||||
protected $throwable = null;
|
||||
|
||||
public static function create(): self
|
||||
{
|
||||
return new static();
|
||||
}
|
||||
|
||||
public static function createForThrowable(Throwable $throwable): self
|
||||
{
|
||||
return (new static())->forThrowable($throwable);
|
||||
}
|
||||
|
||||
protected function forThrowable(Throwable $throwable): self
|
||||
{
|
||||
$this->throwable = $throwable;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function withArguments(
|
||||
bool $withArguments = true
|
||||
): self {
|
||||
$this->withArguments = $withArguments;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<class-string<ArgumentReducer>|ArgumentReducer>|ArgumentReducers|null $argumentReducers
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function reduceArguments(
|
||||
$argumentReducers = null
|
||||
): self {
|
||||
$this->reduceArguments = true;
|
||||
$this->argumentReducers = $argumentReducers;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function withObject(bool $withObject = true): self
|
||||
{
|
||||
$this->withObject = $withObject;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function applicationPath(string $applicationPath): self
|
||||
{
|
||||
$this->applicationPath = rtrim($applicationPath, '/');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function trimFilePaths(): self
|
||||
{
|
||||
$this->trimFilePaths = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function offset(int $offset): self
|
||||
{
|
||||
$this->offset = $offset;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function limit(int $limit): self
|
||||
{
|
||||
$this->limit = $limit;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function startingFromFrame(Closure $startingFromFrameClosure)
|
||||
{
|
||||
$this->startingFromFrameClosure = $startingFromFrameClosure;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Spatie\Backtrace\Frame[]
|
||||
*/
|
||||
public function frames(): array
|
||||
{
|
||||
$rawFrames = $this->getRawFrames();
|
||||
|
||||
return $this->toFrameObjects($rawFrames);
|
||||
}
|
||||
|
||||
public function firstApplicationFrameIndex(): ?int
|
||||
{
|
||||
foreach ($this->frames() as $index => $frame) {
|
||||
if ($frame->applicationFrame) {
|
||||
return $index;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected function getRawFrames(): array
|
||||
{
|
||||
if ($this->throwable) {
|
||||
return $this->throwable->getTrace();
|
||||
}
|
||||
|
||||
// Omit arguments and object
|
||||
$options = DEBUG_BACKTRACE_IGNORE_ARGS;
|
||||
|
||||
// Populate arguments
|
||||
if ($this->withArguments) {
|
||||
$options = 0;
|
||||
}
|
||||
|
||||
// Populate object
|
||||
if ($this->withObject) {
|
||||
$options = $options | DEBUG_BACKTRACE_PROVIDE_OBJECT;
|
||||
}
|
||||
|
||||
$limit = $this->limit;
|
||||
|
||||
if ($limit !== 0) {
|
||||
$limit += 3;
|
||||
}
|
||||
|
||||
return debug_backtrace($options, $limit);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Spatie\Backtrace\Frame[]
|
||||
*/
|
||||
protected function toFrameObjects(array $rawFrames): array
|
||||
{
|
||||
$currentFile = $this->throwable ? $this->throwable->getFile() : '';
|
||||
$currentLine = $this->throwable ? $this->throwable->getLine() : 0;
|
||||
$arguments = $this->withArguments ? [] : null;
|
||||
|
||||
$frames = [];
|
||||
|
||||
$reduceArgumentsAction = new ReduceArgumentsAction($this->resolveArgumentReducers());
|
||||
|
||||
foreach ($rawFrames as $rawFrame) {
|
||||
$textSnippet = null;
|
||||
|
||||
if (
|
||||
class_exists(ClosureStream::class)
|
||||
&& substr($currentFile, 0, strlen(ClosureStream::STREAM_PROTO)) === ClosureStream::STREAM_PROTO
|
||||
) {
|
||||
$textSnippet = $currentFile;
|
||||
$currentFile = ClosureStream::STREAM_PROTO.'://function()';
|
||||
$currentLine -= 1;
|
||||
}
|
||||
|
||||
if ($this->trimFilePaths && $this->applicationPath) {
|
||||
$trimmedFilePath = str_replace($this->applicationPath, '', $currentFile);
|
||||
}
|
||||
$frame = new Frame(
|
||||
$currentFile,
|
||||
$currentLine,
|
||||
$arguments,
|
||||
$rawFrame['function'] ?? null,
|
||||
$rawFrame['class'] ?? null,
|
||||
$rawFrame['object'] ?? null,
|
||||
$this->isApplicationFrame($currentFile),
|
||||
$textSnippet,
|
||||
$trimmedFilePath ?? null,
|
||||
);
|
||||
|
||||
$frames[] = $frame;
|
||||
|
||||
$arguments = $this->withArguments
|
||||
? $rawFrame['args'] ?? null
|
||||
: null;
|
||||
|
||||
if ($this->reduceArguments) {
|
||||
$arguments = $reduceArgumentsAction->execute(
|
||||
$rawFrame['class'] ?? null,
|
||||
$rawFrame['function'] ?? null,
|
||||
$arguments
|
||||
);
|
||||
}
|
||||
|
||||
$currentFile = $rawFrame['file'] ?? 'unknown';
|
||||
$currentLine = $rawFrame['line'] ?? 0;
|
||||
}
|
||||
|
||||
$frames[] = new Frame(
|
||||
$currentFile,
|
||||
$currentLine,
|
||||
[],
|
||||
'[top]',
|
||||
null,
|
||||
null,
|
||||
$this->isApplicationFrame($currentFile),
|
||||
);
|
||||
|
||||
$frames = $this->removeBacktracePackageFrames($frames);
|
||||
|
||||
if ($closure = $this->startingFromFrameClosure) {
|
||||
$frames = $this->startAtFrameFromClosure($frames, $closure);
|
||||
}
|
||||
$frames = array_slice($frames, $this->offset, $this->limit === 0 ? PHP_INT_MAX : $this->limit);
|
||||
|
||||
return array_values($frames);
|
||||
}
|
||||
|
||||
protected function isApplicationFrame(string $frameFilename): bool
|
||||
{
|
||||
$relativeFile = str_replace('\\', DIRECTORY_SEPARATOR, $frameFilename);
|
||||
|
||||
if (! empty($this->applicationPath)) {
|
||||
$relativeFile = array_reverse(explode($this->applicationPath ?? '', $frameFilename, 2))[0];
|
||||
}
|
||||
|
||||
if (strpos($relativeFile, DIRECTORY_SEPARATOR.'vendor') === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Edge case for vendor files that typically live in the app code (e.g. Laravel's `artisan` or Statamic's `please`)
|
||||
if (preg_match('/\/(artisan|please)$/', $relativeFile)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function removeBacktracePackageFrames(array $frames): array
|
||||
{
|
||||
return $this->startAtFrameFromClosure($frames, function (Frame $frame) {
|
||||
return $frame->class !== static::class;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Spatie\Backtrace\Frame[] $frames
|
||||
* @param \Closure $closure
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function startAtFrameFromClosure(array $frames, Closure $closure): array
|
||||
{
|
||||
foreach ($frames as $i => $frame) {
|
||||
$foundStartingFrame = $closure($frame);
|
||||
|
||||
if ($foundStartingFrame) {
|
||||
return $frames;
|
||||
}
|
||||
|
||||
unset($frames[$i]);
|
||||
}
|
||||
|
||||
return $frames;
|
||||
}
|
||||
|
||||
protected function resolveArgumentReducers(): ArgumentReducers
|
||||
{
|
||||
if ($this->argumentReducers === null) {
|
||||
return ArgumentReducers::default();
|
||||
}
|
||||
|
||||
if ($this->argumentReducers instanceof ArgumentReducers) {
|
||||
return $this->argumentReducers;
|
||||
}
|
||||
|
||||
return ArgumentReducers::create($this->argumentReducers);
|
||||
}
|
||||
}
|
||||
77
vendor/spatie/backtrace/src/CodeSnippets/CodeSnippet.php
vendored
Normal file
77
vendor/spatie/backtrace/src/CodeSnippets/CodeSnippet.php
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Backtrace\CodeSnippets;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
class CodeSnippet
|
||||
{
|
||||
/** @var int */
|
||||
protected $surroundingLine = 1;
|
||||
|
||||
/** @var int */
|
||||
protected $snippetLineCount = 9;
|
||||
|
||||
public function surroundingLine(int $surroundingLine): self
|
||||
{
|
||||
$this->surroundingLine = $surroundingLine;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function snippetLineCount(int $snippetLineCount): self
|
||||
{
|
||||
$this->snippetLineCount = $snippetLineCount;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function get(SnippetProvider $provider): array
|
||||
{
|
||||
try {
|
||||
[$startLineNumber, $endLineNumber] = $this->getBounds($provider->numberOfLines());
|
||||
|
||||
$code = [];
|
||||
|
||||
$line = $provider->getLine($startLineNumber);
|
||||
|
||||
$currentLineNumber = $startLineNumber;
|
||||
|
||||
while ($currentLineNumber <= $endLineNumber) {
|
||||
$code[$currentLineNumber] = rtrim(substr($line, 0, 250));
|
||||
|
||||
$line = $provider->getNextLine();
|
||||
$currentLineNumber++;
|
||||
}
|
||||
|
||||
return $code;
|
||||
} catch (RuntimeException $exception) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
public function getAsString(SnippetProvider $provider): string
|
||||
{
|
||||
$snippet = $this->get($provider);
|
||||
|
||||
$snippetStrings = array_map(function (string $line, string $number) {
|
||||
return "{$number} {$line}";
|
||||
}, $snippet, array_keys($snippet));
|
||||
|
||||
return implode(PHP_EOL, $snippetStrings);
|
||||
}
|
||||
|
||||
protected function getBounds(int $totalNumberOfLineInFile): array
|
||||
{
|
||||
$startLine = max($this->surroundingLine - floor($this->snippetLineCount / 2), 1);
|
||||
|
||||
$endLine = $startLine + ($this->snippetLineCount - 1);
|
||||
|
||||
if ($endLine > $totalNumberOfLineInFile) {
|
||||
$endLine = $totalNumberOfLineInFile;
|
||||
$startLine = max($endLine - ($this->snippetLineCount - 1), 1);
|
||||
}
|
||||
|
||||
return [$startLine, $endLine];
|
||||
}
|
||||
}
|
||||
41
vendor/spatie/backtrace/src/CodeSnippets/FileSnippetProvider.php
vendored
Normal file
41
vendor/spatie/backtrace/src/CodeSnippets/FileSnippetProvider.php
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Backtrace\CodeSnippets;
|
||||
|
||||
use SplFileObject;
|
||||
|
||||
class FileSnippetProvider implements SnippetProvider
|
||||
{
|
||||
/** @var \SplFileObject */
|
||||
protected $file;
|
||||
|
||||
public function __construct(string $path)
|
||||
{
|
||||
$this->file = new SplFileObject($path);
|
||||
}
|
||||
|
||||
public function numberOfLines(): int
|
||||
{
|
||||
$this->file->seek(PHP_INT_MAX);
|
||||
|
||||
return $this->file->key() + 1;
|
||||
}
|
||||
|
||||
public function getLine(?int $lineNumber = null): string
|
||||
{
|
||||
if (is_null($lineNumber)) {
|
||||
return $this->getNextLine();
|
||||
}
|
||||
|
||||
$this->file->seek($lineNumber - 1);
|
||||
|
||||
return $this->file->current();
|
||||
}
|
||||
|
||||
public function getNextLine(): string
|
||||
{
|
||||
$this->file->next();
|
||||
|
||||
return $this->file->current();
|
||||
}
|
||||
}
|
||||
67
vendor/spatie/backtrace/src/CodeSnippets/LaravelSerializableClosureSnippetProvider.php
vendored
Normal file
67
vendor/spatie/backtrace/src/CodeSnippets/LaravelSerializableClosureSnippetProvider.php
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Backtrace\CodeSnippets;
|
||||
|
||||
class LaravelSerializableClosureSnippetProvider implements SnippetProvider
|
||||
{
|
||||
/** @var array<string> */
|
||||
protected $lines;
|
||||
|
||||
/** @var int */
|
||||
protected $counter = 0;
|
||||
|
||||
public function __construct(string $snippet)
|
||||
{
|
||||
$this->lines = preg_split("/\r\n|\n|\r/", $snippet);
|
||||
|
||||
$this->cleanupLines();
|
||||
}
|
||||
|
||||
public function numberOfLines(): int
|
||||
{
|
||||
return count($this->lines);
|
||||
}
|
||||
|
||||
public function getLine(?int $lineNumber = null): string
|
||||
{
|
||||
if (is_null($lineNumber)) {
|
||||
return $this->getNextLine();
|
||||
}
|
||||
|
||||
$this->counter = $lineNumber - 1;
|
||||
|
||||
return $this->lines[$lineNumber - 1];
|
||||
}
|
||||
|
||||
public function getNextLine(): string
|
||||
{
|
||||
$this->counter++;
|
||||
|
||||
if ($this->counter >= count($this->lines)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $this->lines[$this->counter];
|
||||
}
|
||||
|
||||
protected function cleanupLines(): void
|
||||
{
|
||||
$spacesOrTabsToRemove = PHP_INT_MAX;
|
||||
|
||||
for ($i = 1; $i < count($this->lines); $i++) {
|
||||
if (empty($this->lines[$i])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$spacesOrTabsToRemove = min(strspn($this->lines[$i], " \t"), $spacesOrTabsToRemove);
|
||||
}
|
||||
|
||||
if ($spacesOrTabsToRemove === PHP_INT_MAX) {
|
||||
$spacesOrTabsToRemove = 0;
|
||||
}
|
||||
|
||||
for ($i = 1; $i < count($this->lines); $i++) {
|
||||
$this->lines[$i] = substr($this->lines[$i], $spacesOrTabsToRemove);
|
||||
}
|
||||
}
|
||||
}
|
||||
21
vendor/spatie/backtrace/src/CodeSnippets/NullSnippetProvider.php
vendored
Normal file
21
vendor/spatie/backtrace/src/CodeSnippets/NullSnippetProvider.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Backtrace\CodeSnippets;
|
||||
|
||||
class NullSnippetProvider implements SnippetProvider
|
||||
{
|
||||
public function numberOfLines(): int
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function getLine(?int $lineNumber = null): string
|
||||
{
|
||||
return $this->getNextLine();
|
||||
}
|
||||
|
||||
public function getNextLine(): string
|
||||
{
|
||||
return "File not found for code snippet";
|
||||
}
|
||||
}
|
||||
12
vendor/spatie/backtrace/src/CodeSnippets/SnippetProvider.php
vendored
Normal file
12
vendor/spatie/backtrace/src/CodeSnippets/SnippetProvider.php
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Backtrace\CodeSnippets;
|
||||
|
||||
interface SnippetProvider
|
||||
{
|
||||
public function numberOfLines(): int;
|
||||
|
||||
public function getLine(?int $lineNumber = null): string;
|
||||
|
||||
public function getNextLine(): string;
|
||||
}
|
||||
110
vendor/spatie/backtrace/src/Frame.php
vendored
Normal file
110
vendor/spatie/backtrace/src/Frame.php
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Backtrace;
|
||||
|
||||
use Spatie\Backtrace\CodeSnippets\CodeSnippet;
|
||||
use Spatie\Backtrace\CodeSnippets\FileSnippetProvider;
|
||||
use Spatie\Backtrace\CodeSnippets\LaravelSerializableClosureSnippetProvider;
|
||||
use Spatie\Backtrace\CodeSnippets\NullSnippetProvider;
|
||||
use Spatie\Backtrace\CodeSnippets\SnippetProvider;
|
||||
|
||||
class Frame
|
||||
{
|
||||
/** @var string */
|
||||
public $file;
|
||||
|
||||
/** @var string|null */
|
||||
public $trimmedFilePath;
|
||||
|
||||
/** @var int */
|
||||
public $lineNumber;
|
||||
|
||||
/** @var array|null */
|
||||
public $arguments = null;
|
||||
|
||||
/** @var bool */
|
||||
public $applicationFrame;
|
||||
|
||||
/** @var string|null */
|
||||
public $method;
|
||||
|
||||
/** @var string|null */
|
||||
public $class;
|
||||
|
||||
/** @var object|null */
|
||||
public $object;
|
||||
|
||||
/** @var string|null */
|
||||
protected $textSnippet;
|
||||
|
||||
public function __construct(
|
||||
string $file,
|
||||
int $lineNumber,
|
||||
?array $arguments,
|
||||
?string $method = null,
|
||||
?string $class = null,
|
||||
?object $object = null,
|
||||
bool $isApplicationFrame = false,
|
||||
?string $textSnippet = null,
|
||||
?string $trimmedFilePath = null
|
||||
) {
|
||||
$this->file = $file;
|
||||
|
||||
$this->trimmedFilePath = $trimmedFilePath;
|
||||
|
||||
$this->lineNumber = $lineNumber;
|
||||
|
||||
$this->arguments = $arguments;
|
||||
|
||||
$this->method = $method;
|
||||
|
||||
$this->class = $class;
|
||||
|
||||
$this->object = $object;
|
||||
|
||||
$this->applicationFrame = $isApplicationFrame;
|
||||
|
||||
$this->textSnippet = $textSnippet;
|
||||
}
|
||||
|
||||
public function getSnippet(int $lineCount): array
|
||||
{
|
||||
return (new CodeSnippet())
|
||||
->surroundingLine($this->lineNumber)
|
||||
->snippetLineCount($lineCount)
|
||||
->get($this->getCodeSnippetProvider());
|
||||
}
|
||||
|
||||
public function getSnippetAsString(int $lineCount): string
|
||||
{
|
||||
return (new CodeSnippet())
|
||||
->surroundingLine($this->lineNumber)
|
||||
->snippetLineCount($lineCount)
|
||||
->getAsString($this->getCodeSnippetProvider());
|
||||
}
|
||||
|
||||
public function getSnippetProperties(int $lineCount): array
|
||||
{
|
||||
$snippet = $this->getSnippet($lineCount);
|
||||
|
||||
return array_map(function (int $lineNumber) use ($snippet) {
|
||||
return [
|
||||
'line_number' => $lineNumber,
|
||||
'text' => $snippet[$lineNumber],
|
||||
];
|
||||
}, array_keys($snippet));
|
||||
}
|
||||
|
||||
protected function getCodeSnippetProvider(): SnippetProvider
|
||||
{
|
||||
if ($this->textSnippet) {
|
||||
return new LaravelSerializableClosureSnippetProvider($this->textSnippet);
|
||||
}
|
||||
|
||||
if (@file_exists($this->file)) {
|
||||
return new FileSnippetProvider($this->file);
|
||||
}
|
||||
|
||||
return new NullSnippetProvider();
|
||||
}
|
||||
}
|
||||
163
vendor/spatie/color/CHANGELOG.md
vendored
Normal file
163
vendor/spatie/color/CHANGELOG.md
vendored
Normal file
@@ -0,0 +1,163 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to `color` will be documented in this file
|
||||
|
||||
## 1.7.0 - 2024-12-30
|
||||
|
||||
### What's Changed
|
||||
|
||||
* Extended HSL/HSLA/HSB Handling with Float Support by @danielebarbaro in https://github.com/spatie/color/pull/93
|
||||
|
||||
**Full Changelog**: https://github.com/spatie/color/compare/1.6.3...1.7.0
|
||||
|
||||
## 1.6.3 - 2024-12-23
|
||||
|
||||
### What's Changed
|
||||
|
||||
* Test Enhancements for Contrast Calculations (and mini refactor for contrast class) by @danielebarbaro in https://github.com/spatie/color/pull/92
|
||||
|
||||
### New Contributors
|
||||
|
||||
* @danielebarbaro made their first contribution in https://github.com/spatie/color/pull/92
|
||||
|
||||
**Full Changelog**: https://github.com/spatie/color/compare/1.6.2...1.6.3
|
||||
|
||||
## 1.6.2 - 2024-12-09
|
||||
|
||||
### What's Changed
|
||||
|
||||
* Issue #88 Cast return to float instead of string to match Contrast ratio return type by @NiklasBr in https://github.com/spatie/color/pull/91
|
||||
|
||||
### New Contributors
|
||||
|
||||
* @NiklasBr made their first contribution in https://github.com/spatie/color/pull/91
|
||||
|
||||
**Full Changelog**: https://github.com/spatie/color/compare/1.6.1...1.6.2
|
||||
|
||||
## 1.6.1 - 2024-11-18
|
||||
|
||||
### What's Changed
|
||||
|
||||
* Fix wrong Validation Error message for hsla strings by @Afrowson in https://github.com/spatie/color/pull/90
|
||||
|
||||
### New Contributors
|
||||
|
||||
* @Afrowson made their first contribution in https://github.com/spatie/color/pull/90
|
||||
|
||||
**Full Changelog**: https://github.com/spatie/color/compare/1.6.0...1.6.1
|
||||
|
||||
## 1.6.0 - 2024-09-20
|
||||
|
||||
### What's Changed
|
||||
|
||||
* Ignore more file when packaging releases by @andypost in https://github.com/spatie/color/pull/83
|
||||
* Fix typo in README for Hsl::fromString() in Cast the color to a string. by @agnonym in https://github.com/spatie/color/pull/84
|
||||
* Added named colors by @vanodevium in https://github.com/spatie/color/pull/87
|
||||
|
||||
### New Contributors
|
||||
|
||||
* @andypost made their first contribution in https://github.com/spatie/color/pull/83
|
||||
* @agnonym made their first contribution in https://github.com/spatie/color/pull/84
|
||||
* @vanodevium made their first contribution in https://github.com/spatie/color/pull/87
|
||||
|
||||
**Full Changelog**: https://github.com/spatie/color/compare/1.5.3...1.6.0
|
||||
|
||||
## 1.5.3 - 2022-12-18
|
||||
|
||||
### What's Changed
|
||||
|
||||
- Refactor tests to pest by @AyoobMH in https://github.com/spatie/color/pull/80
|
||||
- Add PHP 8.2 Support by @patinthehat in https://github.com/spatie/color/pull/81
|
||||
- Fix rgb to cmyk division by zero bug by @stefanriehl in https://github.com/spatie/color/pull/82
|
||||
|
||||
### New Contributors
|
||||
|
||||
- @AyoobMH made their first contribution in https://github.com/spatie/color/pull/80
|
||||
- @patinthehat made their first contribution in https://github.com/spatie/color/pull/81
|
||||
- @stefanriehl made their first contribution in https://github.com/spatie/color/pull/82
|
||||
|
||||
**Full Changelog**: https://github.com/spatie/color/compare/1.5.2...1.5.3
|
||||
|
||||
## 1.5.2 - 2022-06-24
|
||||
|
||||
### What's Changed
|
||||
|
||||
- Add RegEx fix to Validate.php too... by @jcogs-design in https://github.com/spatie/color/pull/73
|
||||
- Fix typo in Distance::CIE76. by @Angel5a in https://github.com/spatie/color/pull/76
|
||||
|
||||
### New Contributors
|
||||
|
||||
- @jcogs-design made their first contribution in https://github.com/spatie/color/pull/73
|
||||
- @Angel5a made their first contribution in https://github.com/spatie/color/pull/76
|
||||
|
||||
**Full Changelog**: https://github.com/spatie/color/compare/1.5.1...1.5.2
|
||||
|
||||
## 1.5.1 - 2022-04-12
|
||||
|
||||
## What's Changed
|
||||
|
||||
- Fix rgba opacity by @AstroCorp in https://github.com/spatie/color/pull/67
|
||||
|
||||
## New Contributors
|
||||
|
||||
- @AstroCorp made their first contribution in https://github.com/spatie/color/pull/67
|
||||
|
||||
**Full Changelog**: https://github.com/spatie/color/compare/1.5.0...1.5.1
|
||||
|
||||
## 1.4.0 - 2022-01-05
|
||||
|
||||
- Added support for PHP 8
|
||||
- Added support for CMYK & HSB
|
||||
- Added support for HEX alpha channel
|
||||
- Added support for 3-digit HEX values
|
||||
|
||||
## 1.3.1 - 2021-09-09
|
||||
|
||||
- Fix HEX/HSL conversion bug
|
||||
|
||||
## 1.3.0 - 2021-09-06
|
||||
|
||||
- Added CIELab and XYZ color formats and `Distance` API
|
||||
- Added `Contrast` API
|
||||
|
||||
## 1.2.4 - 2021-02-18
|
||||
|
||||
- Fixed division by zero error on pure white/black convertions ([#42](https://github.com/spatie/color/pull/42))
|
||||
|
||||
## 1.2.3 - 2020-12-10
|
||||
|
||||
- Added support for PHP 8
|
||||
|
||||
## 1.2.2 - 2020-11-18
|
||||
|
||||
- Fix transform RGB value to HSL : division by zero (#38)
|
||||
|
||||
## 1.2.1 - 2020-07-17
|
||||
|
||||
- HSL to RGB fixes
|
||||
|
||||
## 1.2.0 - 2020-06-22
|
||||
|
||||
- Added HSL & HSLA support
|
||||
|
||||
## 1.1.1 - 2017-02-03
|
||||
|
||||
- Fixed validation when a color contained redundant characters at the beginning or end of the string
|
||||
|
||||
## 1.1.0 - 2017-01-13
|
||||
|
||||
- All color formats now implement a `Color` interface
|
||||
- Added a `Factory` class with a `fromString` static method to guess a format
|
||||
- `rgb` and `rgba` values can now contain spaces (e.g. `rgb(255, 255, 255)`)
|
||||
|
||||
## 1.0.2 - 2016-10-17
|
||||
|
||||
- `rgbChannelToHexChannel` now also accepts single single-digit hex values
|
||||
|
||||
## 1.0.1 - 2016-09-22
|
||||
|
||||
- Bugfix (breaking!): Alpha channel values are now a float between 0 and 1
|
||||
|
||||
## 1.0.0 - 2016-09-21
|
||||
|
||||
- First release
|
||||
21
vendor/spatie/color/LICENSE.md
vendored
Normal file
21
vendor/spatie/color/LICENSE.md
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
# The MIT License (MIT)
|
||||
|
||||
Copyright (c) Spatie bvba <info@spatie.be>
|
||||
|
||||
> Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
> of this software and associated documentation files (the "Software"), to deal
|
||||
> in the Software without restriction, including without limitation the rights
|
||||
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
> copies of the Software, and to permit persons to whom the Software is
|
||||
> furnished to do so, subject to the following conditions:
|
||||
>
|
||||
> The above copyright notice and this permission notice shall be included in
|
||||
> all copies or substantial portions of the Software.
|
||||
>
|
||||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
> THE SOFTWARE.
|
||||
293
vendor/spatie/color/README.md
vendored
Normal file
293
vendor/spatie/color/README.md
vendored
Normal file
@@ -0,0 +1,293 @@
|
||||
# A little library to handle color conversions and comparisons
|
||||
|
||||
[](https://packagist.org/packages/spatie/color)
|
||||
[](LICENSE.md)
|
||||
[](https://travis-ci.org/spatie/color)
|
||||
[](https://scrutinizer-ci.com/g/spatie/color)
|
||||
[](https://packagist.org/packages/spatie/color)
|
||||

|
||||
|
||||
A little library to handle color conversions and comparisons. Currently, supports CSS names, rgb, rgba, hex, hsl, hsla, CIELab, and xyz color formats as well as CIE76, CIE94, and CIEDE2000 color comparison algorithms.
|
||||
|
||||
```php
|
||||
$named = Named::fromString('peru'); // case-insensitive
|
||||
|
||||
echo $named->red(); // 205
|
||||
echo $named->green(); // 133
|
||||
echo $named->blue(); // 63
|
||||
|
||||
echo $named->toHex(); // #cd853f
|
||||
|
||||
$rgb = Rgb::fromString('rgb(55,155,255)');
|
||||
|
||||
echo $rgb->red(); // 55
|
||||
echo $rgb->green(); // 155
|
||||
echo $rgb->blue(); // 255
|
||||
|
||||
echo $rgb; // rgb(55,155,255)
|
||||
|
||||
$rgba = $rgb->toRgba(); // `Spatie\Color\Rgba`
|
||||
$rgba->alpha(); // 1
|
||||
echo $rgba; // rgba(55,155,255,1)
|
||||
|
||||
$hex = $rgb->toHex(); // `Spatie\Color\Hex`
|
||||
$rgba->alpha(); // ff
|
||||
echo $hex; // #379bff
|
||||
|
||||
$cmyk = $rgb->toCmyk(); // `Spatie\Color\Cmyk`
|
||||
echo $cmyk; // cmyk(78,39,0,0)
|
||||
|
||||
$hsl = $rgb->toHsl(); // `Spatie\Color\Hsl`
|
||||
echo $hsl; // hsl(210,100%,100%)
|
||||
|
||||
$hsb = $rgb->toHsb(); // `Spatie\Color\Hsb`
|
||||
echo $hsb; // hsl(210,78.4%,100%)
|
||||
|
||||
$lab = $rgb->toCIELab();
|
||||
echo $lab; // CIELab(62.91,5.34,-57.73)
|
||||
|
||||
$xyz = $rgb->toXyz();
|
||||
echo $xyz; // xyz(31.3469,31.4749,99.0308)
|
||||
|
||||
$hex2 = Hex::fromString('#2d78c8');
|
||||
|
||||
$ratio = Contrast::ratio(Hex::fromString('#f0fff0'), Hex::fromString('#191970'));
|
||||
echo $ratio; // 15.0
|
||||
|
||||
$cie76_distance = Distance::CIE76($rgb, $hex2);
|
||||
$cie76_distance = Distance::CIE76('rgba(55,155,255,1)', '#2d78c8'); // Outputs the same thing, Factory is built-in to all comparison functions
|
||||
echo $cie76_distance; // 55.89468042667388
|
||||
|
||||
$cie94_distance = Distance::CIE94($rgb, $hex2);
|
||||
echo $cie94_distance; // 13.49091942790753
|
||||
|
||||
$cie94_textiles_distance = Distance::CIE94($rgb, $hex2, 1); // Third parameter optionally sets the application type (0 = Graphic Arts [Default], 1 = Textiles)
|
||||
echo $cie94_textiles_distance; // 7.0926538068477
|
||||
|
||||
$ciede2000_distance = Distance::CIEDE2000($rgb, $hex2);
|
||||
echo $ciede2000_distance; // 12.711957696300898
|
||||
```
|
||||
|
||||
## Support us
|
||||
|
||||
[<img src="https://github-ads.s3.eu-central-1.amazonaws.com/color.jpg?t=1" width="419px" />](https://spatie.be/github-ad-click/color)
|
||||
|
||||
We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).
|
||||
|
||||
We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).
|
||||
|
||||
## Installation
|
||||
|
||||
You can install the package via composer:
|
||||
|
||||
```bash
|
||||
composer require spatie/color
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
The `Color` package contains a separate class per color format, which each implement a `Color` interface.
|
||||
|
||||
There are seven classes which implement the `Color` interface:
|
||||
|
||||
- `CIELab`
|
||||
- `Cmyk`
|
||||
- `Hex`
|
||||
- `Hsb`
|
||||
- `Hsl`
|
||||
- `Hsla`
|
||||
- `Rgb`
|
||||
- `Rgba`
|
||||
- `Xyz`
|
||||
|
||||
### `interface Spatie\Color\Color`
|
||||
|
||||
#### `fromString(): Color`
|
||||
|
||||
Parses a color string and returns a `Color` implementation, depending on the format of the input string.
|
||||
|
||||
```php
|
||||
Named::fromString('blue');
|
||||
Hex::fromString('#000000');
|
||||
Rgba::fromString('rgba(255, 255, 255, 1)');
|
||||
Hsla::fromString('hsla(360, 100%, 100%, 1)');
|
||||
```
|
||||
|
||||
Throws an `InvalidColorValue` exception if the string can't be parsed.
|
||||
|
||||
> `Rgb`, `Rgba`, `Hsl` and `Hsla` strings are allowed to have spaces. `rgb(0,0,0)` is just as valid as `rgb(0, 0, 0)`.
|
||||
|
||||
#### `red(): int|string`
|
||||
|
||||
Return the value of the `red` color channel.
|
||||
|
||||
```php
|
||||
Hex::fromString('#ff0000')->red(); // 'ff'
|
||||
Rgb::fromString('rgb(255, 0, 0)')->red(); // 255
|
||||
```
|
||||
|
||||
#### `green(): int|string`
|
||||
|
||||
Return the value of the `green` color channel.
|
||||
|
||||
```php
|
||||
Hex::fromString('#00ff00')->green(); // 'ff'
|
||||
Rgb::fromString('rgb(0, 255, 0)')->green(); // 255
|
||||
```
|
||||
|
||||
#### `blue(): int|string`
|
||||
|
||||
Return the value of the `blue` color channel.
|
||||
|
||||
```php
|
||||
Hex::fromString('#0000ff')->blue(); // 'ff'
|
||||
Rgb::fromString('rgb(0, 0, 255)')->blue(); // 255
|
||||
```
|
||||
|
||||
#### `toCmyk(): Cmyk`
|
||||
|
||||
Convert a color to a `Cmyk` color.
|
||||
|
||||
```php
|
||||
Rgb::fromString('rgb(0, 0, 255)')->toCmyk();
|
||||
// `Cmyk` instance; 'cmyk(100,100,0,0)'
|
||||
```
|
||||
|
||||
#### `toHex(): Hex`
|
||||
|
||||
Convert a color to a `Hex` color.
|
||||
|
||||
```php
|
||||
Rgb::fromString('rgb(0, 0, 255)')->toHex();
|
||||
// `Hex` instance; '#0000ff'
|
||||
```
|
||||
|
||||
When coming from a color format that doesn't support opacity, it can be added by passing it to the `$alpha` parameter.
|
||||
|
||||
|
||||
#### `toHsb(): Hsb`
|
||||
|
||||
Convert a color to a `Hsb` color.
|
||||
|
||||
```php
|
||||
Rgb::fromString('rgb(0, 0, 255)')->toHsb();
|
||||
// `Hsl` instance; 'hsb(240, 100%, 100%)'
|
||||
```
|
||||
|
||||
#### `toHsl(): Hsl`
|
||||
|
||||
Convert a color to a `Hsl` color.
|
||||
|
||||
```php
|
||||
Rgb::fromString('rgb(0, 0, 255)')->toHsl();
|
||||
// `Hsl` instance; 'hsl(240, 100%, 50%)'
|
||||
```
|
||||
|
||||
When coming from a color format that supports opacity, the opacity will simply be omitted.
|
||||
|
||||
```php
|
||||
Rgba::fromString('rgba(0, 0, 255, .5)')->toHsl();
|
||||
// `Hsl` instance; 'hsl(240, 100%, 50%)'
|
||||
```
|
||||
|
||||
#### `toHsla(float $alpha = 1): Hsla`
|
||||
|
||||
Convert a color to a `Hsla` color.
|
||||
|
||||
```php
|
||||
Rgb::fromString('rgb(0, 0, 255)')->toHsla();
|
||||
// `Hsla` instance; 'hsla(240, 100%, 50%, 1.0)'
|
||||
```
|
||||
|
||||
When coming from a color format that doesn't support opacity, it can be added by passing it to the `$alpha` parameter.
|
||||
|
||||
```php
|
||||
Rgb::fromString('rgb(0, 0, 255)')->toHsla(.5);
|
||||
// `Hsla` instance; 'hsla(240, 100%, 50%, 0.5)'
|
||||
```
|
||||
|
||||
#### `toRgb(): Rgb`
|
||||
|
||||
Convert a color to an `Rgb` color.
|
||||
|
||||
```php
|
||||
Hex::fromString('#0000ff')->toRgb();
|
||||
// `Rgb` instance; 'rgb(0, 0, 255)'
|
||||
```
|
||||
|
||||
When coming from a color format that supports opacity, the opacity will simply be omitted.
|
||||
|
||||
```php
|
||||
Rgba::fromString('rgb(0, 0, 255, .5)')->toRgb();
|
||||
// `Rgb` instance; 'rgb(0, 0, 255)'
|
||||
```
|
||||
|
||||
#### `toRgba(float $alpha = 1): Rgba`
|
||||
|
||||
Convert a color to a `Rgba` color.
|
||||
|
||||
```php
|
||||
Rgb::fromString('rgb(0, 0, 255)')->toRgba();
|
||||
// `Rgba` instance; 'rgba(0, 0, 255, 1)'
|
||||
```
|
||||
|
||||
When coming from a color format that doesn't support opacity, it can be added by passing it to the `$alpha` parameter.
|
||||
|
||||
```php
|
||||
Rgba::fromString('rgb(0, 0, 255)')->toRgba(.5);
|
||||
// `Rgba` instance; 'rgba(0, 0, 255, .5)'
|
||||
```
|
||||
|
||||
#### `__toString(): string`
|
||||
|
||||
Cast the color to a string.
|
||||
|
||||
```php
|
||||
(string) Rgb::fromString('rgb(0, 0, 255)'); // 'rgb(0,0,255)'
|
||||
(string) Rgba::fromString('rgb(0, 0, 255, .5)'); // 'rgb(0,0,255,0.5)'
|
||||
(string) Hex::fromString('#0000ff'); // '#0000ff'
|
||||
(string) Hsl::fromString('hsl(240, 100%, 50%)'); // 'hsl(240, 100%, 50%)'
|
||||
(string) Hsla::fromString('hsla(240, 100%, 50%, 1.0)'); // 'hsla(240, 100%, 50%, 1.0)'
|
||||
```
|
||||
|
||||
### `Factory::fromString(): Color`
|
||||
|
||||
With the `Factory` class, you can create a color instance from any string (it does an educated guess under the hood). If the string isn't a valid color string in any format, it throws an `InvalidColorValue` exception.
|
||||
|
||||
```php
|
||||
Factory::fromString('rgb(0, 0, 255)'); // `Rgb` instance
|
||||
Factory::fromString('blue'); // `Named` instance
|
||||
Factory::fromString('#0000ff'); // `Hex` instance
|
||||
Factory::fromString('hsl(240, 100%, 50%)'); // `Hsl` instance
|
||||
Factory::fromString('Hello world!'); // `InvalidColorValue` exception
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
|
||||
|
||||
## Testing
|
||||
|
||||
``` bash
|
||||
$ composer test
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.
|
||||
|
||||
## Security
|
||||
|
||||
If you've found a bug regarding security please mail [security@spatie.be](mailto:security@spatie.be) instead of using the issue tracker.
|
||||
|
||||
## Credits
|
||||
|
||||
- [Sebastian De Deyne](https://github.com/sebastiandedeyne)
|
||||
- [All Contributors](../../contributors)
|
||||
|
||||
## About Spatie
|
||||
Spatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects [on our website](https://spatie.be/opensource).
|
||||
|
||||
## License
|
||||
|
||||
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
|
||||
46
vendor/spatie/color/composer.json
vendored
Normal file
46
vendor/spatie/color/composer.json
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"name": "spatie/color",
|
||||
"description": "A little library to handle color conversions",
|
||||
"keywords": [
|
||||
"spatie",
|
||||
"color",
|
||||
"conversion",
|
||||
"rgb"
|
||||
],
|
||||
"homepage": "https://github.com/spatie/color",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian De Deyne",
|
||||
"email": "sebastian@spatie.be",
|
||||
"homepage": "https://spatie.be",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php" : "^7.3|^8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"pestphp/pest": "^1.22",
|
||||
"phpunit/phpunit": "^6.5||^9.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Spatie\\Color\\": "src"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Spatie\\Color\\Test\\": "tests"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"test": "vendor/bin/pest"
|
||||
},
|
||||
"config": {
|
||||
"sort-packages": true,
|
||||
"allow-plugins": {
|
||||
"pestphp/pest-plugin": true
|
||||
}
|
||||
}
|
||||
}
|
||||
127
vendor/spatie/color/src/CIELab.php
vendored
Normal file
127
vendor/spatie/color/src/CIELab.php
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Color;
|
||||
|
||||
class CIELab implements Color
|
||||
{
|
||||
/** @var float */
|
||||
protected $l;
|
||||
protected $a;
|
||||
protected $b;
|
||||
|
||||
public function __construct(float $l, float $a, float $b)
|
||||
{
|
||||
Validate::CIELabValue($l, 'l');
|
||||
Validate::CIELabValue($a, 'a');
|
||||
Validate::CIELabValue($b, 'b');
|
||||
|
||||
$this->l = $l;
|
||||
$this->a = $a;
|
||||
$this->b = $b;
|
||||
}
|
||||
|
||||
public static function fromString(string $string)
|
||||
{
|
||||
Validate::CIELabColorString($string);
|
||||
|
||||
$matches = null;
|
||||
preg_match('/CIELab\( *(\d{1,3}\.?\d* *, *-?\d{1,3}\.?\d* *, *-?\d{1,3}\.?\d*) *\)/i', $string, $matches);
|
||||
|
||||
$channels = explode(',', $matches[1]);
|
||||
[$l, $a, $b] = array_map('trim', $channels);
|
||||
|
||||
return new static($l, $a, $b);
|
||||
}
|
||||
|
||||
public function l(): float
|
||||
{
|
||||
return $this->l;
|
||||
}
|
||||
|
||||
public function a(): float
|
||||
{
|
||||
return $this->a;
|
||||
}
|
||||
|
||||
public function b(): float
|
||||
{
|
||||
return $this->b;
|
||||
}
|
||||
|
||||
public function red(): int
|
||||
{
|
||||
$rgb = $this->toRgb();
|
||||
|
||||
return $rgb->red();
|
||||
}
|
||||
|
||||
public function blue(): int
|
||||
{
|
||||
$rgb = $this->toRgb();
|
||||
|
||||
return $rgb->blue();
|
||||
}
|
||||
|
||||
public function green(): int
|
||||
{
|
||||
$rgb = $this->toRgb();
|
||||
|
||||
return $rgb->green();
|
||||
}
|
||||
|
||||
public function toCIELab(): self
|
||||
{
|
||||
return new self($this->l, $this->a, $this->b);
|
||||
}
|
||||
|
||||
public function toCmyk(): Cmyk
|
||||
{
|
||||
return $this->toRgb()->toCmyk();
|
||||
}
|
||||
|
||||
public function toHex(?string $alpha = null): Hex
|
||||
{
|
||||
return $this->toRgb()->toHex($alpha ?? 'ff');
|
||||
}
|
||||
|
||||
public function toHsb(): Hsb
|
||||
{
|
||||
return $this->toRgb()->toHsb();
|
||||
}
|
||||
|
||||
public function toHsl(): Hsl
|
||||
{
|
||||
return $this->toRgb()->toHSL();
|
||||
}
|
||||
|
||||
public function toHsla(?float $alpha = null): Hsla
|
||||
{
|
||||
return $this->toRgb()->toHsla($alpha ?? 1);
|
||||
}
|
||||
|
||||
public function toRgb(): Rgb
|
||||
{
|
||||
return $this->toXyz()->toRgb();
|
||||
}
|
||||
|
||||
public function toRgba(?float $alpha = null): Rgba
|
||||
{
|
||||
return $this->toRgb()->toRgba($alpha ?? 1);
|
||||
}
|
||||
|
||||
public function toXyz(): Xyz
|
||||
{
|
||||
[$x, $y, $z] = Convert::CIELabValueToXyz(
|
||||
$this->l,
|
||||
$this->a,
|
||||
$this->b
|
||||
);
|
||||
|
||||
return new Xyz($x, $y, $z);
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
return "CIELab({$this->l},{$this->a},{$this->b})";
|
||||
}
|
||||
}
|
||||
132
vendor/spatie/color/src/Cmyk.php
vendored
Normal file
132
vendor/spatie/color/src/Cmyk.php
vendored
Normal file
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Color;
|
||||
|
||||
class Cmyk implements Color
|
||||
{
|
||||
/** @var float */
|
||||
protected $cyan;
|
||||
protected $magenta;
|
||||
protected $yellow;
|
||||
protected $key;
|
||||
|
||||
public function __construct(float $cyan, float $magenta, float $yellow, float $key)
|
||||
{
|
||||
Validate::cmykValue($cyan, 'cyan');
|
||||
Validate::cmykValue($magenta, 'magenta');
|
||||
Validate::cmykValue($yellow, 'yellow');
|
||||
Validate::cmykValue($key, 'key (black)');
|
||||
|
||||
$this->cyan = $cyan;
|
||||
$this->magenta = $magenta;
|
||||
$this->yellow = $yellow;
|
||||
$this->key = $key;
|
||||
}
|
||||
|
||||
public static function fromString(string $string)
|
||||
{
|
||||
Validate::cmykColorString($string);
|
||||
|
||||
$matches = null;
|
||||
preg_match('/cmyk\( *(\d{1,3})%? *, *(\d{1,3})%? *, *(\d{1,3})%? *, *(\d{1,3})%? *\)/i', $string, $matches);
|
||||
|
||||
return new static($matches[1] / 100, $matches[2] / 100, $matches[3] / 100, $matches[4] / 100);
|
||||
}
|
||||
|
||||
public function red(): int
|
||||
{
|
||||
return Convert::cmykValueToRgb($this->cyan, $this->magenta, $this->yellow, $this->key)[0];
|
||||
}
|
||||
|
||||
public function green(): int
|
||||
{
|
||||
return Convert::cmykValueToRgb($this->cyan, $this->magenta, $this->yellow, $this->key)[1];
|
||||
}
|
||||
|
||||
public function blue(): int
|
||||
{
|
||||
return Convert::cmykValueToRgb($this->cyan, $this->magenta, $this->yellow, $this->key)[2];
|
||||
}
|
||||
|
||||
public function cyan(): float
|
||||
{
|
||||
return $this->cyan;
|
||||
}
|
||||
|
||||
public function magenta(): float
|
||||
{
|
||||
return $this->magenta;
|
||||
}
|
||||
|
||||
public function yellow(): float
|
||||
{
|
||||
return $this->yellow;
|
||||
}
|
||||
|
||||
public function key(): float
|
||||
{
|
||||
return $this->key;
|
||||
}
|
||||
|
||||
public function black(): float
|
||||
{
|
||||
return $this->key;
|
||||
}
|
||||
|
||||
public function toCmyk(): Cmyk
|
||||
{
|
||||
return new self($this->cyan, $this->magenta, $this->yellow, $this->key);
|
||||
}
|
||||
|
||||
public function toCIELab(): CIELab
|
||||
{
|
||||
return $this->toRgb()->toCIELab();
|
||||
}
|
||||
|
||||
public function toHex(?string $alpha = null): Hex
|
||||
{
|
||||
return $this->toRgb()->toHex($alpha ?? 'ff');
|
||||
}
|
||||
|
||||
public function toHsb(): Hsb
|
||||
{
|
||||
return $this->toRgb()->toHsb();
|
||||
}
|
||||
|
||||
public function toHsl(): Hsl
|
||||
{
|
||||
return $this->toRgb()->toHsl();
|
||||
}
|
||||
|
||||
public function toHsla(?float $alpha = null): Hsla
|
||||
{
|
||||
return $this->toRgb()->toHsla($alpha ?? 1);
|
||||
}
|
||||
|
||||
public function toRgb(): Rgb
|
||||
{
|
||||
list($red, $green, $blue) = Convert::cmykValueToRgb($this->cyan, $this->magenta, $this->yellow, $this->key);
|
||||
|
||||
return new Rgb($red, $green, $blue);
|
||||
}
|
||||
|
||||
public function toRgba(?float $alpha = null): Rgba
|
||||
{
|
||||
return $this->toRgb()->toRgba($alpha ?? 1);
|
||||
}
|
||||
|
||||
public function toXyz(): Xyz
|
||||
{
|
||||
return $this->toRgba()->toXyz();
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
$cyan = round($this->cyan * 100);
|
||||
$magenta = round($this->magenta * 100);
|
||||
$yellow = round($this->yellow * 100);
|
||||
$key = round($this->key * 100);
|
||||
|
||||
return "cmyk({$cyan}%,{$magenta}%,{$yellow}%,{$key}%)";
|
||||
}
|
||||
}
|
||||
34
vendor/spatie/color/src/Color.php
vendored
Normal file
34
vendor/spatie/color/src/Color.php
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Color;
|
||||
|
||||
interface Color
|
||||
{
|
||||
public static function fromString(string $string);
|
||||
|
||||
public function red();
|
||||
|
||||
public function green();
|
||||
|
||||
public function blue();
|
||||
|
||||
public function toCIELab(): CIELab;
|
||||
|
||||
public function toHex(?string $alpha = null): Hex;
|
||||
|
||||
public function toHsb(): Hsb;
|
||||
|
||||
public function toHsl(): Hsl;
|
||||
|
||||
public function toHsla(?float $alpha = null): Hsla;
|
||||
|
||||
public function toRgb(): Rgb;
|
||||
|
||||
public function toRgba(?float $alpha = null): Rgba;
|
||||
|
||||
public function toXyz(): Xyz;
|
||||
|
||||
public function toCmyk(): Cmyk;
|
||||
|
||||
public function __toString(): string;
|
||||
}
|
||||
30
vendor/spatie/color/src/Contrast.php
vendored
Normal file
30
vendor/spatie/color/src/Contrast.php
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Color;
|
||||
|
||||
class Contrast
|
||||
{
|
||||
public static function ratio(Color $a, Color $b): float
|
||||
{
|
||||
$a = $a instanceof Hex ? $a : $a->toHex();
|
||||
$b = $b instanceof Hex ? $b : $b->toHex();
|
||||
|
||||
$l1 = self::calculateLuminance($a);
|
||||
$l2 = self::calculateLuminance($b);
|
||||
|
||||
return round(
|
||||
($l1 > $l2)
|
||||
? ($l1 + 0.05) / ($l2 + 0.05)
|
||||
: ($l2 + 0.05) / ($l1 + 0.05),
|
||||
2
|
||||
);
|
||||
}
|
||||
|
||||
public static function calculateLuminance(Hex $color): float
|
||||
{
|
||||
return
|
||||
0.2126 * pow(hexdec($color->red()) / 255, 2.2) +
|
||||
0.7152 * pow(hexdec($color->green()) / 255, 2.2) +
|
||||
0.0722 * pow(hexdec($color->blue()) / 255, 2.2);
|
||||
}
|
||||
}
|
||||
399
vendor/spatie/color/src/Convert.php
vendored
Normal file
399
vendor/spatie/color/src/Convert.php
vendored
Normal file
@@ -0,0 +1,399 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Color;
|
||||
|
||||
class Convert
|
||||
{
|
||||
public static function CIELabValueToXyz(float $l, float $a, float $b): array
|
||||
{
|
||||
$y = ($l + 16) / 116;
|
||||
$x = $a / 500 + $y;
|
||||
$z = $y - $b / 200;
|
||||
|
||||
if (pow($y, 3) > 0.008856) {
|
||||
$y = pow($y, 3);
|
||||
} else {
|
||||
$y = ($y - 16 / 116) / 7.787;
|
||||
}
|
||||
|
||||
if (pow($x, 3) > 0.008856) {
|
||||
$x = pow($x, 3);
|
||||
} else {
|
||||
$x = ($x - 16 / 116) / 7.787;
|
||||
}
|
||||
|
||||
if (pow($z, 3) > 0.008856) {
|
||||
$z = pow($z, 3);
|
||||
} else {
|
||||
$z = ($z - 16 / 116) / 7.787;
|
||||
}
|
||||
|
||||
$x = round(95.047 * $x, 4);
|
||||
$y = round(100.000 * $y, 4);
|
||||
$z = round(108.883 * $z, 4);
|
||||
|
||||
if ($x > 95.047) {
|
||||
$x = 95.047;
|
||||
}
|
||||
if ($y > 100) {
|
||||
$y = 100;
|
||||
}
|
||||
if ($z > 108.883) {
|
||||
$z = 108.883;
|
||||
}
|
||||
|
||||
return [$x, $y, $z];
|
||||
}
|
||||
|
||||
public static function cmykValueToRgb(float $cyan, float $magenta, float $yellow, float $key): array
|
||||
{
|
||||
return [
|
||||
(int) (255 * (1 - $cyan) * (1 - $key)),
|
||||
(int) (255 * (1 - $magenta) * (1 - $key)),
|
||||
(int) (255 * (1 - $yellow) * (1 - $key)),
|
||||
];
|
||||
}
|
||||
|
||||
public static function rgbValueToCmyk($red, $green, $blue): array
|
||||
{
|
||||
$red /= 255;
|
||||
$green /= 255;
|
||||
$blue /= 255;
|
||||
|
||||
$black = 1 - max($red, $green, $blue);
|
||||
$keyNeg = (1 - $black);
|
||||
|
||||
return [
|
||||
(1 - $red - $black) / ($keyNeg ?: 1),
|
||||
(1 - $green - $black) / ($keyNeg ?: 1),
|
||||
(1 - $blue - $black) / ($keyNeg ?: 1),
|
||||
$black,
|
||||
];
|
||||
}
|
||||
|
||||
public static function hexChannelToRgbChannel(string $hexValue): int
|
||||
{
|
||||
return hexdec($hexValue);
|
||||
}
|
||||
|
||||
public static function rgbChannelToHexChannel(int $rgbValue): string
|
||||
{
|
||||
return str_pad(dechex($rgbValue), 2, '0', STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
public static function hexAlphaToFloat(string $hexAlpha): float
|
||||
{
|
||||
return round(static::hexChannelToRgbChannel($hexAlpha) / 255, 2);
|
||||
}
|
||||
|
||||
public static function floatAlphaToHex(float $floatAlpha): string
|
||||
{
|
||||
return static::rgbChannelToHexChannel(round($floatAlpha * 255, 0));
|
||||
}
|
||||
|
||||
public static function hsbValueToRgb($hue, $saturation, $brightness)
|
||||
{
|
||||
while ($hue > 360) {
|
||||
$hue -= 360.0;
|
||||
}
|
||||
while ($hue < 0) {
|
||||
$hue += 360.0;
|
||||
}
|
||||
|
||||
$hue /= 360;
|
||||
$saturation /= 100;
|
||||
$brightness /= 100;
|
||||
|
||||
if ($saturation == 0) {
|
||||
$R = $G = $B = $brightness * 255;
|
||||
} else {
|
||||
$hue = $hue * 6;
|
||||
$i = floor($hue);
|
||||
$j = $brightness * (1 - $saturation);
|
||||
$k = $brightness * (1 - $saturation * ($hue - $i));
|
||||
$l = $brightness * (1 - $saturation * (1 - ($hue - $i)));
|
||||
|
||||
switch ($i) {
|
||||
case 0:
|
||||
$red = $brightness;
|
||||
$green = $l;
|
||||
$blue = $j;
|
||||
|
||||
break;
|
||||
|
||||
case 1:
|
||||
$red = $k;
|
||||
$green = $brightness;
|
||||
$blue = $j;
|
||||
|
||||
break;
|
||||
|
||||
case 2:
|
||||
$red = $j;
|
||||
$green = $brightness;
|
||||
$blue = $l;
|
||||
|
||||
break;
|
||||
|
||||
case 3:
|
||||
$red = $j;
|
||||
$green = $k;
|
||||
$blue = $brightness;
|
||||
|
||||
break;
|
||||
|
||||
case 4:
|
||||
$red = $l;
|
||||
$green = $j;
|
||||
$blue = $brightness;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
$red = $brightness;
|
||||
$green = $j;
|
||||
$blue = $k;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
$R = $red * 255;
|
||||
$G = $green * 255;
|
||||
$B = $blue * 255;
|
||||
}
|
||||
|
||||
return [round($R), round($G), round($B)];
|
||||
}
|
||||
|
||||
public static function hslValueToRgb(float $hue, float $saturation, float $lightness): array
|
||||
{
|
||||
$h = intval((360 + (intval($hue) % 360)) % 360); // hue values can be less than 0 and greater than 360. This normalises them into the range 0-360.
|
||||
|
||||
$c = (1 - abs(2 * ($lightness / 100) - 1)) * ($saturation / 100);
|
||||
$x = $c * (1 - abs(fmod($h / 60, 2) - 1));
|
||||
$m = ($lightness / 100) - ($c / 2);
|
||||
|
||||
if ($h >= 0 && $h <= 60) {
|
||||
return [round(($c + $m) * 255), round(($x + $m) * 255), round($m * 255)];
|
||||
}
|
||||
|
||||
if ($h > 60 && $h <= 120) {
|
||||
return [round(($x + $m) * 255), round(($c + $m) * 255), round($m * 255)];
|
||||
}
|
||||
|
||||
if ($h > 120 && $h <= 180) {
|
||||
return [round($m * 255), round(($c + $m) * 255), round(($x + $m) * 255)];
|
||||
}
|
||||
|
||||
if ($h > 180 && $h <= 240) {
|
||||
return [round($m * 255), round(($x + $m) * 255), round(($c + $m) * 255)];
|
||||
}
|
||||
|
||||
if ($h > 240 && $h <= 300) {
|
||||
return [round(($x + $m) * 255), round($m * 255), round(($c + $m) * 255)];
|
||||
}
|
||||
|
||||
if ($h > 300 && $h <= 360) {
|
||||
return [round(($c + $m) * 255), round($m * 255), round(($x + $m) * 255)];
|
||||
}
|
||||
}
|
||||
|
||||
public static function rgbValueToHsb($red, $green, $blue): array
|
||||
{
|
||||
$red /= 255;
|
||||
$green /= 255;
|
||||
$blue /= 255;
|
||||
|
||||
$min = min($red, $green, $blue);
|
||||
$max = max($red, $green, $blue);
|
||||
$delMax = $max - $min;
|
||||
|
||||
$brightness = $max;
|
||||
$hue = 0;
|
||||
|
||||
if ($delMax == 0) {
|
||||
$hue = 0;
|
||||
$saturation = 0;
|
||||
} else {
|
||||
$saturation = $delMax / $max;
|
||||
|
||||
$delR = ((($max - $red) / 6) + ($delMax / 2)) / $delMax;
|
||||
$delG = ((($max - $green) / 6) + ($delMax / 2)) / $delMax;
|
||||
$delB = ((($max - $blue) / 6) + ($delMax / 2)) / $delMax;
|
||||
|
||||
if ($red == $max) {
|
||||
$hue = $delB - $delG;
|
||||
} else {
|
||||
if ($green == $max) {
|
||||
$hue = (1 / 3) + $delR - $delB;
|
||||
} else {
|
||||
if ($blue == $max) {
|
||||
$hue = (2 / 3) + $delG - $delR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($hue < 0) {
|
||||
$hue++;
|
||||
}
|
||||
if ($hue > 1) {
|
||||
$hue--;
|
||||
}
|
||||
}
|
||||
|
||||
return [round($hue, 2) * 360, round($saturation, 2) * 100, round($brightness, 2) * 100];
|
||||
}
|
||||
|
||||
public static function rgbValueToHsl($red, $green, $blue): array
|
||||
{
|
||||
$r = $red / 255;
|
||||
$g = $green / 255;
|
||||
$b = $blue / 255;
|
||||
|
||||
$cmax = max($r, $g, $b);
|
||||
$cmin = min($r, $g, $b);
|
||||
$delta = $cmax - $cmin;
|
||||
|
||||
$hue = 0;
|
||||
if ($delta != 0) {
|
||||
if ($r === $cmax) {
|
||||
$hue = 60 * fmod(($g - $b) / $delta, 6);
|
||||
$hue = $hue < 0 ? $hue + 360 : $hue ;
|
||||
}
|
||||
|
||||
if ($g === $cmax) {
|
||||
$hue = 60 * ((($b - $r) / $delta) + 2);
|
||||
}
|
||||
|
||||
if ($b === $cmax) {
|
||||
$hue = 60 * ((($r - $g) / $delta) + 4);
|
||||
}
|
||||
}
|
||||
|
||||
$lightness = ($cmax + $cmin) / 2;
|
||||
|
||||
$saturation = 0;
|
||||
|
||||
if ($lightness > 0 && $lightness < 1) {
|
||||
$saturation = $delta / (1 - abs((2 * $lightness) - 1));
|
||||
}
|
||||
|
||||
return [$hue, min($saturation, 1) * 100, min($lightness, 1) * 100];
|
||||
}
|
||||
|
||||
public static function rgbValueToXyz($red, $green, $blue): array
|
||||
{
|
||||
$red = $red / 255;
|
||||
$green = $green / 255;
|
||||
$blue = $blue / 255;
|
||||
|
||||
if ($red > 0.04045) {
|
||||
$red = pow((($red + 0.055) / 1.055), 2.4);
|
||||
} else {
|
||||
$red = $red / 12.92;
|
||||
}
|
||||
|
||||
if ($green > 0.04045) {
|
||||
$green = pow((($green + 0.055) / 1.055), 2.4);
|
||||
} else {
|
||||
$green = $green / 12.92;
|
||||
}
|
||||
|
||||
if ($blue > 0.04045) {
|
||||
$blue = pow((($blue + 0.055) / 1.055), 2.4);
|
||||
} else {
|
||||
$blue = $blue / 12.92;
|
||||
}
|
||||
|
||||
$red = $red * 100;
|
||||
$green = $green * 100;
|
||||
$blue = $blue * 100;
|
||||
$x = round($red * 0.4124 + $green * 0.3576 + $blue * 0.1805, 4);
|
||||
$y = round($red * 0.2126 + $green * 0.7152 + $blue * 0.0722, 4);
|
||||
$z = round($red * 0.0193 + $green * 0.1192 + $blue * 0.9505, 4);
|
||||
|
||||
if ($x > 95.047) {
|
||||
$x = 95.047;
|
||||
}
|
||||
if ($y > 100) {
|
||||
$y = 100;
|
||||
}
|
||||
if ($z > 108.883) {
|
||||
$z = 108.883;
|
||||
}
|
||||
|
||||
return [$x, $y, $z];
|
||||
}
|
||||
|
||||
public static function xyzValueToCIELab(float $x, float $y, float $z): array
|
||||
{
|
||||
$x = $x / 95.047;
|
||||
$y = $y / 100.000;
|
||||
$z = $z / 108.883;
|
||||
|
||||
if ($x > 0.008856) {
|
||||
$x = pow($x, 1 / 3);
|
||||
} else {
|
||||
$x = (7.787 * $x) + (16 / 116);
|
||||
}
|
||||
|
||||
if ($y > 0.008856) {
|
||||
$y = pow($y, 1 / 3);
|
||||
} else {
|
||||
$y = (7.787 * $y) + (16 / 116);
|
||||
}
|
||||
|
||||
if ($y > 0.008856) {
|
||||
$l = (116 * $y) - 16;
|
||||
} else {
|
||||
$l = 903.3 * $y;
|
||||
}
|
||||
|
||||
if ($z > 0.008856) {
|
||||
$z = pow($z, 1 / 3);
|
||||
} else {
|
||||
$z = (7.787 * $z) + (16 / 116);
|
||||
}
|
||||
|
||||
$l = round($l, 2);
|
||||
$a = round(500 * ($x - $y), 2);
|
||||
$b = round(200 * ($y - $z), 2);
|
||||
|
||||
return [$l, $a, $b];
|
||||
}
|
||||
|
||||
public static function xyzValueToRgb(float $x, float $y, float $z): array
|
||||
{
|
||||
$x = $x / 100;
|
||||
$y = $y / 100;
|
||||
$z = $z / 100;
|
||||
|
||||
$r = $x * 3.2406 + $y * -1.5372 + $z * -0.4986;
|
||||
$g = $x * -0.9689 + $y * 1.8758 + $z * 0.0415;
|
||||
$b = $x * 0.0557 + $y * -0.2040 + $z * 1.0570;
|
||||
|
||||
if ($r > 0.0031308) {
|
||||
$r = 1.055 * pow($r, (1 / 2.4)) - 0.055;
|
||||
} else {
|
||||
$r = 12.92 * $r;
|
||||
}
|
||||
|
||||
if ($g > 0.0031308) {
|
||||
$g = 1.055 * pow($g, (1 / 2.4)) - 0.055;
|
||||
} else {
|
||||
$g = 12.92 * $g;
|
||||
}
|
||||
|
||||
if ($b > 0.0031308) {
|
||||
$b = 1.055 * pow($b, (1 / 2.4)) - 0.055;
|
||||
} else {
|
||||
$b = 12.92 * $b;
|
||||
}
|
||||
|
||||
$r = intval(max(0, min(255, $r * 255)));
|
||||
$g = intval(max(0, min(255, $g * 255)));
|
||||
$b = intval(max(0, min(255, $b * 255)));
|
||||
|
||||
return [$r, $g, $b];
|
||||
}
|
||||
}
|
||||
155
vendor/spatie/color/src/Distance.php
vendored
Normal file
155
vendor/spatie/color/src/Distance.php
vendored
Normal file
@@ -0,0 +1,155 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Color;
|
||||
|
||||
class Distance
|
||||
{
|
||||
public static function CIE76($color1, $color2): float
|
||||
{
|
||||
if (gettype($color1) === 'string') {
|
||||
$color1 = Factory::fromString($color1);
|
||||
}
|
||||
|
||||
if (gettype($color2) === 'string') {
|
||||
$color2 = Factory::fromString($color2);
|
||||
}
|
||||
|
||||
$lab1 = $color1->toCIELab();
|
||||
$lab2 = $color2->toCIELab();
|
||||
|
||||
if (strval($lab1) === strval($lab2)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$sum = 0;
|
||||
$sum += pow($lab1->l() - $lab2->l(), 2);
|
||||
$sum += pow($lab1->a() - $lab2->a(), 2);
|
||||
$sum += pow($lab1->b() - $lab2->b(), 2);
|
||||
|
||||
return max(min(sqrt($sum), 100), 0);
|
||||
}
|
||||
|
||||
public static function CIE94($color1, $color2, $textiles = 0): float
|
||||
{
|
||||
if (gettype($color1) === 'string') {
|
||||
$color1 = Factory::fromString($color1);
|
||||
}
|
||||
|
||||
if (gettype($color2) === 'string') {
|
||||
$color2 = Factory::fromString($color2);
|
||||
}
|
||||
|
||||
$lab1 = $color1->toCIELab();
|
||||
$lab2 = $color2->toCIELab();
|
||||
|
||||
$l1 = $lab1->l();
|
||||
$a1 = $lab1->a();
|
||||
$b1 = $lab1->b();
|
||||
|
||||
$l2 = $lab2->l();
|
||||
$a2 = $lab2->a();
|
||||
$b2 = $lab2->b();
|
||||
|
||||
$delta_l = $l1 - $l2;
|
||||
$delta_a = $a1 - $a2;
|
||||
$delta_b = $b1 - $b2;
|
||||
|
||||
$c1 = sqrt(pow($a1, 2) + pow($b1, 2));
|
||||
$c2 = sqrt(pow($a2, 2) + pow($b2, 2));
|
||||
$delta_c = $c1 - $c2;
|
||||
|
||||
$delta_h = pow($delta_a, 2) + pow($delta_b, 2) - pow($delta_c, 2);
|
||||
$delta_h = $delta_h < 0 ? 0 : sqrt($delta_h);
|
||||
|
||||
if ($textiles) {
|
||||
$kl = 2.0;
|
||||
$k1 = .048;
|
||||
$k2 = .014;
|
||||
} else {
|
||||
$kl = 1.0;
|
||||
$k1 = .045;
|
||||
$k2 = .015;
|
||||
}
|
||||
|
||||
$sc = 1.0 + $k1 * $c1;
|
||||
$sh = 1.0 + $k2 * $c1;
|
||||
|
||||
$i = pow($delta_l / $kl, 2) + pow($delta_c / $sc, 2) + pow($delta_h / $sh, 2);
|
||||
|
||||
return $i < 0 ? 0 : sqrt($i);
|
||||
}
|
||||
|
||||
public static function CIEDE2000($color1, $color2): float
|
||||
{
|
||||
if (gettype($color1) === 'string') {
|
||||
$color1 = Factory::fromString($color1);
|
||||
}
|
||||
|
||||
if (gettype($color2) === 'string') {
|
||||
$color2 = Factory::fromString($color2);
|
||||
}
|
||||
|
||||
$lab1 = $color1->toCIELab();
|
||||
$lab2 = $color2->toCIELab();
|
||||
|
||||
$l1 = $lab1->l();
|
||||
$a1 = $lab1->a();
|
||||
$b1 = $lab1->b();
|
||||
|
||||
$l2 = $lab2->l();
|
||||
$a2 = $lab2->a();
|
||||
$b2 = $lab2->b();
|
||||
|
||||
$avg_lp = ($l1 + $l2) / 2;
|
||||
$c1 = sqrt(pow($a1, 2) + pow($b1, 2));
|
||||
$c2 = sqrt(pow($a2, 2) + pow($b2, 2));
|
||||
$avg_c = ($c1 + $c2) / 2;
|
||||
$g = (1 - sqrt(pow($avg_c, 7) / (pow($avg_c, 7) + pow(25, 7)))) / 2;
|
||||
$a1p = $a1 * (1 + $g);
|
||||
$a2p = $a2 * (1 + $g);
|
||||
$c1p = sqrt(pow($a1p, 2) + pow($b1, 2));
|
||||
$c2p = sqrt(pow($a2p, 2) + pow($b2, 2));
|
||||
$avg_cp = ($c1p + $c2p) / 2;
|
||||
$h1p = rad2deg(atan2($b1, $a1p));
|
||||
|
||||
if ($h1p < 0) {
|
||||
$h1p += 360;
|
||||
}
|
||||
|
||||
$h2p = rad2deg(atan2($b2, $a2p));
|
||||
|
||||
if ($h2p < 0) {
|
||||
$h2p += 360;
|
||||
}
|
||||
|
||||
$avg_hp = abs($h1p - $h2p) > 180 ? ($h1p + $h2p + 360) / 2 : ($h1p + $h2p) / 2;
|
||||
$t = 1 - 0.17 * cos(deg2rad($avg_hp - 30)) + 0.24 * cos(deg2rad(2 * $avg_hp)) + 0.32 * cos(deg2rad(3 * $avg_hp + 6)) - 0.2 * cos(deg2rad(4 * $avg_hp - 63));
|
||||
$delta_hp = $h2p - $h1p;
|
||||
|
||||
if (abs($delta_hp) > 180) {
|
||||
if ($h2p <= $h1p) {
|
||||
$delta_hp += 360;
|
||||
} else {
|
||||
$delta_hp -= 360;
|
||||
}
|
||||
}
|
||||
|
||||
$delta_lp = $l2 - $l1;
|
||||
$delta_cp = $c2p - $c1p;
|
||||
$delta_hp = 2 * sqrt($c1p * $c2p) * sin(deg2rad($delta_hp) / 2);
|
||||
|
||||
$s_l = 1 + ((0.015 * pow($avg_lp - 50, 2)) / sqrt(20 + pow($avg_lp - 50, 2)));
|
||||
$s_c = 1 + 0.045 * $avg_cp;
|
||||
$s_h = 1 + 0.015 * $avg_cp * $t;
|
||||
|
||||
$delta_ro = 30 * exp(-(pow(($avg_hp - 275) / 25, 2)));
|
||||
$r_c = 2 * sqrt(pow($avg_cp, 7) / (pow($avg_cp, 7) + pow(25, 7)));
|
||||
$r_t = -$r_c * sin(2 * deg2rad($delta_ro));
|
||||
|
||||
$kl = $kc = $kh = 1;
|
||||
|
||||
$delta_e = sqrt(pow($delta_lp / ($s_l * $kl), 2) + pow($delta_cp / ($s_c * $kc), 2) + pow($delta_hp / ($s_h * $kh), 2) + $r_t * ($delta_cp / ($s_c * $kc)) * ($delta_hp / ($s_h * $kh)));
|
||||
|
||||
return $delta_e;
|
||||
}
|
||||
}
|
||||
105
vendor/spatie/color/src/Exceptions/InvalidColorValue.php
vendored
Normal file
105
vendor/spatie/color/src/Exceptions/InvalidColorValue.php
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Color\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class InvalidColorValue extends Exception
|
||||
{
|
||||
public static function CIELabValueNotInRange(float $value, string $name, float $min, float $max): self
|
||||
{
|
||||
return new static("CIELab value `{$name}` must be a number between $min and $max");
|
||||
}
|
||||
|
||||
public static function rgbChannelValueNotInRange(int $value, string $channel): self
|
||||
{
|
||||
return new static("An rgb values must be an integer between 0 and 255, `{$value}` provided for channel {$channel}.");
|
||||
}
|
||||
|
||||
public static function alphaChannelValueNotInRange(float $value): self
|
||||
{
|
||||
return new static("An alpha values must be a float between 0 and 1, `{$value}` provided.");
|
||||
}
|
||||
|
||||
public static function hexChannelValueHasInvalidLength(string $value): self
|
||||
{
|
||||
$length = strlen($value);
|
||||
|
||||
return new static("Hex values must contain exactly 2 characters, `{$value}` contains {$length} characters.");
|
||||
}
|
||||
|
||||
public static function malformedCIELabColorString(string $string): self
|
||||
{
|
||||
return new static("CIELab color string `{$string}` is malformed. A CIELab color contains 3 comma separated values, wrapped in `CIELab()`, e.g. `CIELab(62.91,5.34,-57.73)`.");
|
||||
}
|
||||
|
||||
public static function cmykValueNotInRange(float $value, string $name): self
|
||||
{
|
||||
return new static("Cmyk value `{$name}` must be a number between 0 and 1");
|
||||
}
|
||||
|
||||
public static function hexValueContainsInvalidCharacters(string $value): self
|
||||
{
|
||||
return new static("Hex values can only contain numbers or letters from A-F, `{$value}` contains invalid characters.");
|
||||
}
|
||||
|
||||
public static function hsbValueNotInRange(float $value, string $name): self
|
||||
{
|
||||
return new static("Hsb value `{$name}` must be a number between 0 and 100");
|
||||
}
|
||||
|
||||
public static function hslValueNotInRange(float $value, string $name): self
|
||||
{
|
||||
return new static("Hsl value `{$name}` must be a number between 0 and 100");
|
||||
}
|
||||
|
||||
public static function malformedCmykColorString(string $string): self
|
||||
{
|
||||
return new static("Cmyk color string `{$string}` is malformed. A cmyk color contains cyan, magenta, yellow and key (black) values, wrapped in `cmyk()`, e.g. `cmyk(100%,100%,100%,100%)`.");
|
||||
}
|
||||
|
||||
public static function malformedHexColorString(string $string): self
|
||||
{
|
||||
return new static("Hex color string `{$string}` is malformed. A hex color string starts with a `#` and contains exactly six characters, e.g. `#aabbcc`.");
|
||||
}
|
||||
|
||||
public static function malformedHslColorString(string $string): self
|
||||
{
|
||||
return new static("Hsl color string `{$string}` is malformed. An hsl color contains hue, saturation, and lightness values, wrapped in `hsl()`, e.g. `hsl(300,10%,50%)`.");
|
||||
}
|
||||
|
||||
public static function malformedHslaColorString(string $string): self
|
||||
{
|
||||
return new static("Hsla color string `{$string}` is malformed. An hsla color contains hue, saturation, lightness and alpha values, wrapped in `hsla()`, e.g. `hsla(300,10%,50%,0.25)`.");
|
||||
}
|
||||
|
||||
public static function malformedRgbColorString(string $string): self
|
||||
{
|
||||
return new static("Rgb color string `{$string}` is malformed. An rgb color contains 3 comma separated values between 0 and 255, wrapped in `rgb()`, e.g. `rgb(0,0,255)`.");
|
||||
}
|
||||
|
||||
public static function malformedRgbaColorString(string $string): self
|
||||
{
|
||||
return new static("Rgba color string `{$string}` is malformed. An rgba color contains 3 comma separated values between 0 and 255 with an alpha value between 0 and 1, wrapped in `rgba()`, e.g. `rgb(0,0,255,0.5)`.");
|
||||
}
|
||||
|
||||
public static function malformedColorString(string $string): self
|
||||
{
|
||||
return new static("Color string `{$string}` doesn't match any of the available colors.");
|
||||
}
|
||||
|
||||
public static function malformedXyzColorString(string $string): self
|
||||
{
|
||||
return new static("Xyz color string `{$string}` is malformed. An xyz color contains 3 comma separated values, wrapped in `xyz()`, e.g. `xyz(31.3469,31.4749,99.0308)`.");
|
||||
}
|
||||
|
||||
public static function xyzValueNotInRange(float $value, string $name, float $min, float $max): self
|
||||
{
|
||||
return new static("Xyz value `{$name}` must be a number between $min and $max");
|
||||
}
|
||||
|
||||
public static function malformedNamedColorString(string $string): self
|
||||
{
|
||||
return new static("Color string `{$string}` doesn't match any of the available colors.");
|
||||
}
|
||||
}
|
||||
39
vendor/spatie/color/src/Factory.php
vendored
Normal file
39
vendor/spatie/color/src/Factory.php
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Color;
|
||||
|
||||
use Spatie\Color\Exceptions\InvalidColorValue;
|
||||
|
||||
class Factory
|
||||
{
|
||||
public static function fromString(string $string): Color
|
||||
{
|
||||
$colorClasses = static::getColorClasses();
|
||||
|
||||
foreach ($colorClasses as $colorClass) {
|
||||
try {
|
||||
return $colorClass::fromString($string);
|
||||
} catch (InvalidColorValue $e) {
|
||||
// Catch the exception but never throw it.
|
||||
}
|
||||
}
|
||||
|
||||
throw InvalidColorValue::malformedColorString($string);
|
||||
}
|
||||
|
||||
protected static function getColorClasses(): array
|
||||
{
|
||||
return [
|
||||
Named::class,
|
||||
CIELab::class,
|
||||
Cmyk::class,
|
||||
Hex::class,
|
||||
Hsb::class,
|
||||
Hsl::class,
|
||||
Hsla::class,
|
||||
Rgb::class,
|
||||
Rgba::class,
|
||||
Xyz::class,
|
||||
];
|
||||
}
|
||||
}
|
||||
146
vendor/spatie/color/src/Hex.php
vendored
Normal file
146
vendor/spatie/color/src/Hex.php
vendored
Normal file
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Color;
|
||||
|
||||
class Hex implements Color
|
||||
{
|
||||
/** @var string */
|
||||
protected $red;
|
||||
protected $green;
|
||||
protected $blue;
|
||||
protected $alpha = 'ff';
|
||||
|
||||
public function __construct(string $red, string $green, string $blue, string $alpha = 'ff')
|
||||
{
|
||||
Validate::hexChannelValue($red);
|
||||
Validate::hexChannelValue($green);
|
||||
Validate::hexChannelValue($blue);
|
||||
Validate::hexChannelValue($alpha);
|
||||
|
||||
$this->red = strtolower($red);
|
||||
$this->green = strtolower($green);
|
||||
$this->blue = strtolower($blue);
|
||||
$this->alpha = strtolower($alpha);
|
||||
}
|
||||
|
||||
public static function fromString(string $string)
|
||||
{
|
||||
Validate::hexColorString($string);
|
||||
|
||||
$string = ltrim($string, '#');
|
||||
|
||||
switch (strlen($string)) {
|
||||
case 3:
|
||||
[$red, $green, $blue] = str_split($string);
|
||||
$red .= $red;
|
||||
$green .= $green;
|
||||
$blue .= $blue;
|
||||
$alpha = 'ff';
|
||||
|
||||
break;
|
||||
|
||||
case 4:
|
||||
[$red, $green, $blue, $alpha] = str_split($string);
|
||||
$red .= $red;
|
||||
$green .= $green;
|
||||
$blue .= $blue;
|
||||
$alpha .= $alpha;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
case 6:
|
||||
[$red, $green, $blue] = str_split($string, 2);
|
||||
$alpha = 'ff';
|
||||
|
||||
break;
|
||||
|
||||
case 8:
|
||||
[$red, $green, $blue, $alpha] = str_split($string, 2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return new static($red, $green, $blue, $alpha);
|
||||
}
|
||||
|
||||
public function red(): string
|
||||
{
|
||||
return $this->red;
|
||||
}
|
||||
|
||||
public function green(): string
|
||||
{
|
||||
return $this->green;
|
||||
}
|
||||
|
||||
public function blue(): string
|
||||
{
|
||||
return $this->blue;
|
||||
}
|
||||
|
||||
public function alpha(): string
|
||||
{
|
||||
return $this->alpha;
|
||||
}
|
||||
|
||||
public function toCIELab(): CIELab
|
||||
{
|
||||
return $this->toRgb()->toCIELab();
|
||||
}
|
||||
|
||||
public function toCmyk(): Cmyk
|
||||
{
|
||||
return $this->toRgb()->toCmyk();
|
||||
}
|
||||
|
||||
public function toHex(?string $alpha = null): self
|
||||
{
|
||||
return new self($this->red, $this->green, $this->blue, $alpha ?? $this->alpha);
|
||||
}
|
||||
|
||||
public function toHsb(): Hsb
|
||||
{
|
||||
return $this->toRgb()->toHsb();
|
||||
}
|
||||
|
||||
public function toHsl(): Hsl
|
||||
{
|
||||
[$hue, $saturation, $lightness] = Convert::rgbValueToHsl(
|
||||
Convert::hexChannelToRgbChannel($this->red),
|
||||
Convert::hexChannelToRgbChannel($this->green),
|
||||
Convert::hexChannelToRgbChannel($this->blue)
|
||||
);
|
||||
|
||||
return new Hsl($hue, $saturation, $lightness);
|
||||
}
|
||||
|
||||
public function toHsla(?float $alpha = null): Hsla
|
||||
{
|
||||
return $this->toRgb()->toHsla($alpha ?? Convert::hexAlphaToFloat($this->alpha));
|
||||
}
|
||||
|
||||
public function toRgb(): Rgb
|
||||
{
|
||||
return new Rgb(
|
||||
Convert::hexChannelToRgbChannel($this->red),
|
||||
Convert::hexChannelToRgbChannel($this->green),
|
||||
Convert::hexChannelToRgbChannel($this->blue)
|
||||
);
|
||||
}
|
||||
|
||||
public function toRgba(?float $alpha = null): Rgba
|
||||
{
|
||||
return $this->toRgb()->toRgba($alpha ?? Convert::hexAlphaToFloat($this->alpha));
|
||||
}
|
||||
|
||||
public function toXyz(): Xyz
|
||||
{
|
||||
return $this->toRgb()->toXyz();
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
return "#{$this->red}{$this->green}{$this->blue}" . ($this->alpha !== 'ff' ? $this->alpha : '');
|
||||
}
|
||||
}
|
||||
40
vendor/spatie/color/src/HsPatterns.php
vendored
Normal file
40
vendor/spatie/color/src/HsPatterns.php
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Color;
|
||||
|
||||
class HsPatterns
|
||||
{
|
||||
protected const HUE = '\d{1,3}';
|
||||
protected const COMPONENT = '\d{1,3}(?:\.\d+)?%?';
|
||||
protected const ALPHA = '[0-1](?:\.\d{1,2})?';
|
||||
|
||||
private const VALIDATION_PATTERNS = [
|
||||
'hsb' => '/^ *hs[vb]\( *-?' . self::HUE . ' *, *' . self::COMPONENT . ' *, *' . self::COMPONENT . ' *\) *$/i',
|
||||
'hsl' => '/^ *hsl\( *-?' . self::HUE . ' *, *' . self::COMPONENT . ' *, *' . self::COMPONENT . ' *\) *$/i',
|
||||
'hsla' => '/^ *hsla\( *' . self::HUE . ' *, *' . self::COMPONENT . ' *, *' . self::COMPONENT . ' *, *' . self::ALPHA . ' *\) *$/i',
|
||||
];
|
||||
|
||||
private const EXTRACTION_PATTERNS = [
|
||||
'hsb' => '/hs[vb]\( *(-?' . self::HUE . ') *, *(' . self::COMPONENT . ') *, *(' . self::COMPONENT . ') *\)/i',
|
||||
'hsl' => '/hsl\( *(-?' . self::HUE . ') *, *(' . self::COMPONENT . ') *, *(' . self::COMPONENT . ') *\)/i',
|
||||
'hsla' => '/hsla\( *(' . self::HUE . ') *, *(' . self::COMPONENT . ') *, *(' . self::COMPONENT . ') *, *(' . self::ALPHA . ') *\)/i',
|
||||
];
|
||||
|
||||
public static function getValidationPattern(string $type): string
|
||||
{
|
||||
if (! isset(self::VALIDATION_PATTERNS[$type])) {
|
||||
throw new \InvalidArgumentException('Invalid color type: ' . $type);
|
||||
}
|
||||
|
||||
return self::VALIDATION_PATTERNS[$type];
|
||||
}
|
||||
|
||||
public static function getExtractionPattern(string $type): string
|
||||
{
|
||||
if (! isset(self::EXTRACTION_PATTERNS[$type])) {
|
||||
throw new \InvalidArgumentException('Invalid color type: ' . $type);
|
||||
}
|
||||
|
||||
return self::EXTRACTION_PATTERNS[$type];
|
||||
}
|
||||
}
|
||||
120
vendor/spatie/color/src/Hsb.php
vendored
Normal file
120
vendor/spatie/color/src/Hsb.php
vendored
Normal file
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Color;
|
||||
|
||||
class Hsb implements Color
|
||||
{
|
||||
/** @var float */
|
||||
protected $hue;
|
||||
protected $saturation;
|
||||
protected $brightness;
|
||||
|
||||
public function __construct(float $hue, float $saturation, float $brightness)
|
||||
{
|
||||
Validate::hsbValue($hue, 'hue');
|
||||
Validate::hsbValue($saturation, 'saturation');
|
||||
Validate::hsbValue($brightness, 'brightness');
|
||||
|
||||
$this->hue = $hue;
|
||||
$this->saturation = $saturation;
|
||||
$this->brightness = $brightness;
|
||||
}
|
||||
|
||||
public static function fromString(string $string)
|
||||
{
|
||||
Validate::hsbColorString($string);
|
||||
|
||||
$matches = null;
|
||||
preg_match(HsPatterns::getExtractionPattern('hsb'), $string, $matches);
|
||||
|
||||
return new static(
|
||||
(float) $matches[1],
|
||||
(float) $matches[2],
|
||||
(float) $matches[3],
|
||||
);
|
||||
}
|
||||
|
||||
public function hue(): float
|
||||
{
|
||||
return $this->hue;
|
||||
}
|
||||
|
||||
public function saturation(): float
|
||||
{
|
||||
return $this->saturation;
|
||||
}
|
||||
|
||||
public function brightness(): float
|
||||
{
|
||||
return $this->brightness;
|
||||
}
|
||||
|
||||
public function red(): int
|
||||
{
|
||||
return Convert::hsbValueToRgb($this->hue, $this->saturation, $this->brightness)[0];
|
||||
}
|
||||
|
||||
public function green(): int
|
||||
{
|
||||
return Convert::hsbValueToRgb($this->hue, $this->saturation, $this->brightness)[1];
|
||||
}
|
||||
|
||||
public function blue(): int
|
||||
{
|
||||
return Convert::hsbValueToRgb($this->hue, $this->saturation, $this->brightness)[2];
|
||||
}
|
||||
|
||||
public function toCIELab(): CIELab
|
||||
{
|
||||
return $this->toRgb()->toCIELab();
|
||||
}
|
||||
|
||||
public function toCmyk(): Cmyk
|
||||
{
|
||||
return $this->toRgb()->toCmyk();
|
||||
}
|
||||
|
||||
public function toHsb(): Hsb
|
||||
{
|
||||
return new self($this->hue, $this->saturation, $this->brightness);
|
||||
}
|
||||
|
||||
public function toHex(?string $alpha = null): Hex
|
||||
{
|
||||
return $this->toRgb()->toHex($alpha ?? 'ff');
|
||||
}
|
||||
|
||||
public function toHsl(): Hsl
|
||||
{
|
||||
return $this->toRgb()->toHsl();
|
||||
}
|
||||
|
||||
public function toHsla(?float $alpha = null): Hsla
|
||||
{
|
||||
return $this->toRgb()->toHsla($alpha ?? 1);
|
||||
}
|
||||
|
||||
public function toRgb(): Rgb
|
||||
{
|
||||
return new Rgb($this->red(), $this->green(), $this->blue());
|
||||
}
|
||||
|
||||
public function toRgba(?float $alpha = null): Rgba
|
||||
{
|
||||
return new Rgba($this->red(), $this->green(), $this->blue(), $alpha ?? 1);
|
||||
}
|
||||
|
||||
public function toXyz(): Xyz
|
||||
{
|
||||
return $this->toRgb()->toXyz();
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
$hue = round($this->hue);
|
||||
$saturation = round($this->saturation);
|
||||
$brightness = round($this->brightness);
|
||||
|
||||
return "hsb({$hue},{$saturation}%,{$brightness}%)";
|
||||
}
|
||||
}
|
||||
121
vendor/spatie/color/src/Hsl.php
vendored
Normal file
121
vendor/spatie/color/src/Hsl.php
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Color;
|
||||
|
||||
class Hsl implements Color
|
||||
{
|
||||
/** @var float */
|
||||
protected $hue;
|
||||
protected $saturation;
|
||||
protected $lightness;
|
||||
|
||||
public function __construct(float $hue, float $saturation, float $lightness)
|
||||
{
|
||||
Validate::hslValue($saturation, 'saturation');
|
||||
Validate::hslValue($lightness, 'lightness');
|
||||
|
||||
$this->hue = $hue;
|
||||
$this->saturation = $saturation;
|
||||
$this->lightness = $lightness;
|
||||
}
|
||||
|
||||
public static function fromString(string $string)
|
||||
{
|
||||
Validate::hslColorString($string);
|
||||
|
||||
$matches = null;
|
||||
|
||||
|
||||
preg_match(HsPatterns::getExtractionPattern('hsl'), $string, $matches);
|
||||
|
||||
return new static(
|
||||
(float) $matches[1],
|
||||
(float) $matches[2],
|
||||
(float) $matches[3],
|
||||
);
|
||||
}
|
||||
|
||||
public function hue(): float
|
||||
{
|
||||
return $this->hue;
|
||||
}
|
||||
|
||||
public function saturation(): float
|
||||
{
|
||||
return $this->saturation;
|
||||
}
|
||||
|
||||
public function lightness(): float
|
||||
{
|
||||
return $this->lightness;
|
||||
}
|
||||
|
||||
public function red(): int
|
||||
{
|
||||
return Convert::hslValueToRgb($this->hue, $this->saturation, $this->lightness)[0];
|
||||
}
|
||||
|
||||
public function green(): int
|
||||
{
|
||||
return Convert::hslValueToRgb($this->hue, $this->saturation, $this->lightness)[1];
|
||||
}
|
||||
|
||||
public function blue(): int
|
||||
{
|
||||
return Convert::hslValueToRgb($this->hue, $this->saturation, $this->lightness)[2];
|
||||
}
|
||||
|
||||
public function toCIELab(): CIELab
|
||||
{
|
||||
return $this->toRgb()->toCIELab();
|
||||
}
|
||||
|
||||
public function toCmyk(): Cmyk
|
||||
{
|
||||
return $this->toRgb()->toCmyk();
|
||||
}
|
||||
|
||||
public function toHex(?string $alpha = null): Hex
|
||||
{
|
||||
return $this->toRgb()->toHex($alpha ?? 'ff');
|
||||
}
|
||||
|
||||
public function toHsb(): Hsb
|
||||
{
|
||||
return $this->toRgb()->toHsb();
|
||||
}
|
||||
|
||||
public function toHsl(): self
|
||||
{
|
||||
return new self($this->hue(), $this->saturation(), $this->lightness());
|
||||
}
|
||||
|
||||
public function toHsla(?float $alpha = null): Hsla
|
||||
{
|
||||
return new Hsla($this->hue(), $this->saturation(), $this->lightness(), $alpha ?? 1);
|
||||
}
|
||||
|
||||
public function toRgb(): Rgb
|
||||
{
|
||||
return new Rgb($this->red(), $this->green(), $this->blue());
|
||||
}
|
||||
|
||||
public function toRgba(?float $alpha = null): Rgba
|
||||
{
|
||||
return new Rgba($this->red(), $this->green(), $this->blue(), $alpha ?? 1);
|
||||
}
|
||||
|
||||
public function toXyz(): Xyz
|
||||
{
|
||||
return $this->toRgb()->toXyz();
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
$hue = round($this->hue);
|
||||
$saturation = round($this->saturation);
|
||||
$lightness = round($this->lightness);
|
||||
|
||||
return "hsl({$hue},{$saturation}%,{$lightness}%)";
|
||||
}
|
||||
}
|
||||
134
vendor/spatie/color/src/Hsla.php
vendored
Normal file
134
vendor/spatie/color/src/Hsla.php
vendored
Normal file
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Color;
|
||||
|
||||
class Hsla implements Color
|
||||
{
|
||||
/** @var float */
|
||||
protected $hue;
|
||||
protected $saturation;
|
||||
protected $lightness;
|
||||
protected $alpha;
|
||||
|
||||
public function __construct(float $hue, float $saturation, float $lightness, float $alpha = 1.0)
|
||||
{
|
||||
Validate::hslValue($saturation, 'saturation');
|
||||
Validate::hslValue($lightness, 'lightness');
|
||||
Validate::alphaChannelValue($alpha);
|
||||
|
||||
$this->hue = $hue;
|
||||
$this->saturation = $saturation;
|
||||
$this->lightness = $lightness;
|
||||
$this->alpha = $alpha;
|
||||
}
|
||||
|
||||
public static function fromString(string $string)
|
||||
{
|
||||
Validate::hslaColorString($string);
|
||||
|
||||
$matches = null;
|
||||
preg_match(HsPatterns::getExtractionPattern('hsla'), $string, $matches);
|
||||
|
||||
return new static(
|
||||
(float) $matches[1],
|
||||
(float) $matches[2],
|
||||
(float) $matches[3],
|
||||
(float) $matches[4]
|
||||
);
|
||||
}
|
||||
|
||||
public function hue(): float
|
||||
{
|
||||
return $this->hue;
|
||||
}
|
||||
|
||||
public function saturation(): float
|
||||
{
|
||||
return $this->saturation;
|
||||
}
|
||||
|
||||
public function lightness(): float
|
||||
{
|
||||
return $this->lightness;
|
||||
}
|
||||
|
||||
public function red(): int
|
||||
{
|
||||
return Convert::hslValueToRgb($this->hue, $this->saturation, $this->lightness)[0];
|
||||
}
|
||||
|
||||
public function green(): int
|
||||
{
|
||||
return Convert::hslValueToRgb($this->hue, $this->saturation, $this->lightness)[1];
|
||||
}
|
||||
|
||||
public function blue(): int
|
||||
{
|
||||
return Convert::hslValueToRgb($this->hue, $this->saturation, $this->lightness)[2];
|
||||
}
|
||||
|
||||
public function alpha(): float
|
||||
{
|
||||
return $this->alpha;
|
||||
}
|
||||
|
||||
public function contrast(): self
|
||||
{
|
||||
return Contrast::make($this->toHex())->toHsla($this->alpha());
|
||||
}
|
||||
|
||||
public function toCIELab(): CIELab
|
||||
{
|
||||
return $this->toRgb()->toCIELab();
|
||||
}
|
||||
|
||||
public function toCmyk(): Cmyk
|
||||
{
|
||||
return $this->toRgb()->toCmyk();
|
||||
}
|
||||
|
||||
public function toHex(?string $alpha = null): Hex
|
||||
{
|
||||
return $this->toRgb()->toHex($alpha ?? Convert::floatAlphaToHex($this->alpha));
|
||||
}
|
||||
|
||||
public function toHsb(): Hsb
|
||||
{
|
||||
return $this->toRgb()->toHsb();
|
||||
}
|
||||
|
||||
public function toHsla(?float $alpha = null): self
|
||||
{
|
||||
return new self($this->hue(), $this->saturation(), $this->lightness(), $alpha ?? $this->alpha);
|
||||
}
|
||||
|
||||
public function toHsl(): Hsl
|
||||
{
|
||||
return new Hsl($this->hue(), $this->saturation(), $this->lightness());
|
||||
}
|
||||
|
||||
public function toRgb(): Rgb
|
||||
{
|
||||
return new Rgb($this->red(), $this->green(), $this->blue());
|
||||
}
|
||||
|
||||
public function toRgba(?float $alpha = null): Rgba
|
||||
{
|
||||
return new Rgba($this->red(), $this->green(), $this->blue(), $alpha ?? $this->alpha);
|
||||
}
|
||||
|
||||
public function toXyz(): Xyz
|
||||
{
|
||||
return $this->toRgb()->toXyz();
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
$hue = round($this->hue);
|
||||
$saturation = round($this->saturation);
|
||||
$lightness = round($this->lightness);
|
||||
$alpha = round($this->alpha, 2);
|
||||
|
||||
return "hsla({$hue},{$saturation}%,{$lightness}%,{$alpha})";
|
||||
}
|
||||
}
|
||||
38
vendor/spatie/color/src/Named.php
vendored
Normal file
38
vendor/spatie/color/src/Named.php
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Color;
|
||||
|
||||
use Spatie\Color\Exceptions\InvalidColorValue;
|
||||
|
||||
class Named extends Rgb
|
||||
{
|
||||
use Names;
|
||||
|
||||
protected $name;
|
||||
|
||||
public function __construct(string $name)
|
||||
{
|
||||
|
||||
$this->name = strtolower($name);
|
||||
|
||||
if (! array_key_exists($this->name, $this->names)) {
|
||||
throw InvalidColorValue::malformedNamedColorString($name);
|
||||
}
|
||||
|
||||
$color = $this->names[$this->name];
|
||||
|
||||
parent::__construct($color[0], $color[1], $color[2]);
|
||||
}
|
||||
|
||||
public static function fromString(string $string)
|
||||
{
|
||||
Validate::namedColorString($string);
|
||||
|
||||
return new static($string);
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
}
|
||||
749
vendor/spatie/color/src/Names.php
vendored
Normal file
749
vendor/spatie/color/src/Names.php
vendored
Normal file
@@ -0,0 +1,749 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Color;
|
||||
|
||||
trait Names
|
||||
{
|
||||
protected $names = [
|
||||
'aliceblue' => [
|
||||
240,
|
||||
248,
|
||||
255,
|
||||
],
|
||||
'antiquewhite' => [
|
||||
250,
|
||||
235,
|
||||
215,
|
||||
],
|
||||
'aqua' => [
|
||||
0,
|
||||
255,
|
||||
255,
|
||||
],
|
||||
'aquamarine' => [
|
||||
127,
|
||||
255,
|
||||
212,
|
||||
],
|
||||
'azure' => [
|
||||
240,
|
||||
255,
|
||||
255,
|
||||
],
|
||||
'beige' => [
|
||||
245,
|
||||
245,
|
||||
220,
|
||||
],
|
||||
'bisque' => [
|
||||
255,
|
||||
228,
|
||||
196,
|
||||
],
|
||||
'black' => [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
],
|
||||
'blanchedalmond' => [
|
||||
255,
|
||||
235,
|
||||
205,
|
||||
],
|
||||
'blue' => [
|
||||
0,
|
||||
0,
|
||||
255,
|
||||
],
|
||||
'blueviolet' => [
|
||||
138,
|
||||
43,
|
||||
226,
|
||||
],
|
||||
'brown' => [
|
||||
165,
|
||||
42,
|
||||
42,
|
||||
],
|
||||
'burlywood' => [
|
||||
222,
|
||||
184,
|
||||
135,
|
||||
],
|
||||
'cadetblue' => [
|
||||
95,
|
||||
158,
|
||||
160,
|
||||
],
|
||||
'chartreuse' => [
|
||||
127,
|
||||
255,
|
||||
0,
|
||||
],
|
||||
'chocolate' => [
|
||||
210,
|
||||
105,
|
||||
30,
|
||||
],
|
||||
'coral' => [
|
||||
255,
|
||||
127,
|
||||
80,
|
||||
],
|
||||
'cornflowerblue' => [
|
||||
100,
|
||||
149,
|
||||
237,
|
||||
],
|
||||
'cornsilk' => [
|
||||
255,
|
||||
248,
|
||||
220,
|
||||
],
|
||||
'crimson' => [
|
||||
220,
|
||||
20,
|
||||
60,
|
||||
],
|
||||
'cyan' => [
|
||||
0,
|
||||
255,
|
||||
255,
|
||||
],
|
||||
'darkblue' => [
|
||||
0,
|
||||
0,
|
||||
139,
|
||||
],
|
||||
'darkcyan' => [
|
||||
0,
|
||||
139,
|
||||
139,
|
||||
],
|
||||
'darkgoldenrod' => [
|
||||
184,
|
||||
134,
|
||||
11,
|
||||
],
|
||||
'darkgray' => [
|
||||
169,
|
||||
169,
|
||||
169,
|
||||
],
|
||||
'darkgreen' => [
|
||||
0,
|
||||
100,
|
||||
0,
|
||||
],
|
||||
'darkgrey' => [
|
||||
169,
|
||||
169,
|
||||
169,
|
||||
],
|
||||
'darkkhaki' => [
|
||||
189,
|
||||
183,
|
||||
107,
|
||||
],
|
||||
'darkmagenta' => [
|
||||
139,
|
||||
0,
|
||||
139,
|
||||
],
|
||||
'darkolivegreen' => [
|
||||
85,
|
||||
107,
|
||||
47,
|
||||
],
|
||||
'darkorange' => [
|
||||
255,
|
||||
140,
|
||||
0,
|
||||
],
|
||||
'darkorchid' => [
|
||||
153,
|
||||
50,
|
||||
204,
|
||||
],
|
||||
'darkred' => [
|
||||
139,
|
||||
0,
|
||||
0,
|
||||
],
|
||||
'darksalmon' => [
|
||||
233,
|
||||
150,
|
||||
122,
|
||||
],
|
||||
'darkseagreen' => [
|
||||
143,
|
||||
188,
|
||||
143,
|
||||
],
|
||||
'darkslateblue' => [
|
||||
72,
|
||||
61,
|
||||
139,
|
||||
],
|
||||
'darkslategray' => [
|
||||
47,
|
||||
79,
|
||||
79,
|
||||
],
|
||||
'darkslategrey' => [
|
||||
47,
|
||||
79,
|
||||
79,
|
||||
],
|
||||
'darkturquoise' => [
|
||||
0,
|
||||
206,
|
||||
209,
|
||||
],
|
||||
'darkviolet' => [
|
||||
148,
|
||||
0,
|
||||
211,
|
||||
],
|
||||
'deeppink' => [
|
||||
255,
|
||||
20,
|
||||
147,
|
||||
],
|
||||
'deepskyblue' => [
|
||||
0,
|
||||
191,
|
||||
255,
|
||||
],
|
||||
'dimgray' => [
|
||||
105,
|
||||
105,
|
||||
105,
|
||||
],
|
||||
'dimgrey' => [
|
||||
105,
|
||||
105,
|
||||
105,
|
||||
],
|
||||
'dodgerblue' => [
|
||||
30,
|
||||
144,
|
||||
255,
|
||||
],
|
||||
'firebrick' => [
|
||||
178,
|
||||
34,
|
||||
34,
|
||||
],
|
||||
'floralwhite' => [
|
||||
255,
|
||||
250,
|
||||
240,
|
||||
],
|
||||
'forestgreen' => [
|
||||
34,
|
||||
139,
|
||||
34,
|
||||
],
|
||||
'fuchsia' => [
|
||||
255,
|
||||
0,
|
||||
255,
|
||||
],
|
||||
'gainsboro' => [
|
||||
220,
|
||||
220,
|
||||
220,
|
||||
],
|
||||
'ghostwhite' => [
|
||||
248,
|
||||
248,
|
||||
255,
|
||||
],
|
||||
'gold' => [
|
||||
255,
|
||||
215,
|
||||
0,
|
||||
],
|
||||
'goldenrod' => [
|
||||
218,
|
||||
165,
|
||||
32,
|
||||
],
|
||||
'gray' => [
|
||||
128,
|
||||
128,
|
||||
128,
|
||||
],
|
||||
'green' => [
|
||||
0,
|
||||
128,
|
||||
0,
|
||||
],
|
||||
'greenyellow' => [
|
||||
173,
|
||||
255,
|
||||
47,
|
||||
],
|
||||
'grey' => [
|
||||
128,
|
||||
128,
|
||||
128,
|
||||
],
|
||||
'honeydew' => [
|
||||
240,
|
||||
255,
|
||||
240,
|
||||
],
|
||||
'hotpink' => [
|
||||
255,
|
||||
105,
|
||||
180,
|
||||
],
|
||||
'indianred' => [
|
||||
205,
|
||||
92,
|
||||
92,
|
||||
],
|
||||
'indigo' => [
|
||||
75,
|
||||
0,
|
||||
130,
|
||||
],
|
||||
'ivory' => [
|
||||
255,
|
||||
255,
|
||||
240,
|
||||
],
|
||||
'khaki' => [
|
||||
240,
|
||||
230,
|
||||
140,
|
||||
],
|
||||
'lavender' => [
|
||||
230,
|
||||
230,
|
||||
250,
|
||||
],
|
||||
'lavenderblush' => [
|
||||
255,
|
||||
240,
|
||||
245,
|
||||
],
|
||||
'lawngreen' => [
|
||||
124,
|
||||
252,
|
||||
0,
|
||||
],
|
||||
'lemonchiffon' => [
|
||||
255,
|
||||
250,
|
||||
205,
|
||||
],
|
||||
'lightblue' => [
|
||||
173,
|
||||
216,
|
||||
230,
|
||||
],
|
||||
'lightcoral' => [
|
||||
240,
|
||||
128,
|
||||
128,
|
||||
],
|
||||
'lightcyan' => [
|
||||
224,
|
||||
255,
|
||||
255,
|
||||
],
|
||||
'lightgoldenrodyellow' => [
|
||||
250,
|
||||
250,
|
||||
210,
|
||||
],
|
||||
'lightgray' => [
|
||||
211,
|
||||
211,
|
||||
211,
|
||||
],
|
||||
'lightgreen' => [
|
||||
144,
|
||||
238,
|
||||
144,
|
||||
],
|
||||
'lightgrey' => [
|
||||
211,
|
||||
211,
|
||||
211,
|
||||
],
|
||||
'lightpink' => [
|
||||
255,
|
||||
182,
|
||||
193,
|
||||
],
|
||||
'lightsalmon' => [
|
||||
255,
|
||||
160,
|
||||
122,
|
||||
],
|
||||
'lightseagreen' => [
|
||||
32,
|
||||
178,
|
||||
170,
|
||||
],
|
||||
'lightskyblue' => [
|
||||
135,
|
||||
206,
|
||||
250,
|
||||
],
|
||||
'lightslategray' => [
|
||||
119,
|
||||
136,
|
||||
153,
|
||||
],
|
||||
'lightslategrey' => [
|
||||
119,
|
||||
136,
|
||||
153,
|
||||
],
|
||||
'lightsteelblue' => [
|
||||
176,
|
||||
196,
|
||||
222,
|
||||
],
|
||||
'lightyellow' => [
|
||||
255,
|
||||
255,
|
||||
224,
|
||||
],
|
||||
'lime' => [
|
||||
0,
|
||||
255,
|
||||
0,
|
||||
],
|
||||
'limegreen' => [
|
||||
50,
|
||||
205,
|
||||
50,
|
||||
],
|
||||
'linen' => [
|
||||
250,
|
||||
240,
|
||||
230,
|
||||
],
|
||||
'magenta' => [
|
||||
255,
|
||||
0,
|
||||
255,
|
||||
],
|
||||
'maroon' => [
|
||||
128,
|
||||
0,
|
||||
0,
|
||||
],
|
||||
'mediumaquamarine' => [
|
||||
102,
|
||||
205,
|
||||
170,
|
||||
],
|
||||
'mediumblue' => [
|
||||
0,
|
||||
0,
|
||||
205,
|
||||
],
|
||||
'mediumorchid' => [
|
||||
186,
|
||||
85,
|
||||
211,
|
||||
],
|
||||
'mediumpurple' => [
|
||||
147,
|
||||
112,
|
||||
219,
|
||||
],
|
||||
'mediumseagreen' => [
|
||||
60,
|
||||
179,
|
||||
113,
|
||||
],
|
||||
'mediumslateblue' => [
|
||||
123,
|
||||
104,
|
||||
238,
|
||||
],
|
||||
'mediumspringgreen' => [
|
||||
0,
|
||||
250,
|
||||
154,
|
||||
],
|
||||
'mediumturquoise' => [
|
||||
72,
|
||||
209,
|
||||
204,
|
||||
],
|
||||
'mediumvioletred' => [
|
||||
199,
|
||||
21,
|
||||
133,
|
||||
],
|
||||
'midnightblue' => [
|
||||
25,
|
||||
25,
|
||||
112,
|
||||
],
|
||||
'mintcream' => [
|
||||
245,
|
||||
255,
|
||||
250,
|
||||
],
|
||||
'mistyrose' => [
|
||||
255,
|
||||
228,
|
||||
225,
|
||||
],
|
||||
'moccasin' => [
|
||||
255,
|
||||
228,
|
||||
181,
|
||||
],
|
||||
'navajowhite' => [
|
||||
255,
|
||||
222,
|
||||
173,
|
||||
],
|
||||
'navy' => [
|
||||
0,
|
||||
0,
|
||||
128,
|
||||
],
|
||||
'oldlace' => [
|
||||
253,
|
||||
245,
|
||||
230,
|
||||
],
|
||||
'olive' => [
|
||||
128,
|
||||
128,
|
||||
0,
|
||||
],
|
||||
'olivedrab' => [
|
||||
107,
|
||||
142,
|
||||
35,
|
||||
],
|
||||
'orange' => [
|
||||
255,
|
||||
165,
|
||||
0,
|
||||
],
|
||||
'orangered' => [
|
||||
255,
|
||||
69,
|
||||
0,
|
||||
],
|
||||
'orchid' => [
|
||||
218,
|
||||
112,
|
||||
214,
|
||||
],
|
||||
'palegoldenrod' => [
|
||||
238,
|
||||
232,
|
||||
170,
|
||||
],
|
||||
'palegreen' => [
|
||||
152,
|
||||
251,
|
||||
152,
|
||||
],
|
||||
'paleturquoise' => [
|
||||
175,
|
||||
238,
|
||||
238,
|
||||
],
|
||||
'palevioletred' => [
|
||||
219,
|
||||
112,
|
||||
147,
|
||||
],
|
||||
'papayawhip' => [
|
||||
255,
|
||||
239,
|
||||
213,
|
||||
],
|
||||
'peachpuff' => [
|
||||
255,
|
||||
218,
|
||||
185,
|
||||
],
|
||||
'peru' => [
|
||||
205,
|
||||
133,
|
||||
63,
|
||||
],
|
||||
'pink' => [
|
||||
255,
|
||||
192,
|
||||
203,
|
||||
],
|
||||
'plum' => [
|
||||
221,
|
||||
160,
|
||||
221,
|
||||
],
|
||||
'powderblue' => [
|
||||
176,
|
||||
224,
|
||||
230,
|
||||
],
|
||||
'purple' => [
|
||||
128,
|
||||
0,
|
||||
128,
|
||||
],
|
||||
'rebeccapurple' => [
|
||||
102,
|
||||
51,
|
||||
153,
|
||||
],
|
||||
'red' => [
|
||||
255,
|
||||
0,
|
||||
0,
|
||||
],
|
||||
'rosybrown' => [
|
||||
188,
|
||||
143,
|
||||
143,
|
||||
],
|
||||
'royalblue' => [
|
||||
65,
|
||||
105,
|
||||
225,
|
||||
],
|
||||
'saddlebrown' => [
|
||||
139,
|
||||
69,
|
||||
19,
|
||||
],
|
||||
'salmon' => [
|
||||
250,
|
||||
128,
|
||||
114,
|
||||
],
|
||||
'sandybrown' => [
|
||||
244,
|
||||
164,
|
||||
96,
|
||||
],
|
||||
'seagreen' => [
|
||||
46,
|
||||
139,
|
||||
87,
|
||||
],
|
||||
'seashell' => [
|
||||
255,
|
||||
245,
|
||||
238,
|
||||
],
|
||||
'sienna' => [
|
||||
160,
|
||||
82,
|
||||
45,
|
||||
],
|
||||
'silver' => [
|
||||
192,
|
||||
192,
|
||||
192,
|
||||
],
|
||||
'skyblue' => [
|
||||
135,
|
||||
206,
|
||||
235,
|
||||
],
|
||||
'slateblue' => [
|
||||
106,
|
||||
90,
|
||||
205,
|
||||
],
|
||||
'slategray' => [
|
||||
112,
|
||||
128,
|
||||
144,
|
||||
],
|
||||
'slategrey' => [
|
||||
112,
|
||||
128,
|
||||
144,
|
||||
],
|
||||
'snow' => [
|
||||
255,
|
||||
250,
|
||||
250,
|
||||
],
|
||||
'springgreen' => [
|
||||
0,
|
||||
255,
|
||||
127,
|
||||
],
|
||||
'steelblue' => [
|
||||
70,
|
||||
130,
|
||||
180,
|
||||
],
|
||||
'tan' => [
|
||||
210,
|
||||
180,
|
||||
140,
|
||||
],
|
||||
'teal' => [
|
||||
0,
|
||||
128,
|
||||
128,
|
||||
],
|
||||
'thistle' => [
|
||||
216,
|
||||
191,
|
||||
216,
|
||||
],
|
||||
'tomato' => [
|
||||
255,
|
||||
99,
|
||||
71,
|
||||
],
|
||||
'turquoise' => [
|
||||
64,
|
||||
224,
|
||||
208,
|
||||
],
|
||||
'violet' => [
|
||||
238,
|
||||
130,
|
||||
238,
|
||||
],
|
||||
'wheat' => [
|
||||
245,
|
||||
222,
|
||||
179,
|
||||
],
|
||||
'white' => [
|
||||
255,
|
||||
255,
|
||||
255,
|
||||
],
|
||||
'whitesmoke' => [
|
||||
245,
|
||||
245,
|
||||
245,
|
||||
],
|
||||
'yellow' => [
|
||||
255,
|
||||
255,
|
||||
0,
|
||||
],
|
||||
'yellowgreen' => [
|
||||
154,
|
||||
205,
|
||||
50,
|
||||
],
|
||||
];
|
||||
}
|
||||
127
vendor/spatie/color/src/Rgb.php
vendored
Normal file
127
vendor/spatie/color/src/Rgb.php
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Color;
|
||||
|
||||
class Rgb implements Color
|
||||
{
|
||||
/** @var int */
|
||||
protected $red;
|
||||
protected $green;
|
||||
protected $blue;
|
||||
|
||||
public function __construct(int $red, int $green, int $blue)
|
||||
{
|
||||
Validate::rgbChannelValue($red, 'red');
|
||||
Validate::rgbChannelValue($green, 'green');
|
||||
Validate::rgbChannelValue($blue, 'blue');
|
||||
|
||||
$this->red = $red;
|
||||
$this->green = $green;
|
||||
$this->blue = $blue;
|
||||
}
|
||||
|
||||
public static function fromString(string $string)
|
||||
{
|
||||
Validate::rgbColorString($string);
|
||||
|
||||
$matches = null;
|
||||
preg_match('/rgb\( *(\d{1,3} *, *\d{1,3} *, *\d{1,3}) *\)/i', $string, $matches);
|
||||
|
||||
$channels = explode(',', $matches[1]);
|
||||
[$red, $green, $blue] = array_map('trim', $channels);
|
||||
|
||||
return new static($red, $green, $blue);
|
||||
}
|
||||
|
||||
public function red(): int
|
||||
{
|
||||
return $this->red;
|
||||
}
|
||||
|
||||
public function green(): int
|
||||
{
|
||||
return $this->green;
|
||||
}
|
||||
|
||||
public function blue(): int
|
||||
{
|
||||
return $this->blue;
|
||||
}
|
||||
|
||||
public function toCIELab(): CIELab
|
||||
{
|
||||
return $this->toXyz()->toCIELab();
|
||||
}
|
||||
|
||||
public function toCmyk(): Cmyk
|
||||
{
|
||||
list($cyan, $magenta, $yellow, $key) = Convert::rgbValueToCmyk($this->red, $this->green, $this->blue);
|
||||
|
||||
return new Cmyk($cyan, $magenta, $yellow, $key);
|
||||
}
|
||||
|
||||
public function toHex(?string $alpha = null): Hex
|
||||
{
|
||||
return new Hex(
|
||||
Convert::rgbChannelToHexChannel($this->red),
|
||||
Convert::rgbChannelToHexChannel($this->green),
|
||||
Convert::rgbChannelToHexChannel($this->blue),
|
||||
$alpha ?? 'ff'
|
||||
);
|
||||
}
|
||||
|
||||
public function toHsb(): Hsb
|
||||
{
|
||||
list($hue, $saturation, $brightness) = Convert::rgbValueToHsb($this->red, $this->green, $this->blue);
|
||||
|
||||
return new Hsb($hue, $saturation, $brightness);
|
||||
}
|
||||
|
||||
public function toHsl(): Hsl
|
||||
{
|
||||
[$hue, $saturation, $lightness] = Convert::rgbValueToHsl(
|
||||
$this->red,
|
||||
$this->green,
|
||||
$this->blue
|
||||
);
|
||||
|
||||
return new Hsl($hue, $saturation, $lightness);
|
||||
}
|
||||
|
||||
public function toHsla(?float $alpha = null): Hsla
|
||||
{
|
||||
[$hue, $saturation, $lightness] = Convert::rgbValueToHsl(
|
||||
$this->red,
|
||||
$this->green,
|
||||
$this->blue
|
||||
);
|
||||
|
||||
return new Hsla($hue, $saturation, $lightness, $alpha ?? 1);
|
||||
}
|
||||
|
||||
public function toRgb(): self
|
||||
{
|
||||
return new self($this->red, $this->green, $this->blue);
|
||||
}
|
||||
|
||||
public function toRgba(?float $alpha = null): Rgba
|
||||
{
|
||||
return new Rgba($this->red, $this->green, $this->blue, $alpha ?? 1);
|
||||
}
|
||||
|
||||
public function toXyz(): Xyz
|
||||
{
|
||||
[$x, $y, $z] = Convert::rgbValueToXyz(
|
||||
$this->red,
|
||||
$this->green,
|
||||
$this->blue
|
||||
);
|
||||
|
||||
return new Xyz($x, $y, $z);
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
return "rgb({$this->red},{$this->green},{$this->blue})";
|
||||
}
|
||||
}
|
||||
118
vendor/spatie/color/src/Rgba.php
vendored
Normal file
118
vendor/spatie/color/src/Rgba.php
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Color;
|
||||
|
||||
class Rgba implements Color
|
||||
{
|
||||
/** @var int */
|
||||
protected $red;
|
||||
protected $green;
|
||||
protected $blue;
|
||||
|
||||
/** @var float */
|
||||
protected $alpha;
|
||||
|
||||
public function __construct(int $red, int $green, int $blue, float $alpha)
|
||||
{
|
||||
Validate::rgbChannelValue($red, 'red');
|
||||
Validate::rgbChannelValue($green, 'green');
|
||||
Validate::rgbChannelValue($blue, 'blue');
|
||||
Validate::alphaChannelValue($alpha);
|
||||
|
||||
$this->red = $red;
|
||||
$this->green = $green;
|
||||
$this->blue = $blue;
|
||||
$this->alpha = $alpha;
|
||||
}
|
||||
|
||||
public static function fromString(string $string)
|
||||
{
|
||||
Validate::rgbaColorString($string);
|
||||
|
||||
$matches = null;
|
||||
preg_match('/rgba\( *(\d{1,3} *, *\d{1,3} *, *\d{1,3} *, *[0-1]*(\.\d{1,})?) *\)/i', $string, $matches);
|
||||
|
||||
$channels = explode(',', $matches[1]);
|
||||
[$red, $green, $blue, $alpha] = array_map('trim', $channels);
|
||||
|
||||
return new static($red, $green, $blue, $alpha);
|
||||
}
|
||||
|
||||
public function red(): int
|
||||
{
|
||||
return $this->red;
|
||||
}
|
||||
|
||||
public function green(): int
|
||||
{
|
||||
return $this->green;
|
||||
}
|
||||
|
||||
public function blue(): int
|
||||
{
|
||||
return $this->blue;
|
||||
}
|
||||
|
||||
public function alpha(): float
|
||||
{
|
||||
return $this->alpha;
|
||||
}
|
||||
|
||||
public function toCIELab(): CIELab
|
||||
{
|
||||
return $this->toRgb()->toCIELab();
|
||||
}
|
||||
|
||||
public function toCmyk(): Cmyk
|
||||
{
|
||||
return $this->toRgb()->toCmyk();
|
||||
}
|
||||
|
||||
public function toHex(?string $alpha = null): Hex
|
||||
{
|
||||
return $this->toRgb()->toHex($alpha ?? Convert::floatAlphaToHex($this->alpha));
|
||||
}
|
||||
|
||||
public function toHsb(): Hsb
|
||||
{
|
||||
return $this->toRgb()->toHsb();
|
||||
}
|
||||
|
||||
public function toHsl(): Hsl
|
||||
{
|
||||
[$hue, $saturation, $lightness] = Convert::rgbValueToHsl(
|
||||
$this->red,
|
||||
$this->green,
|
||||
$this->blue
|
||||
);
|
||||
|
||||
return new Hsl($hue, $saturation, $lightness);
|
||||
}
|
||||
|
||||
public function toHsla(?float $alpha = null): Hsla
|
||||
{
|
||||
return $this->toRgb()->toHsla($alpha ?? $this->alpha);
|
||||
}
|
||||
|
||||
public function toRgb(): Rgb
|
||||
{
|
||||
return new Rgb($this->red, $this->green, $this->blue);
|
||||
}
|
||||
|
||||
public function toRgba(?float $alpha = null): self
|
||||
{
|
||||
return new self($this->red, $this->green, $this->blue, $alpha ?? $this->alpha);
|
||||
}
|
||||
|
||||
public function toXyz(): Xyz
|
||||
{
|
||||
return $this->toRgb()->toXyz();
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
$alpha = number_format($this->alpha, 2);
|
||||
|
||||
return "rgba({$this->red},{$this->green},{$this->blue},{$alpha})";
|
||||
}
|
||||
}
|
||||
162
vendor/spatie/color/src/Validate.php
vendored
Normal file
162
vendor/spatie/color/src/Validate.php
vendored
Normal file
@@ -0,0 +1,162 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Color;
|
||||
|
||||
use Spatie\Color\Exceptions\InvalidColorValue;
|
||||
|
||||
class Validate
|
||||
{
|
||||
public static function CIELabValue(float $value, string $name): void
|
||||
{
|
||||
if ($name === 'l' && ($value < 0 || $value > 100)) {
|
||||
throw InvalidColorValue::CIELabValueNotInRange($value, $name, 0, 100);
|
||||
}
|
||||
|
||||
if (($name === 'a' || $name === 'b') && ($value < -110 || $value > 110)) {
|
||||
throw InvalidColorValue::CIELabValueNotInRange($value, $name, -110, 110);
|
||||
}
|
||||
}
|
||||
|
||||
public static function CIELabColorString($string): void
|
||||
{
|
||||
if (! preg_match('/^ *CIELab\( *\d{1,3}\.?\d* *, *-?\d{1,3}\.?\d* *, *-?\d{1,3}\.?\d* *\) *$/i', $string)) {
|
||||
throw InvalidColorValue::malformedCIELabColorString($string);
|
||||
}
|
||||
}
|
||||
|
||||
public static function cmykValue(float $value, string $name): void
|
||||
{
|
||||
if ($value < 0 || $value > 1) {
|
||||
throw InvalidColorValue::cmykValueNotInRange($value, $name);
|
||||
}
|
||||
}
|
||||
|
||||
public static function rgbChannelValue(int $value, string $channel): void
|
||||
{
|
||||
if ($value < 0 || $value > 255) {
|
||||
throw InvalidColorValue::rgbChannelValueNotInRange($value, $channel);
|
||||
}
|
||||
}
|
||||
|
||||
public static function alphaChannelValue(float $value): void
|
||||
{
|
||||
if ($value < 0 || $value > 1) {
|
||||
throw InvalidColorValue::alphaChannelValueNotInRange($value);
|
||||
}
|
||||
}
|
||||
|
||||
public static function hexChannelValue(string $value): void
|
||||
{
|
||||
if (strlen($value) !== 2) {
|
||||
throw InvalidColorValue::hexChannelValueHasInvalidLength($value);
|
||||
}
|
||||
|
||||
if (! preg_match('/[a-f0-9]{2}/i', $value)) {
|
||||
throw InvalidColorValue::hexValueContainsInvalidCharacters($value);
|
||||
}
|
||||
}
|
||||
|
||||
public static function hsbValue(float $value, string $name): void
|
||||
{
|
||||
switch ($name) {
|
||||
case 'hue':
|
||||
if ($value < 0 || $value > 360) {
|
||||
throw InvalidColorValue::hsbValueNotInRange($value, $name);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
if ($value < 0 || $value > 100) {
|
||||
throw InvalidColorValue::hsbValueNotInRange($value, $name);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static function hslValue(float $value, string $name): void
|
||||
{
|
||||
if ($value < 0 || $value > 100) {
|
||||
throw InvalidColorValue::hslValueNotInRange($value, $name);
|
||||
}
|
||||
}
|
||||
|
||||
public static function cmykColorString($string): void
|
||||
{
|
||||
if (! preg_match('/^ *cmyk\( *(\d{1,3})%? *, *(\d{1,3})%? *, *(\d{1,3})%? *, *(\d{1,3})%? *\) *$/i', $string)) {
|
||||
throw InvalidColorValue::malformedCmykColorString($string);
|
||||
}
|
||||
}
|
||||
|
||||
public static function rgbColorString($string): void
|
||||
{
|
||||
if (! preg_match('/^ *rgb\( *\d{1,3} *, *\d{1,3} *, *\d{1,3} *\) *$/i', $string)) {
|
||||
throw InvalidColorValue::malformedRgbColorString($string);
|
||||
}
|
||||
}
|
||||
|
||||
public static function rgbaColorString($string): void
|
||||
{
|
||||
if (! preg_match('/^ *rgba\( *\d{1,3} *, *\d{1,3} *, *\d{1,3} *, *[0-1]*(\.\d{1,})? *\) *$/i', $string)) {
|
||||
throw InvalidColorValue::malformedRgbaColorString($string);
|
||||
}
|
||||
}
|
||||
|
||||
public static function hexColorString($string): void
|
||||
{
|
||||
if (! preg_match('/^#(?:[a-f0-9]{3}|[a-f0-9]{4}|[a-f0-9]{6}|[a-f0-9]{8})$/i', $string)) {
|
||||
throw InvalidColorValue::malformedHexColorString($string);
|
||||
}
|
||||
}
|
||||
|
||||
public static function hsbColorString($string): void
|
||||
{
|
||||
if (! preg_match(HsPatterns::getValidationPattern('hsb'), $string)) {
|
||||
throw InvalidColorValue::malformedHslColorString($string);
|
||||
}
|
||||
}
|
||||
|
||||
public static function hslColorString($string): void
|
||||
{
|
||||
if (! preg_match(HsPatterns::getValidationPattern('hsl'), $string)) {
|
||||
throw InvalidColorValue::malformedHslColorString($string);
|
||||
}
|
||||
}
|
||||
|
||||
public static function hslaColorString($string): void
|
||||
{
|
||||
if (! preg_match(HsPatterns::getValidationPattern('hsla'), $string)) {
|
||||
throw InvalidColorValue::malformedHslaColorString($string);
|
||||
}
|
||||
}
|
||||
|
||||
public static function xyzValue(float $value, string $name): void
|
||||
{
|
||||
if ($name === 'x' && ($value < 0 || $value > 95.047)) {
|
||||
throw InvalidColorValue::xyzValueNotInRange($value, $name, 0, 95.047);
|
||||
}
|
||||
|
||||
if ($name === 'y' && ($value < 0 || $value > 100)) {
|
||||
throw InvalidColorValue::xyzValueNotInRange($value, $name, 0, 100);
|
||||
}
|
||||
|
||||
if ($name === 'z' && ($value < 0 || $value > 108.883)) {
|
||||
throw InvalidColorValue::xyzValueNotInRange($value, $name, 0, 108.883);
|
||||
}
|
||||
}
|
||||
|
||||
public static function xyzColorString($string): void
|
||||
{
|
||||
if (! preg_match('/^ *xyz\( *\d{1,2}\.?\d+? *, *\d{1,3}\.?\d+? *, *\d{1,3}\.?\d+? *\) *$/i', $string)) {
|
||||
throw InvalidColorValue::malformedXyzColorString($string);
|
||||
}
|
||||
}
|
||||
|
||||
public static function namedColorString($string): void
|
||||
{
|
||||
if (! preg_match('/^[a-z]+$/i', $string)) {
|
||||
throw InvalidColorValue::malformedNamedColorString($string);
|
||||
}
|
||||
}
|
||||
}
|
||||
133
vendor/spatie/color/src/Xyz.php
vendored
Normal file
133
vendor/spatie/color/src/Xyz.php
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Color;
|
||||
|
||||
class Xyz implements Color
|
||||
{
|
||||
/** @var float */
|
||||
protected $x;
|
||||
protected $y;
|
||||
protected $z;
|
||||
|
||||
public function __construct(float $x, float $y, float $z)
|
||||
{
|
||||
Validate::xyzValue($x, 'x');
|
||||
Validate::xyzValue($y, 'y');
|
||||
Validate::xyzValue($z, 'z');
|
||||
|
||||
$this->x = $x;
|
||||
$this->y = $y;
|
||||
$this->z = $z;
|
||||
}
|
||||
|
||||
public static function fromString(string $string)
|
||||
{
|
||||
Validate::xyzColorString($string);
|
||||
|
||||
$matches = null;
|
||||
preg_match('/xyz\( *(\d{1,2}\.?\d+? *, *\d{1,3}\.?\d+? *, *\d{1,3}\.?\d+?) *\)/i', $string, $matches);
|
||||
|
||||
$channels = explode(',', $matches[1]);
|
||||
[$x, $y, $z] = array_map('trim', $channels);
|
||||
|
||||
return new static($x, $y, $z);
|
||||
}
|
||||
|
||||
public function x(): float
|
||||
{
|
||||
return $this->x;
|
||||
}
|
||||
|
||||
public function y(): float
|
||||
{
|
||||
return $this->y;
|
||||
}
|
||||
|
||||
public function z(): float
|
||||
{
|
||||
return $this->z;
|
||||
}
|
||||
|
||||
public function red(): int
|
||||
{
|
||||
$rgb = $this->toRgb();
|
||||
|
||||
return $rgb->red();
|
||||
}
|
||||
|
||||
public function blue(): int
|
||||
{
|
||||
$rgb = $this->toRgb();
|
||||
|
||||
return $rgb->blue();
|
||||
}
|
||||
|
||||
public function green(): int
|
||||
{
|
||||
$rgb = $this->toRgb();
|
||||
|
||||
return $rgb->green();
|
||||
}
|
||||
|
||||
public function toCIELab(): CIELab
|
||||
{
|
||||
[$l, $a, $b] = Convert::xyzValueToCIELab(
|
||||
$this->x,
|
||||
$this->y,
|
||||
$this->z
|
||||
);
|
||||
|
||||
return new CIELab($l, $a, $b);
|
||||
}
|
||||
|
||||
public function toCmyk(): Cmyk
|
||||
{
|
||||
return $this->toRgb()->toCmyk();
|
||||
}
|
||||
|
||||
public function toHex(?string $alpha = null): Hex
|
||||
{
|
||||
return $this->toRgb()->toHex($alpha ?? 'ff');
|
||||
}
|
||||
|
||||
public function toHsb(): Hsb
|
||||
{
|
||||
return $this->toRgb()->toHsb();
|
||||
}
|
||||
|
||||
public function toHsl(): Hsl
|
||||
{
|
||||
return $this->toRgb()->toHSL();
|
||||
}
|
||||
|
||||
public function toHsla(?float $alpha = null): Hsla
|
||||
{
|
||||
return $this->toRgb()->toHsla($alpha ?? 1);
|
||||
}
|
||||
|
||||
public function toRgb(): Rgb
|
||||
{
|
||||
[$red, $green, $blue] = Convert::xyzValueToRgb(
|
||||
$this->x,
|
||||
$this->y,
|
||||
$this->z
|
||||
);
|
||||
|
||||
return new Rgb($red, $green, $blue);
|
||||
}
|
||||
|
||||
public function toRgba(?float $alpha = null): Rgba
|
||||
{
|
||||
return $this->toRgb()->toRgba($alpha ?? 1);
|
||||
}
|
||||
|
||||
public function toXyz(): self
|
||||
{
|
||||
return new self($this->x, $this->y, $this->z);
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
return "xyz({$this->x},{$this->y},{$this->z})";
|
||||
}
|
||||
}
|
||||
35
vendor/spatie/error-solutions/.php_cs.php
vendored
Normal file
35
vendor/spatie/error-solutions/.php_cs.php
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
$finder = Symfony\Component\Finder\Finder::create()
|
||||
->in([
|
||||
__DIR__ . '/src',
|
||||
__DIR__ . '/tests',
|
||||
])
|
||||
->name('*.php')
|
||||
->notName('*.blade.php')
|
||||
->ignoreDotFiles(true)
|
||||
->ignoreVCS(true);
|
||||
|
||||
return (new PhpCsFixer\Config())
|
||||
->setRules([
|
||||
'@PSR2' => true,
|
||||
'array_syntax' => ['syntax' => 'short'],
|
||||
'ordered_imports' => ['sort_algorithm' => 'alpha'],
|
||||
'no_unused_imports' => true,
|
||||
'not_operator_with_successor_space' => true,
|
||||
'trailing_comma_in_multiline' => true,
|
||||
'phpdoc_scalar' => true,
|
||||
'unary_operator_spaces' => true,
|
||||
'binary_operator_spaces' => true,
|
||||
'blank_line_before_statement' => [
|
||||
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'],
|
||||
],
|
||||
'phpdoc_single_line_var_spacing' => true,
|
||||
'phpdoc_var_without_name' => true,
|
||||
'method_argument_space' => [
|
||||
'on_multiline' => 'ensure_fully_multiline',
|
||||
'keep_multiple_spaces_after_comma' => true,
|
||||
],
|
||||
'single_trait_insert_per_statement' => true,
|
||||
])
|
||||
->setFinder($finder);
|
||||
90
vendor/spatie/error-solutions/CHANGELOG.md
vendored
Normal file
90
vendor/spatie/error-solutions/CHANGELOG.md
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to `error-solutions` will be documented in this file.
|
||||
|
||||
## 1.1.2 - 2024-12-11
|
||||
|
||||
### What's Changed
|
||||
|
||||
* Documentation link should follow the latest major version by @mshukurlu in https://github.com/spatie/error-solutions/pull/17
|
||||
* Replace implicitly nullable parameters for PHP 8.4 by @txdFabio in https://github.com/spatie/error-solutions/pull/22
|
||||
|
||||
### New Contributors
|
||||
|
||||
* @mshukurlu made their first contribution in https://github.com/spatie/error-solutions/pull/17
|
||||
* @txdFabio made their first contribution in https://github.com/spatie/error-solutions/pull/22
|
||||
|
||||
**Full Changelog**: https://github.com/spatie/error-solutions/compare/1.1.1...1.1.2
|
||||
|
||||
## 1.1.1 - 2024-07-25
|
||||
|
||||
### What's Changed
|
||||
|
||||
* Fix OpenAI response text links by @Lukaaashek in https://github.com/spatie/error-solutions/pull/9
|
||||
|
||||
### New Contributors
|
||||
|
||||
* @Lukaaashek made their first contribution in https://github.com/spatie/error-solutions/pull/9
|
||||
|
||||
**Full Changelog**: https://github.com/spatie/error-solutions/compare/1.1.0...1.1.1
|
||||
|
||||
## 1.1.0 - 2024-07-22
|
||||
|
||||
### What's Changed
|
||||
|
||||
* Allow to customize OpenAI Model by @arnebr in https://github.com/spatie/error-solutions/pull/7
|
||||
|
||||
### New Contributors
|
||||
|
||||
* @arnebr made their first contribution in https://github.com/spatie/error-solutions/pull/7
|
||||
|
||||
**Full Changelog**: https://github.com/spatie/error-solutions/compare/1.0.5...1.1.0
|
||||
|
||||
## 1.0.5 - 2024-07-09
|
||||
|
||||
### What's Changed
|
||||
|
||||
* Legacy `RunnableSolution` should continue to extend legacy `Solution` by @duncanmcclean in https://github.com/spatie/error-solutions/pull/6
|
||||
|
||||
### New Contributors
|
||||
|
||||
* @duncanmcclean made their first contribution in https://github.com/spatie/error-solutions/pull/6
|
||||
|
||||
**Full Changelog**: https://github.com/spatie/error-solutions/compare/1.0.4...1.0.5
|
||||
|
||||
## 1.0.4 - 2024-06-28
|
||||
|
||||
**Full Changelog**: https://github.com/spatie/error-solutions/compare/1.0.3...1.0.4
|
||||
|
||||
## 1.0.3 - 2024-06-27
|
||||
|
||||
**Full Changelog**: https://github.com/spatie/error-solutions/compare/1.0.2...1.0.3
|
||||
|
||||
## 1.0.2 - 2024-06-26
|
||||
|
||||
### What's Changed
|
||||
|
||||
* Fix AI solutions
|
||||
* Bump dependabot/fetch-metadata from 1.6.0 to 2.1.0 by @dependabot in https://github.com/spatie/error-solutions/pull/1
|
||||
|
||||
### New Contributors
|
||||
|
||||
* @dependabot made their first contribution in https://github.com/spatie/error-solutions/pull/1
|
||||
|
||||
**Full Changelog**: https://github.com/spatie/error-solutions/compare/0.0.1...1.0.2
|
||||
|
||||
## 1.0.1 - 2024-06-21
|
||||
|
||||
- Add the legacy string comperator
|
||||
|
||||
**Full Changelog**: https://github.com/spatie/error-solutions/compare/1.0.0...1.0.1
|
||||
|
||||
## 1.0.0 - 2024-06-12
|
||||
|
||||
- Initial release
|
||||
|
||||
**Full Changelog**: https://github.com/spatie/error-solutions/compare/0.0.1...1.0.0
|
||||
|
||||
## 0.0.1 - 2024-06-11
|
||||
|
||||
**Full Changelog**: https://github.com/spatie/error-solutions/commits/0.0.1
|
||||
21
vendor/spatie/error-solutions/LICENSE.md
vendored
Normal file
21
vendor/spatie/error-solutions/LICENSE.md
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Spatie <ruben@spatie.be>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
57
vendor/spatie/error-solutions/README.md
vendored
Normal file
57
vendor/spatie/error-solutions/README.md
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
# Error solutions
|
||||
|
||||
[](https://packagist.org/packages/spatie/error-solutions)
|
||||
[](https://github.com/spatie/error-solutions/actions/workflows/run-tests.yml)
|
||||
[](https://packagist.org/packages/spatie/error-solutions)
|
||||
|
||||
At Spatie we develop multiple packages handling errors and providing solutions for these errors. This package is a collection of all these solutions.
|
||||
|
||||
## Support us
|
||||
|
||||
[<img src="https://github-ads.s3.eu-central-1.amazonaws.com/error-solutions.jpg?t=1" width="419px" />](https://spatie.be/github-ad-click/error-solutions)
|
||||
|
||||
We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).
|
||||
|
||||
We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).
|
||||
|
||||
## Installation
|
||||
|
||||
You can install the package via composer:
|
||||
|
||||
```bash
|
||||
composer require spatie/error-solutions
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
We've got some excellent documentation on how to use solutions:
|
||||
|
||||
- [Flare](https://flareapp.io/docs/ignition/solutions/implementing-solutions)
|
||||
- [Ignition](https://github.com/spatie/ignition/?tab=readme-ov-file#displaying-solutions)
|
||||
|
||||
## Testing
|
||||
|
||||
```bash
|
||||
composer test
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
|
||||
|
||||
## Contributing
|
||||
|
||||
Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.
|
||||
|
||||
## Security Vulnerabilities
|
||||
|
||||
Please review [our security policy](../../security/policy) on how to report security vulnerabilities.
|
||||
|
||||
## Credits
|
||||
|
||||
- [Ruben Van Assche](https://github.com/rubenvanassche)
|
||||
- [All Contributors](../../contributors)
|
||||
|
||||
## License
|
||||
|
||||
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
|
||||
69
vendor/spatie/error-solutions/composer.json
vendored
Normal file
69
vendor/spatie/error-solutions/composer.json
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
{
|
||||
"name" : "spatie/error-solutions",
|
||||
"description" : "This is my package error-solutions",
|
||||
"keywords" : [
|
||||
"Spatie",
|
||||
"error-solutions"
|
||||
],
|
||||
"homepage" : "https://github.com/spatie/error-solutions",
|
||||
"license" : "MIT",
|
||||
"authors" : [
|
||||
{
|
||||
"name" : "Ruben Van Assche",
|
||||
"email" : "ruben@spatie.be",
|
||||
"role" : "Developer"
|
||||
}
|
||||
],
|
||||
"require" : {
|
||||
"php": "^8.0"
|
||||
},
|
||||
"require-dev" : {
|
||||
"livewire/livewire": "^2.11|^3.5.20",
|
||||
"illuminate/support": "^10.0|^11.0|^12.0",
|
||||
"illuminate/broadcasting" : "^10.0|^11.0|^12.0",
|
||||
"openai-php/client": "^0.10.1",
|
||||
"illuminate/cache" : "^10.0|^11.0|^12.0",
|
||||
"pestphp/pest" : "^2.20|^3.0",
|
||||
"phpstan/phpstan" : "^2.1",
|
||||
"psr/simple-cache-implementation" : "^3.0",
|
||||
"psr/simple-cache" : "^3.0",
|
||||
"spatie/ray" : "^1.28",
|
||||
"symfony/cache" : "^5.4|^6.0|^7.0",
|
||||
"symfony/process" : "^5.4|^6.0|^7.0",
|
||||
"vlucas/phpdotenv" : "^5.5",
|
||||
"orchestra/testbench": "8.22.3|^9.0|^10.0"
|
||||
},
|
||||
"autoload" : {
|
||||
"psr-4" : {
|
||||
"Spatie\\ErrorSolutions\\" : "src",
|
||||
"Spatie\\Ignition\\" : "legacy/ignition",
|
||||
"Spatie\\LaravelIgnition\\" : "legacy/laravel-ignition"
|
||||
}
|
||||
},
|
||||
"autoload-dev" : {
|
||||
"psr-4" : {
|
||||
"Spatie\\ErrorSolutions\\Tests\\" : "tests"
|
||||
}
|
||||
},
|
||||
"suggest" : {
|
||||
"openai-php/client" : "Require get solutions from OpenAI",
|
||||
"simple-cache-implementation" : "To cache solutions from OpenAI"
|
||||
},
|
||||
"scripts" : {
|
||||
"analyse" : "vendor/bin/phpstan analyse",
|
||||
"baseline" : "vendor/bin/phpstan analyse --generate-baseline",
|
||||
"test" : "vendor/bin/pest",
|
||||
"test-coverage" : "vendor/bin/pest --coverage",
|
||||
"format" : "vendor/bin/pint"
|
||||
},
|
||||
"config" : {
|
||||
"sort-packages" : true,
|
||||
"allow-plugins" : {
|
||||
"pestphp/pest-plugin": true,
|
||||
"phpstan/extension-installer": true,
|
||||
"php-http/discovery": false
|
||||
}
|
||||
},
|
||||
"minimum-stability" : "dev",
|
||||
"prefer-stable" : true
|
||||
}
|
||||
7
vendor/spatie/error-solutions/legacy/ignition/Contracts/BaseSolution.php
vendored
Normal file
7
vendor/spatie/error-solutions/legacy/ignition/Contracts/BaseSolution.php
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Ignition\Contracts;
|
||||
|
||||
class BaseSolution extends \Spatie\ErrorSolutions\Contracts\BaseSolution implements Solution
|
||||
{
|
||||
}
|
||||
7
vendor/spatie/error-solutions/legacy/ignition/Contracts/HasSolutionsForThrowable.php
vendored
Normal file
7
vendor/spatie/error-solutions/legacy/ignition/Contracts/HasSolutionsForThrowable.php
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Ignition\Contracts;
|
||||
|
||||
interface HasSolutionsForThrowable extends \Spatie\ErrorSolutions\Contracts\HasSolutionsForThrowable
|
||||
{
|
||||
}
|
||||
7
vendor/spatie/error-solutions/legacy/ignition/Contracts/ProvidesSolution.php
vendored
Normal file
7
vendor/spatie/error-solutions/legacy/ignition/Contracts/ProvidesSolution.php
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Ignition\Contracts;
|
||||
|
||||
interface ProvidesSolution extends \Spatie\ErrorSolutions\Contracts\ProvidesSolution
|
||||
{
|
||||
}
|
||||
16
vendor/spatie/error-solutions/legacy/ignition/Contracts/RunnableSolution.php
vendored
Normal file
16
vendor/spatie/error-solutions/legacy/ignition/Contracts/RunnableSolution.php
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Ignition\Contracts;
|
||||
|
||||
interface RunnableSolution extends Solution
|
||||
{
|
||||
public function getSolutionActionDescription(): string;
|
||||
|
||||
public function getRunButtonText(): string;
|
||||
|
||||
/** @param array<string, mixed> $parameters */
|
||||
public function run(array $parameters = []): void;
|
||||
|
||||
/** @return array<string, mixed> */
|
||||
public function getRunParameters(): array;
|
||||
}
|
||||
7
vendor/spatie/error-solutions/legacy/ignition/Contracts/Solution.php
vendored
Normal file
7
vendor/spatie/error-solutions/legacy/ignition/Contracts/Solution.php
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Ignition\Contracts;
|
||||
|
||||
interface Solution extends \Spatie\ErrorSolutions\Contracts\Solution
|
||||
{
|
||||
}
|
||||
8
vendor/spatie/error-solutions/legacy/ignition/Contracts/SolutionProviderRepository.php
vendored
Normal file
8
vendor/spatie/error-solutions/legacy/ignition/Contracts/SolutionProviderRepository.php
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Ignition\Contracts;
|
||||
|
||||
interface SolutionProviderRepository extends \Spatie\ErrorSolutions\Contracts\SolutionProviderRepository
|
||||
{
|
||||
|
||||
}
|
||||
8
vendor/spatie/error-solutions/legacy/ignition/Solutions/OpenAi/DummyCache.php
vendored
Normal file
8
vendor/spatie/error-solutions/legacy/ignition/Solutions/OpenAi/DummyCache.php
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Ignition\Solutions\OpenAi;
|
||||
|
||||
class DummyCache extends \Spatie\ErrorSolutions\Solutions\OpenAi\DummyCache
|
||||
{
|
||||
|
||||
}
|
||||
7
vendor/spatie/error-solutions/legacy/ignition/Solutions/OpenAi/OpenAiPromptViewModel.php
vendored
Normal file
7
vendor/spatie/error-solutions/legacy/ignition/Solutions/OpenAi/OpenAiPromptViewModel.php
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Ignition\Solutions\OpenAi;
|
||||
|
||||
class OpenAiPromptViewModel extends \Spatie\ErrorSolutions\Solutions\OpenAi\OpenAiPromptViewModel
|
||||
{
|
||||
}
|
||||
10
vendor/spatie/error-solutions/legacy/ignition/Solutions/OpenAi/OpenAiSolution.php
vendored
Normal file
10
vendor/spatie/error-solutions/legacy/ignition/Solutions/OpenAi/OpenAiSolution.php
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Ignition\Solutions\OpenAi;
|
||||
|
||||
use Spatie\Ignition\Contracts\Solution;
|
||||
|
||||
class OpenAiSolution extends \Spatie\ErrorSolutions\Solutions\OpenAi\OpenAiSolution implements Solution
|
||||
{
|
||||
|
||||
}
|
||||
10
vendor/spatie/error-solutions/legacy/ignition/Solutions/OpenAi/OpenAiSolutionProvider.php
vendored
Normal file
10
vendor/spatie/error-solutions/legacy/ignition/Solutions/OpenAi/OpenAiSolutionProvider.php
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Ignition\Solutions\OpenAi;
|
||||
|
||||
use Spatie\Ignition\Contracts\HasSolutionsForThrowable;
|
||||
|
||||
class OpenAiSolutionProvider extends \Spatie\ErrorSolutions\Solutions\OpenAi\OpenAiSolutionProvider implements HasSolutionsForThrowable
|
||||
{
|
||||
|
||||
}
|
||||
8
vendor/spatie/error-solutions/legacy/ignition/Solutions/OpenAi/OpenAiSolutionResponse.php
vendored
Normal file
8
vendor/spatie/error-solutions/legacy/ignition/Solutions/OpenAi/OpenAiSolutionResponse.php
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Ignition\Solutions\OpenAi;
|
||||
|
||||
class OpenAiSolutionResponse extends \Spatie\ErrorSolutions\Solutions\OpenAi\OpenAiSolutionResponse
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Ignition\Solutions\SolutionProviders;
|
||||
|
||||
use Spatie\ErrorSolutions\SolutionProviders\BadMethodCallSolutionProvider as BaseBadMethodCallSolutionProviderAlias;
|
||||
use Spatie\Ignition\Contracts\HasSolutionsForThrowable;
|
||||
|
||||
class BadMethodCallSolutionProvider extends BaseBadMethodCallSolutionProviderAlias implements HasSolutionsForThrowable
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Ignition\Solutions\SolutionProviders;
|
||||
|
||||
use Spatie\ErrorSolutions\SolutionProviders\MergeConflictSolutionProvider as BaseMergeConflictSolutionProviderAlias;
|
||||
use Spatie\Ignition\Contracts\HasSolutionsForThrowable;
|
||||
|
||||
class MergeConflictSolutionProvider extends BaseMergeConflictSolutionProviderAlias implements HasSolutionsForThrowable
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Ignition\Solutions\SolutionProviders;
|
||||
|
||||
use Spatie\ErrorSolutions\SolutionProviderRepository as BaseSolutionProviderRepositoryAlias;
|
||||
use Spatie\Ignition\Contracts\SolutionProviderRepository as SolutionProviderRepositoryContract;
|
||||
|
||||
class SolutionProviderRepository extends BaseSolutionProviderRepositoryAlias implements SolutionProviderRepositoryContract
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Ignition\Solutions\SolutionProviders;
|
||||
|
||||
use Spatie\ErrorSolutions\SolutionProviders\UndefinedPropertySolutionProvider as BaseUndefinedPropertySolutionProviderAlias;
|
||||
use Spatie\Ignition\Contracts\HasSolutionsForThrowable;
|
||||
|
||||
class UndefinedPropertySolutionProvider extends BaseUndefinedPropertySolutionProviderAlias implements HasSolutionsForThrowable
|
||||
{
|
||||
|
||||
}
|
||||
7
vendor/spatie/error-solutions/legacy/ignition/Solutions/SolutionTransformer.php
vendored
Normal file
7
vendor/spatie/error-solutions/legacy/ignition/Solutions/SolutionTransformer.php
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Ignition\Solutions;
|
||||
|
||||
class SolutionTransformer extends \Spatie\ErrorSolutions\Solutions\SolutionTransformer
|
||||
{
|
||||
}
|
||||
10
vendor/spatie/error-solutions/legacy/ignition/Solutions/SuggestCorrectVariableNameSolution.php
vendored
Normal file
10
vendor/spatie/error-solutions/legacy/ignition/Solutions/SuggestCorrectVariableNameSolution.php
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Ignition\Solutions;
|
||||
|
||||
use Spatie\ErrorSolutions\Solutions\SuggestCorrectVariableNameSolution as BaseSuggestCorrectVariableNameSolutionAlias;
|
||||
use Spatie\Ignition\Contracts\Solution;
|
||||
|
||||
class SuggestCorrectVariableNameSolution extends BaseSuggestCorrectVariableNameSolutionAlias implements Solution
|
||||
{
|
||||
}
|
||||
11
vendor/spatie/error-solutions/legacy/ignition/Solutions/SuggestImportSolution.php
vendored
Normal file
11
vendor/spatie/error-solutions/legacy/ignition/Solutions/SuggestImportSolution.php
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\Ignition\Solutions;
|
||||
|
||||
|
||||
use Spatie\ErrorSolutions\Solutions\SuggestImportSolution as BaseSuggestImportSolutionAlias;
|
||||
use Spatie\Ignition\Contracts\Solution;
|
||||
|
||||
class SuggestImportSolution extends BaseSuggestImportSolutionAlias implements Solution
|
||||
{
|
||||
}
|
||||
11
vendor/spatie/error-solutions/legacy/laravel-ignition/Solutions/GenerateAppKeySolution.php
vendored
Normal file
11
vendor/spatie/error-solutions/legacy/laravel-ignition/Solutions/GenerateAppKeySolution.php
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelIgnition\Solutions;
|
||||
|
||||
use Spatie\ErrorSolutions\Solutions\Laravel\GenerateAppKeySolution as BaseGenerateAppKeySolutionAlias;
|
||||
use Spatie\Ignition\Contracts\Solution;
|
||||
|
||||
class GenerateAppKeySolution extends BaseGenerateAppKeySolutionAlias implements Solution
|
||||
{
|
||||
|
||||
}
|
||||
11
vendor/spatie/error-solutions/legacy/laravel-ignition/Solutions/LivewireDiscoverSolution.php
vendored
Normal file
11
vendor/spatie/error-solutions/legacy/laravel-ignition/Solutions/LivewireDiscoverSolution.php
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelIgnition\Solutions;
|
||||
|
||||
use Spatie\ErrorSolutions\Solutions\Laravel\LivewireDiscoverSolution as BaseLivewireDiscoverSolutionAlias;
|
||||
use Spatie\Ignition\Contracts\Solution;
|
||||
|
||||
class LivewireDiscoverSolution extends BaseLivewireDiscoverSolutionAlias implements Solution
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelIgnition\Solutions;
|
||||
|
||||
use Spatie\ErrorSolutions\Solutions\Laravel\MakeViewVariableOptionalSolution as BaseMakeViewVariableOptionalSolutionAlias;
|
||||
use Spatie\Ignition\Contracts\Solution;
|
||||
|
||||
class MakeViewVariableOptionalSolution extends BaseMakeViewVariableOptionalSolutionAlias implements Solution
|
||||
{
|
||||
|
||||
}
|
||||
11
vendor/spatie/error-solutions/legacy/laravel-ignition/Solutions/RunMigrationsSolution.php
vendored
Normal file
11
vendor/spatie/error-solutions/legacy/laravel-ignition/Solutions/RunMigrationsSolution.php
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelIgnition\Solutions;
|
||||
|
||||
use Spatie\ErrorSolutions\Solutions\Laravel\RunMigrationsSolution as BaseRunMigrationsSolutionAlias;
|
||||
use Spatie\Ignition\Contracts\Solution;
|
||||
|
||||
class RunMigrationsSolution extends BaseRunMigrationsSolutionAlias implements Solution
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelIgnition\Solutions\SolutionProviders;
|
||||
|
||||
use Spatie\ErrorSolutions\SolutionProviders\Laravel\DefaultDbNameSolutionProvider as BaseDefaultDbNameSolutionProviderAlias;
|
||||
use Spatie\Ignition\Contracts\HasSolutionsForThrowable;
|
||||
|
||||
class DefaultDbNameSolutionProvider extends BaseDefaultDbNameSolutionProviderAlias implements HasSolutionsForThrowable
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelIgnition\Solutions\SolutionProviders;
|
||||
|
||||
use Spatie\ErrorSolutions\SolutionProviders\Laravel\GenericLaravelExceptionSolutionProvider as BaseGenericLaravelExceptionSolutionProviderAlias;
|
||||
use Spatie\Ignition\Contracts\HasSolutionsForThrowable;
|
||||
|
||||
class GenericLaravelExceptionSolutionProvider extends BaseGenericLaravelExceptionSolutionProviderAlias implements HasSolutionsForThrowable
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelIgnition\Solutions\SolutionProviders;
|
||||
|
||||
use Spatie\ErrorSolutions\SolutionProviders\Laravel\IncorrectValetDbCredentialsSolutionProvider as BaseIncorrectValetDbCredentialsSolutionProviderAlias;
|
||||
use Spatie\Ignition\Contracts\HasSolutionsForThrowable;
|
||||
|
||||
class IncorrectValetDbCredentialsSolutionProvider extends BaseIncorrectValetDbCredentialsSolutionProviderAlias implements HasSolutionsForThrowable
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelIgnition\Solutions\SolutionProviders;
|
||||
|
||||
use Spatie\ErrorSolutions\SolutionProviders\Laravel\InvalidRouteActionSolutionProvider as BaseInvalidRouteActionSolutionProviderAlias;
|
||||
use Spatie\Ignition\Contracts\HasSolutionsForThrowable;
|
||||
|
||||
class InvalidRouteActionSolutionProvider extends BaseInvalidRouteActionSolutionProviderAlias implements HasSolutionsForThrowable
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelIgnition\Solutions\SolutionProviders;
|
||||
|
||||
use Spatie\Ignition\Contracts\HasSolutionsForThrowable;
|
||||
use Spatie\ErrorSolutions\SolutionProviders\Laravel\LazyLoadingViolationSolutionProvider as BaseLazyLoadingViolationSolutionProviderAlias;
|
||||
|
||||
class LazyLoadingViolationSolutionProvider extends BaseLazyLoadingViolationSolutionProviderAlias implements HasSolutionsForThrowable
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelIgnition\Solutions\SolutionProviders;
|
||||
|
||||
use Spatie\ErrorSolutions\SolutionProviders\Laravel\MissingAppKeySolutionProvider as BaseMissingAppKeySolutionProviderAlias;
|
||||
use Spatie\Ignition\Contracts\HasSolutionsForThrowable;
|
||||
|
||||
class MissingAppKeySolutionProvider extends BaseMissingAppKeySolutionProviderAlias implements HasSolutionsForThrowable
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelIgnition\Solutions\SolutionProviders;
|
||||
|
||||
|
||||
use Spatie\ErrorSolutions\SolutionProviders\Laravel\MissingColumnSolutionProvider as BaseMissingColumnSolutionProviderAlias;
|
||||
use Spatie\Ignition\Contracts\HasSolutionsForThrowable;
|
||||
|
||||
class MissingColumnSolutionProvider extends BaseMissingColumnSolutionProviderAlias implements HasSolutionsForThrowable
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelIgnition\Solutions\SolutionProviders;
|
||||
|
||||
|
||||
use Spatie\ErrorSolutions\SolutionProviders\Laravel\MissingImportSolutionProvider as BaseMissingImportSolutionProviderAlias;
|
||||
use Spatie\Ignition\Contracts\HasSolutionsForThrowable;
|
||||
|
||||
class MissingImportSolutionProvider extends BaseMissingImportSolutionProviderAlias implements HasSolutionsForThrowable
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelIgnition\Solutions\SolutionProviders;
|
||||
|
||||
use Spatie\ErrorSolutions\SolutionProviders\Laravel\MissingLivewireComponentSolutionProvider as BaseMissingLivewireComponentSolutionProviderAlias;
|
||||
use Spatie\Ignition\Contracts\HasSolutionsForThrowable;
|
||||
|
||||
class MissingLivewireComponentSolutionProvider extends BaseMissingLivewireComponentSolutionProviderAlias implements HasSolutionsForThrowable
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelIgnition\Solutions\SolutionProviders;
|
||||
|
||||
use Spatie\ErrorSolutions\SolutionProviders\Laravel\MissingMixManifestSolutionProvider as BaseMissingMixManifestSolutionProviderAlias;
|
||||
use Spatie\Ignition\Contracts\HasSolutionsForThrowable;
|
||||
|
||||
class MissingMixManifestSolutionProvider extends BaseMissingMixManifestSolutionProviderAlias implements HasSolutionsForThrowable
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelIgnition\Solutions\SolutionProviders;
|
||||
|
||||
use Spatie\ErrorSolutions\SolutionProviders\Laravel\MissingViteManifestSolutionProvider as BaseMissingViteManifestSolutionProviderAlias;
|
||||
use Spatie\Ignition\Contracts\HasSolutionsForThrowable;
|
||||
|
||||
class MissingViteManifestSolutionProvider extends BaseMissingViteManifestSolutionProviderAlias implements HasSolutionsForThrowable
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelIgnition\Solutions\SolutionProviders;
|
||||
|
||||
use Spatie\ErrorSolutions\SolutionProviders\Laravel\OpenAiSolutionProvider as BaseOpenAiSolutionProviderAlias;
|
||||
use Spatie\Ignition\Contracts\HasSolutionsForThrowable;
|
||||
|
||||
class OpenAiSolutionProvider extends BaseOpenAiSolutionProviderAlias implements HasSolutionsForThrowable
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelIgnition\Solutions\SolutionProviders;
|
||||
|
||||
use Spatie\ErrorSolutions\SolutionProviders\Laravel\RouteNotDefinedSolutionProvider as BaseRouteNotDefinedSolutionProviderAlias;
|
||||
use Spatie\Ignition\Contracts\HasSolutionsForThrowable;
|
||||
|
||||
class RouteNotDefinedSolutionProvider extends BaseRouteNotDefinedSolutionProviderAlias implements HasSolutionsForThrowable
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelIgnition\Solutions\SolutionProviders;
|
||||
|
||||
use Spatie\ErrorSolutions\SolutionProviders\Laravel\RunningLaravelDuskInProductionProvider as BaseRunningLaravelDuskInProductionProviderAlias;
|
||||
use Spatie\Ignition\Contracts\HasSolutionsForThrowable;
|
||||
|
||||
class RunningLaravelDuskInProductionProvider extends BaseRunningLaravelDuskInProductionProviderAlias implements HasSolutionsForThrowable
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelIgnition\Solutions\SolutionProviders;
|
||||
|
||||
use Spatie\ErrorSolutions\SolutionProviders\Laravel\SailNetworkSolutionProvider as BaseSailNetworkSolutionProviderAlias;
|
||||
use Spatie\Ignition\Contracts\HasSolutionsForThrowable;
|
||||
|
||||
class SailNetworkSolutionProvider extends BaseSailNetworkSolutionProviderAlias implements HasSolutionsForThrowable
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelIgnition\Solutions\SolutionProviders;
|
||||
|
||||
use Spatie\ErrorSolutions\SolutionProviderRepository as BaseSolutionProviderRepositoryAlias;
|
||||
use Spatie\Ignition\Contracts\SolutionProviderRepository as SolutionProviderRepositoryContract;
|
||||
|
||||
class SolutionProviderRepository extends BaseSolutionProviderRepositoryAlias implements SolutionProviderRepositoryContract
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelIgnition\Solutions\SolutionProviders;
|
||||
|
||||
use Spatie\ErrorSolutions\SolutionProviders\Laravel\TableNotFoundSolutionProvider as BaseTableNotFoundSolutionProviderAlias;
|
||||
use Spatie\Ignition\Contracts\HasSolutionsForThrowable;
|
||||
|
||||
class TableNotFoundSolutionProvider extends BaseTableNotFoundSolutionProviderAlias implements HasSolutionsForThrowable
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelIgnition\Solutions\SolutionProviders;
|
||||
|
||||
use Spatie\ErrorSolutions\SolutionProviders\Laravel\UndefinedLivewireMethodSolutionProvider as BaseUndefinedLivewireMethodSolutionProviderAlias;
|
||||
use Spatie\Ignition\Contracts\HasSolutionsForThrowable;
|
||||
|
||||
class UndefinedLivewireMethodSolutionProvider extends BaseUndefinedLivewireMethodSolutionProviderAlias implements HasSolutionsForThrowable
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\LaravelIgnition\Solutions\SolutionProviders;
|
||||
|
||||
use Spatie\ErrorSolutions\SolutionProviders\Laravel\UndefinedLivewirePropertySolutionProvider as BaseUndefinedLivewirePropertySolutionProviderAlias;
|
||||
use Spatie\Ignition\Contracts\HasSolutionsForThrowable;
|
||||
|
||||
class UndefinedLivewirePropertySolutionProvider extends BaseUndefinedLivewirePropertySolutionProviderAlias implements HasSolutionsForThrowable
|
||||
{
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user