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

The-oGlow / ya-corapi / 19973072714

05 Dec 2025 07:00PM UTC coverage: 37.825%. First build
19973072714

push

github

web-flow
Push2master (#4)

11 of 51 new or added lines in 13 files covered. (21.57%)

713 of 1885 relevant lines covered (37.82%)

1.88 hits per line

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

50.0
/src/Yacorapi/Data/SpaceData.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 oglowa\tools\common\AbstractContainer;
17
use oglowa\tools\Yacorapi\ConstData;
18
use oglowa\tools\Yacorapi\IResponse;
19

20
class SpaceData extends AbstractContainer
21
{
22
    public const           SPACE_SINGLE        = 1;
23

24
    public const           SPACE_SINGLE_METHOD = 'getMySpaceListSingle';
25

26
    public const           SPACE_SIMPLE        = 2;
27

28
    public const           SPACE_SIMPLE_METHOD = 'getMySpaceListSimple';
29

30
    public const           SPACE_ALL           = 99;
31

32
    public const           SPACE_ALL_METHOD    = 'getMySpaceListAll';
33

34
    public const           MY_SPACES_NS        = 'oglowa\\tools\\Yacorapi';
35

36
    public const           MY_SPACES_CLAZZ     = 'MySpaces';
37

38
    public const           MY_SPACES_NS_CLAZZ  = '\\' . self::MY_SPACES_NS . '\\' . self::MY_SPACES_CLAZZ;
39

40
    public const           MY_SPACES_FILE      = self::MY_SPACES_CLAZZ . '.php';
41

42
    /**
43
     * @param mixed[] $spaces
44
     *
45
     * @return string
46
     */
47
    public static function prepareMySpacesContent(array $spaces): string
×
48
    {
49
        $line =
×
50
            "<?php\ndeclare(strict_types=1);\n" .
×
51
            "namespace " .
×
52
            self::MY_SPACES_NS .
×
53
            ";\n" .
×
54
            "class " .
×
55
            self::MY_SPACES_CLAZZ .
×
56
            "\n{\n" .
×
57
            "public static function " .
×
58
            self::SPACE_ALL_METHOD .
×
59
            "(): array\n{return [";
×
60

61
        foreach ($spaces as $space) {
×
62
            $line .= sprintf("'%s',\n", $space[IResponse::KEY_KEY]);
×
63
        }
64

65
        $line .= "\n];\n}\n}\n";
×
66

67
        return $line;
×
68
    }
69

70
    public static function prepareMySpacesFileName(): string
×
71
    {
72
        return self::MY_SPACES_FILE;
×
73
    }
74

75
    /**
76
     * @SuppressWarnings("PHPMD.ExitExpression")
77
     */
78
    public function loadPersonalSpaces(): void
5✔
79
    {
80
        $mySpacesFile = ((string)$this->constData->c(ConstData::KEY_MY_DIR)) . DIRECTORY_SEPARATOR . self::MY_SPACES_FILE;
5✔
81
        if (file_exists($mySpacesFile)) {
5✔
82
            include_once $mySpacesFile; // NOSONAR: php:S4832
5✔
83
        } else {
84
            $this->logger->warning('MySpaces not exists!', [$mySpacesFile]);
×
85

NEW
86
            exit(20); // NOSONAR: php:S1799
×
87
        }
88
    }
89

90
    protected function prepareModes(): void
5✔
91
    {
92
        $allModes = [self::SPACE_SINGLE, self::SPACE_SIMPLE, self::SPACE_ALL];
5✔
93
        $this->setModes($allModes);
5✔
94
    }
95

96
    protected function prepareData(): void
5✔
97
    {
98
        $allData                     = [];
5✔
99
        $allData[self::SPACE_SINGLE] = $this->dynamicall(self::SPACE_SINGLE_METHOD);
5✔
100
        $allData[self::SPACE_SIMPLE] = $this->dynamicall(self::SPACE_SIMPLE_METHOD);
5✔
101
        $allData[self::SPACE_ALL]    = $this->dynamicall(self::SPACE_ALL_METHOD);
5✔
102
        $this->setAllData($allData);
5✔
103
    }
104

105
    /**
106
     * @param string $mySpacesFunc
107
     *
108
     * @return mixed
109
     */
110
    private function dynamicall(string $mySpacesFunc)
5✔
111
    {
112
        $this->loadPersonalSpaces();
5✔
113
        $mySpaces = [];
5✔
114
        /**
115
         * @psalm-suppress ArgumentTypeCoercion
116
         * @phpstan-ignore function.impossibleType
117
         */
118
        if (method_exists(self::MY_SPACES_NS_CLAZZ, $mySpacesFunc)) {
5✔
119
            /** @phpstan-ignore argument.type */
120
            $refInstance = new \ReflectionClass(self::MY_SPACES_NS_CLAZZ);
5✔
121
            $refObject   = new \ReflectionMethod(self::MY_SPACES_NS_CLAZZ, $mySpacesFunc);
5✔
122
            $mySpaces    = $refObject->invoke($refInstance);
5✔
123
        } else {
124
            $this->logger->warning('MySpaces not loaded!', [$mySpacesFunc]);
×
125
        }
126

127
        return $mySpaces;
5✔
128
    }
129
}
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