1<?php declare(strict_types=1); 2 3/* 4 * This file is part of the Monolog package. 5 * 6 * (c) Jordi Boggiano <j.boggiano@seld.be> 7 * 8 * For the full copyright and license information, please view the LICENSE 9 * file that was distributed with this source code. 10 */ 11 12namespace Monolog\Handler; 13 14/** 15 * Base Handler class providing basic close() support as well as handleBatch 16 * 17 * @author Jordi Boggiano <j.boggiano@seld.be> 18 */ 19abstract class Handler implements HandlerInterface 20{ 21 /** 22 * {@inheritDoc} 23 */ 24 public function handleBatch(array $records): void 25 { 26 foreach ($records as $record) { 27 $this->handle($record); 28 } 29 } 30 31 /** 32 * {@inheritDoc} 33 */ 34 public function close(): void 35 { 36 } 37 38 public function __destruct() 39 { 40 try { 41 $this->close(); 42 } catch (\Throwable $e) { 43 // do nothing 44 } 45 } 46 47 public function __sleep() 48 { 49 $this->close(); 50 51 return array_keys(get_object_vars($this)); 52 } 53} 54