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

The-oGlow / ya-corapi / 20730329328

05 Jan 2026 09:54PM UTC coverage: 50.144% (+3.8%) from 46.354%
20730329328

push

github

oglowa
#3: Update files / tested

522 of 537 new or added lines in 20 files covered. (97.21%)

153 existing lines in 8 files now uncovered.

1048 of 2090 relevant lines covered (50.14%)

8.43 hits per line

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

77.19
/src/Yacorapi/Data/AddonMacroData.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of ezlogging
7
 *
8
 * (c) 2024 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 oglowa\tools\Yacorapi\Data;
15

16
use Ds\Map;
17
use Ds\Vector;
18
use oglowa\tools\common\AbstractContainer;
19
use oglowa\tools\Yacorapi\Macro\AllAddon;
20
use oglowa\tools\Yacorapi\Macro\BlockerAddon;
21
use oglowa\tools\Yacorapi\Macro\SingleAddon;
22
use oglowa\tools\Yacorapi\Traits\ExtensionTrait;
23

24
class AddonMacroData extends AbstractContainer
25
{
26
    use ExtensionTrait;
27

28
    /**
29
     * @param int|string $mode
30
     *
31
     * @return mixed
32
     */
33
    public function getMacros($mode = SingleAddon::ADDON_SINGLE)
3✔
34
    {
35
        $this->logger->debug('START', [$mode]);
3✔
36
        $macros = [];
3✔
37
        if ($this->keyExists($mode)) {
3✔
38
            $addons = $this->getDataByMode($mode);
2✔
39
            if (is_array($addons)) {
2✔
NEW
40
                $macros = array_keys($addons);
×
41
            } elseif ($addons instanceof Map) {
2✔
42
                $macros = $this->getExtensionAddonMacrosArray($addons);
2✔
43
            }
44
        }
45
        $this->logger->debug('macros', [$macros]);
3✔
46
        $this->logger->debug('END', [$mode]);
3✔
47

48
        return $macros;
3✔
49
    }
50

51
    /**
52
     * @param int|string $mode
53
     * @param string     $addon
54
     *
55
     * @return mixed[]
56
     */
57
    public function getMacroNamesByAddon($mode, string $addon): array
2✔
58
    {
59
        $this->logger->debug('START', [$mode, $addon]);
2✔
60

61
        $macroNames = [];
2✔
62
        if ($this->keyExists($mode)) {
2✔
63
            $addons = $this->getDataByMode($mode);
1✔
64
            if (is_array($addons)) {
1✔
NEW
65
                if (array_key_exists($addon, $addons)) {
×
NEW
66
                    $macroNames = $addons[$addon];
×
67
                }
68
            }
69
        }
70
        $this->logger->debug('macroNames', [$macroNames]);
2✔
71
        $this->logger->debug('END', [$mode, $addon]);
2✔
72

73
        return $macroNames;
2✔
74
    }
75

76
    /**
77
     * @param int|string $mode
78
     *
79
     * @return mixed[]
80
     */
81
    public function getMacroNamesByMode($mode): array
2✔
82
    {
83
        $this->logger->debug('START', [$mode]);
2✔
84

85
        $macroNames = [];
2✔
86
        if ($this->keyExists($mode)) {
2✔
87
            $addons = $this->getDataByMode($mode);
1✔
88
            foreach ($addons as $addon) {
1✔
89
                if (is_array($addons)) {
1✔
NEW
90
                    $macroNames = array_merge($macroNames, array_values($addon));
×
91
                } elseif ($addon instanceof Vector) {
1✔
92
                    $macroNames = array_merge($macroNames, $addon->toArray());
1✔
93
                }
94
            }
95
        }
96
        $this->logger->debug('macroNames', [$macroNames]);
2✔
97
        $this->logger->debug('END', [$mode]);
2✔
98

99
        return $macroNames;
2✔
100
    }
101

102
    protected function prepareModes(): void
10✔
103
    {
104
        $allModes = [SingleAddon::ADDON_SINGLE, BlockerAddon::ADDON_BLOCKER, AllAddon::ADDON_ALL];
10✔
105
        $this->setModes($allModes);
10✔
106
    }
107

108
    /**
109
     * @SuppressWarnings("PHPMD.ExitExpression")
110
     */
111
    protected function prepareData(): void
10✔
112
    {
113
        $allData = [];
10✔
114

115
        try {
116
            $singleAddon                        = new SingleAddon();
10✔
117
            $allData[SingleAddon::ADDON_SINGLE] = $singleAddon->getAddons();
10✔
UNCOV
118
        } catch (\Exception $ex) {
×
NEW
119
            $this->logger->error('SingleMacro failed', [$ex]);
×
120

UNCOV
121
            exit(25);
×
122
        }
123

124
        try {
125
            $blockerAddon                         = new BlockerAddon();
10✔
126
            $allData[BlockerAddon::ADDON_BLOCKER] = $blockerAddon->getAddons();
10✔
UNCOV
127
        } catch (\Exception $ex) {
×
NEW
128
            $this->logger->error('BlockerMacro failed', [$ex]);
×
129

UNCOV
130
            exit(26);
×
131
        }
132

133
        try {
134
            $allAddon                     = new AllAddon($this->constData);
10✔
135
            $allData[AllAddon::ADDON_ALL] = $allAddon->getAddons();
10✔
UNCOV
136
        } catch (\Exception $ex) {
×
NEW
137
            $this->logger->error('AllMacro failed', [$ex]);
×
138

UNCOV
139
            exit(27);
×
140
        }
141

142
        $this->setAllData($allData);
10✔
143
    }
144
}
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