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

valkyrjaio / valkyrja / 13047041070

30 Jan 2025 06:43AM UTC coverage: 47.621% (+0.2%) from 47.422%
13047041070

push

github

MelechMizrachi
PHPStan level 7 and 8.

168 of 1038 new or added lines in 111 files covered. (16.18%)

444 existing lines in 45 files now uncovered.

5195 of 10909 relevant lines covered (47.62%)

18.83 hits per line

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

0.0
/src/Valkyrja/Config/Config/DataConfig.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of the Valkyrja Framework package.
7
 *
8
 * (c) Melech Mizrachi <melechmizrachi@gmail.com>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13

14
namespace Valkyrja\Config\Config;
15

16
use Valkyrja\Annotation\Config as Annotation;
17
use Valkyrja\Api\Config as Api;
18
use Valkyrja\Application\Config as App;
19
use Valkyrja\Application\Constant\EnvKey;
20
use Valkyrja\Asset\Config as Asset;
21
use Valkyrja\Auth\Config as Auth;
22
use Valkyrja\Broadcast\Config as Broadcast;
23
use Valkyrja\Cache\Config as Cache;
24
use Valkyrja\Client\Config as Client;
25
use Valkyrja\Config\Constant\ConfigKeyPart as CKP;
26
use Valkyrja\Config\DataConfig as ParentConfig;
27
use Valkyrja\Config\Support\Provider;
28
use Valkyrja\Console\Config as Console;
29
use Valkyrja\Container\Config as Container;
30
use Valkyrja\Crypt\Config as Crypt;
31
use Valkyrja\Event\Config as Event;
32
use Valkyrja\Filesystem\Config as Filesystem;
33
use Valkyrja\Http\Routing\Config as Routing;
34
use Valkyrja\Jwt\Config as Jwt;
35
use Valkyrja\Log\Config as Log;
36
use Valkyrja\Mail\Config as Mail;
37
use Valkyrja\Notification\Config as Notification;
38
use Valkyrja\Orm\Config\Config as ORM;
39
use Valkyrja\Path\Config as Path;
40
use Valkyrja\Session\Config as Session;
41
use Valkyrja\Sms\Config as Sms;
42
use Valkyrja\View\Config as View;
43

44
/**
45
 * Class Config.
46
 *
47
 * @author Melech Mizrachi
48
 */
