• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

The-oGlow / ezlogging / 18263869522

05 Oct 2025 08:21PM UTC coverage: 84.516% (+11.0%) from 73.543%
18263869522

push

github

ollily
#1: fix github actions

24 of 36 new or added lines in 3 files covered. (66.67%)

11 existing lines in 4 files now uncovered.

262 of 310 relevant lines covered (84.52%)

13.7 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

87.5
/src/Monolog/Processor/PaddingProcessor.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of ezlogging
7
 *
8
 * (c) 2025 Oliver Glowa, coding.glowa.com
9
 *
10
 * This source file is subject to the Apache-2.0 license that is bundled
11
 * with this source code in the file LICENSE.
12
 */
13

14
namespace Monolog\Processor;
15

16
use Monolog\Logger;
17

18
/**
19
 * Class PaddingProcessor.
20
 *
21
 * Use Introspection from @see IntrospectionProcessor.
22
 *
23
 * @see     IntrospectionProcessor
24
 */
25
class PaddingProcessor implements ProcessorInterface
26
{
27
    /** @var int */
28
    private $level;
29

30
    /** @var string[] */
31
    private $skipClassesPartials;
32

33
    /** @var int */
34
    private $skipStackFramesCount;
35

36
    /** @var string[] */
37
    private $skipFunctions = [
38
        'call_user_func',
39
        'call_user_func_array'
40
    ];
41

42
    /**
43
     * @param mixed    $level
44
     *                                       The minimum logging level at which this Processor will be triggered
45
     * @param string[] $skipClassesPartials
46
     * @param int      $skipStackFramesCount
47
     *
48
     * @SuppressWarnings("PHPMD.StaticAccess")
49
     */
50
    public function __construct($level = Logger::DEBUG, array $skipClassesPartials = [], int $skipStackFramesCount = 0)
24✔
51
    {
52
        $this->level                = Logger::toMonologLevel($level);
24✔
53
        $this->skipClassesPartials  = array_merge(
24✔
54
            [
24✔
55
                'Monolog\\'
24✔
56
            ],
24✔
57
            $skipClassesPartials
24✔
58
        );
24✔
59
        $this->skipStackFramesCount = $skipStackFramesCount;
24✔
60
    }
61

62
    /**
63
     * @param mixed[] $record
64
     *
65
     * @return mixed[]
66
     *
67
     * @phpstan-ignore method.childReturnType
68
     */
69
    public function __invoke(array $record)
3✔
70
    {
71
        $record                   = $this->__invokeIntrospection($record);
3✔
72
        $record['level_name_pad'] = str_pad($record['level_name'], 8, ' ', STR_PAD_RIGHT);
3✔
73

74
        return $record;
3✔
75
    }
76

77
    /**
78
     * @param mixed[] $record
79
     *
80
     * @return mixed[]
81
     *
82
     * @SuppressWarnings("PHPMD.CamelCaseMethodName")
83
     * @SuppressWarnings("PHPMD.ElseExpression")
84
     */
85
    private function __invokeIntrospection(array $record): array // NOSONAR: php:S100
3✔
86
    {
87
        // return if the level is not high enough
88
        if ($record['level'] < $this->level) {
3✔
UNCOV
89
            return $record;
×
90
        }
91

92
        $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
3✔
93

94
        // skip first since it's always the current method
95
        array_shift($trace);
3✔
96
        // the call_user_func call is also skipped
97
        array_shift($trace);
3✔
98

99
        $index = 0;
3✔
100

101
        while ($this->isTraceClassOrSkippedFunction($trace, $index)) {
3✔
102
            if (isset($trace[$index]['class'])) {
3✔
103
                foreach ($this->skipClassesPartials as $part) {
3✔
104
                    if (strpos($trace[$index]['class'], $part) !== false) {
3✔
105
                        $index++;
3✔
106

107
                        continue 2;
3✔
108
                    }
109
                }
UNCOV
110
            } elseif (in_array($trace[$index]['function'], $this->skipFunctions, true)) {
×
111
                $index++;
×
112

113
                continue;
×
114
            } else {
UNCOV
115
                break;
×
116
            }
117
            break;
3✔
118
        }
119

120
        $index += $this->skipStackFramesCount;
3✔
121

122
        // we should have the call source now
123
        if ($index > 0 && $index < count($trace)) {
3✔
124
            $curTrace  = $trace[$index];
3✔
125
            $prevTrace = $trace[$index - 1];
3✔
126
            $xDetails  = [
3✔
127
                'xFile'     => $prevTrace['file'] ?? null,
3✔
128
                'xLine'     => $prevTrace['line'] ?? null,
3✔
129
                'xClass'    => $curTrace['class'] ?? null,
3✔
130
                'xCallType' => $curTrace['type'] ?? null,
3✔
131
                'xFunction' => $curTrace['function']
3✔
132
            ];
3✔
133
            $record    = array_merge($record, $xDetails);
3✔
134
        }
135

136
        return $record;
3✔
137
    }
138

139
    /**
140
     * @param mixed[] $trace
141
     * @param int     $index
142
     *
143
     * @return bool
144
     */
145
    private function isTraceClassOrSkippedFunction(array $trace, int $index): bool
3✔
146
    {
147
        if (!isset($trace[$index])) {
3✔
UNCOV
148
            return false;
×
149
        }
150

151
        return isset($trace[$index]['class']) || in_array($trace[$index]['function'], $this->skipFunctions, true);
3✔
152
    }
153
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc