Skip to content

Commit

Permalink
Small improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
Piagrammist committed Oct 3, 2024
1 parent 0865668 commit 522a40f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
19 changes: 3 additions & 16 deletions src/Ini/EntryManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
use ReflectionProperty;
use ReflectionAttribute;

use EasyIni\Lang;
use function EasyIni\camelToSnake;

abstract class EntryManager implements JsonSerializable
{
private ?string $namespace = null;
protected static ?string $namespace = null;

/** Instantiates all props with the `Entry` attribute. */
public function __construct()
Expand All @@ -28,25 +27,13 @@ public function __construct()
if (!$entry->getName()) {
$entry->setName(camelToSnake($property->getName()));
}
if ($this->namespace) {
$entry->setNamespace($this->namespace);
if (static::$namespace) {
$entry->setNamespace(static::$namespace);
}
$this->{$property->name} = $entry;
}
}

/**
* Sets the entries' prefix/namespace.
* ! Must be called before `__construct()`
*/
protected function setNamespace(string $namespace): void
{
if ($namespace === '') {
throw new \InvalidArgumentException(Lang::get('err_namespace_empty'));
}
$this->namespace = $namespace;
}

protected function setEntry(
Entry &$prop,
mixed $value = null,
Expand Down
3 changes: 2 additions & 1 deletion src/Options/JitOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

final class JitOptions extends EntryManager
{
protected static ?string $namespace = 'opcache';

#[Entry]
protected Entry $enable;

Expand All @@ -38,7 +40,6 @@ final class JitOptions extends EntryManager

public function __construct()
{
$this->setNamespace('opcache');
parent::__construct();

$this->flags->setValue('tracing');
Expand Down

0 comments on commit 522a40f

Please sign in to comment.