Passed
Branch master (ecb7f7)
by Andrey
17:46
created

WhatFailureGroupHandler::handleBatch()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 5
c 0
b 0
f 0
nc 4
nop 1
dl 0
loc 8
rs 10
1
<?php
2
3
/*
4
 * This file is part of the Monolog package.
5
 *
6
 * (c) Jordi Boggiano <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Monolog\Handler;
13
14
/**
15
 * Forwards records to multiple handlers suppressing failures of each handler
16
 * and continuing through to give every handler a chance to succeed.
17
 *
18
 * @author Craig D'Amelio <[email protected]>
19
 */
20
class WhatFailureGroupHandler extends GroupHandler
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function handle(array $record)
26
    {
27
        if ($this->processors) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->processors of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
28
            foreach ($this->processors as $processor) {
29
                $record = call_user_func($processor, $record);
30
            }
31
        }
32
33
        foreach ($this->handlers as $handler) {
34
            try {
35
                $handler->handle($record);
36
            } catch (\Exception $e) {
37
                // What failure?
38
            } catch (\Throwable $e) {
39
                // What failure?
40
            }
41
        }
42
43
        return false === $this->bubble;
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49
    public function handleBatch(array $records)
50
    {
51
        foreach ($this->handlers as $handler) {
52
            try {
53
                $handler->handleBatch($records);
54
            } catch (\Exception $e) {
55
                // What failure?
56
            } catch (\Throwable $e) {
57
                // What failure?
58
            }
59
        }
60
    }
61
}
62