/
jagepard
/
Rudra-Container
Обзор
Документация
Войти
/
jagepard
/
Rudra-Container
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/Container.php
44 строки
1 KB
Jagepard
Refactor: Cleanup documentation and remove redundant comments
08 июн 2026, 15:00
08 июн 2026, 15:00
3c26247
Код
Авторство
О чём код?
<?php declare(strict_types=1); /** * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. * * @author Korotkov Danila (Jagepard) <jagepard@yandex.ru> * @license https://mozilla.org/MPL/2.0/ MPL-2.0 */ namespace Rudra\Container; use Psr\Container\ContainerInterface; use Rudra\Exceptions\NotFoundException; class Container implements ContainerInterface { public function __construct(protected array $data = []) {} #[\Override] public function get(string $id): mixed { return $this->has($id) ? $this->data[$id] : throw new NotFoundException("Identifier \"$id\" is not found."); } public function all(): array { return $this->data; } public function set(array $data): void { $this->data = array_merge($this->data, $data); } #[\Override] public function has(string $id): bool { return array_key_exists($id, $this->data); } }