ProfilerStateChecker.php 742 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\HttpKernel\Profiler;
  11. use Psr\Container\ContainerInterface;
  12. class ProfilerStateChecker
  13. {
  14. public function __construct(
  15. private ContainerInterface $container,
  16. private bool $defaultEnabled,
  17. ) {
  18. }
  19. public function isProfilerEnabled(): bool
  20. {
  21. return $this->container->get('profiler')?->isEnabled() ?? $this->defaultEnabled;
  22. }
  23. public function isProfilerDisabled(): bool
  24. {
  25. return !$this->isProfilerEnabled();
  26. }
  27. }