49
class DataConfig extends ParentConfig
50
{
51
    /**
52
     * @inheritDoc
53
     *
54
     * @var array<string, string>
55
     */
56
    protected static array $envKeys = [
57
        CKP::PROVIDERS       => EnvKey::CONFIG_PROVIDERS,
58
        CKP::CACHE_FILE_PATH => EnvKey::CONFIG_CACHE_FILE_PATH,
59
        CKP::USE_CACHE       => EnvKey::CONFIG_USE_CACHE_FILE,
60
    ];
61

62
    /**
63
     * A map of property to class.
64
     *
65
     * @var array<string, class-string>
66
     */
67
    protected static array $map = [];
68

69
    /**
70
     * The annotation module config.
71
     *
72
     * @var Annotation
73
     */
74
    protected Annotation $annotation;
75

76
    /**
77
     * The api module config.
78
     *
79
     * @var Api
80
     */
81
    protected Api $api;
82

83
    /**
84
     * The application module config.
85
     *
86
     * @var App
87
     */
88
    protected App $app;
89

90
    /**
91
     * The asset module config.
92
     *
93
     * @var Asset
94
     */
95
    protected Asset $asset;
96

97
    /**
98
     * The auth module config.
99
     *
100
     * @var Auth
101
     */
102
    protected Auth $auth;
103

104
    /**
105
     * The broadcast module config.
106
     *
107
     * @var Broadcast
108
     */
109
    protected Broadcast $broadcast;
110

111
    /**
112
     * The cache module config.
113
     *
114
     * @var Cache
115
     */
116
    protected Cache $cache;
117

118
    /**
119
     * The client module config.
120
     *
121
     * @var Client
122
     */
123
    protected Client $client;
124

125
    /**
126
     * The console module config.
127
     *
128
     * @var Console
129
     */
130
    protected Console $console;
131

132
    /**
133
     * The container module config.
134
     *
135
     * @var Container
136
     */
137
    protected Container $container;
138

139
    /**
140
     * The crypt module config.
141
     *
142
     * @var Crypt
143
     */
144
    protected Crypt $crypt;
145

146
    /**
147
     * The event module config.
148
     *
149
     * @var Event
150
     */
151
    protected Event $event;
152

153
    /**
154
     * The filesystem module config.
155
     *
156
     * @var Filesystem
157
     */
158
    protected Filesystem $filesystem;
159

160
    /**
161
     * The Jwt module config.
162
     *
163
     * @var Jwt
164
     */
165
    protected Jwt $jwt;
166

167
    /**
168
     * The logging module config.
169
     *
170
     * @var Log
171
     */
172
    protected Log $log;
173

174
    /**
175
     * The mail module config.
176
     *
177
     * @var Mail
178
     */
179
    protected Mail $mail;
180

181
    /**
182
     * The notification module config.
183
     *
184
     * @var Notification
185
     */
186
    protected Notification $notification;
187

188
    /**
189
     * The ORM module config.
190
     *
191
     * @var ORM
192
     */
193
    protected ORM $orm;
194

195
    /**
196
     * The path module config.
197
     *
198
     * @var Path
199
     */
200
    protected Path $path;
201

202
    /**
203
     * The routing module config.
204
     *
205
     * @var Routing
206
     */
207
    protected Routing $routing;
208

209
    /**
210
     * The session module config.
211
     *
212
     * @var Session
213
     */
214
    protected Session $session;
215

216
    /**
217
     * The SMS module config.
218
     *
219
     * @var Sms
220
     */
221
    protected Sms $sms;
222

223
    /**
224
     * The view module config.
225
     *
226
     * @var View
227
     */
228
    protected View $view;
229

230
    /**
231
     * Array of config providers.
232
     *  NOTE: Provider::deferred() is disregarded.
233
     *
234
     * @var class-string<Provider>[]
235
     */
236
    protected array $providers;
237

238
    /**
239
     * The cache file path.
240
     *
241
     * @var string
242
     */
243
    protected string $cacheFilePath;
244

245
    /**
246
     * Whether to use cache.
247
     *
248
     * @var bool
249
     */
250
    protected bool $useCache;
251

252
    /**
253
     * @param array<string, mixed>|null $cached
254
     */
255
    public function __construct(
256
        protected array|null $cached = null
257
    ) {
258
    }
×
259

260
    /**
261
     * Get a property.
262
     */
263
    public function __get(string $name): mixed
264
    {
265
        if (! isset($this->$name) && $this->cached !== null) {
×
266
            $cache = $this->cached[$name];
×
267

268
            match ($name) {
×
269
                'annotations' => new Annotation\Annotation($cache),
×
NEW
270
                'api'         => new Api\Api($cache),
×
NEW
271
                'app'         => new App\App($cache),
×
NEW
272
                'asset'       => new Asset\Asset($cache),
×
273
                'useCache', 'cacheFilePath', 'providers' => $cache,
×
NEW
274
                default       => new static::$map[$name]($cache),
×
275
            };
×
276
        }
277

278
        return $this->$name ?? null;
×
279
    }
280

281
    /**
282
     * Set a property.
283
     */
284
    public function __set(string $name, mixed $value): void
285
    {
286
        $this->$name = $value;
×
287
    }
288

289
    /**
290
     * Determine if a property isset.
291
     */
292
    public function __isset(string $name): bool
293
    {
294
        return isset($this->$name);
×
295
    }
296

297
    /**
298
     * @inheritDoc
299
     */
300
    public function offsetExists($offset): bool
301
    {
302
        /** @var string $offset */
303
        return $this->__isset($this->$offset);
×
304
    }
305

306
    /**
307
     * @inheritDoc
308
     */
309
    public function offsetGet($offset): mixed
310
    {
311
        /** @var string $offset */
312
        return $this->__get($offset);
×
313
    }
314

315
    /**
316
     * @inheritDoc
317
     */
318
    public function offsetSet($offset, $value): void
319
    {
320
        /** @var string $offset */
321
        $this->__set($offset, $value);
×
322
    }
323
}
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