for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Mguinea\Robots;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Collection;
use Illuminate\Support\ServiceProvider;
class RobotsServiceProvider extends ServiceProvider
{
/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = false;
* Bootstrap services.
* @return void
public function boot(Filesystem $filesystem)
$this->publishes([
__DIR__.'/../config/laravel-robots.php' => config_path('laravel-robots.php'),
], 'config');
__DIR__.'/../database/migrations/create_robots_tables.php.stub' => $this->getMigrationFileName($filesystem),
], 'migrations');
}
* Register the service provider.
public function register()
$this->app->singleton('robots', function ($app) {
$app
If this is a false-positive, you can also ignore this issue in your code via the ignore-unused annotation
ignore-unused
$this->app->singleton('robots', function (/** @scrutinizer ignore-unused */ $app) {
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
return new Robots();
});
$this->app->alias('robots', 'Mguinea\Robots');
$this->mergeConfigFrom(
__DIR__.'/../config/laravel-robots.php',
'laravel-robots'
);
* Returns existing migration file if found, else uses the current timestamp.
* @param Filesystem $filesystem
* @return string
protected function getMigrationFileName(Filesystem $filesystem): string
$timestamp = date('Y_m_d_His');
return Collection::make($this->app->databasePath().DIRECTORY_SEPARATOR.'migrations'.DIRECTORY_SEPARATOR)
->flatMap(function ($path) use ($filesystem) {
return $filesystem->glob($path.'*_create_robots_tables.php');
})->push($this->app->databasePath()."/migrations/{$timestamp}_create_robots_tables.php")
->first();
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.