for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Arp\LaminasMonolog\Factory\Handler;
use Arp\LaminasFactory\AbstractFactory;
use Laminas\ServiceManager\Exception\ServiceNotCreatedException;
use Monolog\Handler\ErrorLogHandler;
use Monolog\Logger;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\ContainerInterface;
use Psr\Log\LogLevel;
/**
* @phpstan-import-type Level from \Monolog\Logger
* @phpstan-import-type LevelName from \Monolog\Logger
*/
final class ErrorLogHandlerFactory extends AbstractFactory
{
* @throws ServiceNotCreatedException
* @throws ContainerExceptionInterface
public function __invoke(
ContainerInterface $container,
string $requestedName,
array $options = null
): ErrorLogHandler {
$options = $options ?? $this->getServiceOptions($container, $requestedName);
/** @var Level|LevelName|LogLevel::* $level */
$level = isset($options['level']) ? (int)$options['level'] : Logger::DEBUG;
return new ErrorLogHandler(
isset($options['message_type']) ? (int)$options['message_type'] : ErrorLogHandler::OPERATING_SYSTEM,
$level,
!isset($options['bubble']) || $options['bubble'],
isset($options['expand_new_lines']) && $options['expand_new_lines']
);
}