first commit

This commit is contained in:
Sampanna Rimal
2024-08-27 17:48:06 +05:45
commit 53c0140f58
10839 changed files with 1125847 additions and 0 deletions

View File

@ -0,0 +1,45 @@
<?php
/*
* This file is part of the PHPFlasher package.
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
*/
namespace Flasher\Prime\Config;
/**
* @phpstan-import-type ConfigType from ConfigInterface
*/
final class Config implements ConfigInterface
{
/**
* @phpstan-var array{}|ConfigType
*/
private $config;
/**
* @phpstan-param array{}|ConfigType $config
*/
public function __construct(array $config = array())
{
$this->config = $config;
}
/**
* {@inheritdoc}
*/
public function get($key, $default = null)
{
$data = $this->config;
foreach (explode('.', $key) as $segment) {
if (!isset($data[$segment])) { // @phpstan-ignore-line
return $default;
}
$data = $data[$segment];
}
return $data;
}
}

View File

@ -0,0 +1,47 @@
<?php
/*
* This file is part of the PHPFlasher package.
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
*/
namespace Flasher\Prime\Config;
/**
* @phpstan-type ConfigType array{
* default: string,
* root_script: string,
* options: array<string, string>,
* themes: array<string, array{
* view: string,
* styles: string[],
* scripts: string[],
* options: array<string, mixed>,
* }>,
* auto_render: bool,
* auto_translate: bool,
* filter_criteria: array<string, mixed>,
* flash_bag: array{
* enabled: bool,
* mapping: array<string, string[]>,
* },
* presets: array<string, array{
* type: string,
* title: string,
* message: string,
* options: array<string, mixed>,
* }>,
* }
*/
interface ConfigInterface
{
/**
* Returns an attribute.
*
* @param string $key
* @param mixed $default the default value if not found
*
* @return mixed
*/
public function get($key, $default = null);
}