for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Spatie\DemoMode;
use Closure;
use Illuminate\Config\Repository;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
class DemoMode
{
/** @var array */
protected $config;
public function __construct(Repository $config)
$this->config = $config->get('demo-mode');
}
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
if (!$this->config['enabled']) {
return $next($request);
if ($this->protectedByDemoMode($request)) {
if (!app(DemoGuard::class)->hasDemoAccess($request)) {
return new RedirectResponse($this->config['redirect_unauthorized_users_to_url']);
protected function protectedByDemoMode(Request $request): bool
$request
If this is a false-positive, you can also ignore this issue in your code via the ignore-unused annotation
ignore-unused
protected function protectedByDemoMode(/** @scrutinizer ignore-unused */ Request $request): bool
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
return true;
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.