DebuggerFactory.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Signifyd\Model\SignifydGateway\Debugger;
  7. use Magento\Framework\ObjectManagerInterface;
  8. use Magento\Signifyd\Model\Config;
  9. /**
  10. * Factory produces debugger based on runtime configuration.
  11. *
  12. * Configuration may be changed by
  13. * - config.xml
  14. * - at Admin panel (Stores > Configuration > Sales > Fraud Detection > Signifyd > Debug)
  15. */
  16. class DebuggerFactory
  17. {
  18. /**
  19. * @var ObjectManagerInterface
  20. */
  21. private $objectManager;
  22. /**
  23. * @var Config
  24. */
  25. private $config;
  26. /**
  27. * DebuggerFactory constructor.
  28. *
  29. * @param ObjectManagerInterface $objectManager
  30. * @param Config $config
  31. */
  32. public function __construct(
  33. ObjectManagerInterface $objectManager,
  34. Config $config
  35. ) {
  36. $this->objectManager = $objectManager;
  37. $this->config = $config;
  38. }
  39. /**
  40. * Create debugger instance
  41. *
  42. * @param int|null $storeId
  43. * @return DebuggerInterface
  44. */
  45. public function create($storeId = null): DebuggerInterface
  46. {
  47. if (!$this->config->isDebugModeEnabled($storeId)) {
  48. return $this->objectManager->get(BlackHole::class);
  49. }
  50. return $this->objectManager->get(Log::class);
  51. }
  52. }