Skip to content
Permalink
a1a069ad7e
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
80 lines (72 sloc) 2.03 KB
<?php
declare(strict_types=1);
namespace NunoMaduro\PhpInsights\Application\Adapters\Laravel;
use NunoMaduro\PhpInsights\Domain\Contracts\Preset as PresetContract;
use NunoMaduro\PhpInsights\Domain\Insights\ForbiddenDefineGlobalConstants;
use PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\ForbiddenFunctionsSniff;
/**
* @internal
*/
final class Preset implements PresetContract
{
/**
* {@inheritDoc}
*/
public static function getName(): string
{
return 'laravel';
}
/**
* {@inheritDoc}
*/
public static function get(): array
{
return [
'exclude' => [
'config',
'storage',
'resources',
'bootstrap',
'nova',
'database',
'server.php',
'_ide_helper.php',
'_ide_helper_models.php',
'public',
],
'add' => [
// ...
],
'remove' => [
// ...
],
'config' => [
ForbiddenDefineGlobalConstants::class => [
'ignore' => ['LARAVEL_START'],
],
ForbiddenFunctionsSniff::class => [
'forbiddenFunctions' => [
'dd' => null,
'dump' => null,
],
],
],
];
}
/**
* {@inheritDoc}
*/
public static function shouldBeApplied(array $composer): bool
{
/** @var string[] $requirements */
$requirements = $composer['require'];
foreach (array_keys($requirements) as $requirement) {
$requirement = (string) $requirement;
if (strpos($requirement, 'laravel/framework') !== false
|| strpos($requirement, 'illuminate/') !== false) {
return true;
}
}
return array_key_exists('name', $composer) && $composer['name'] === 'laravel/framework';
}
}