Loheide-eu-mitarbeiterplatt.../vendor/league/uri-components/Components/FragmentDirectives/GenericDirective.php
Friederich Loheide 9c0f8de791
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m14s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m7s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m19s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 1m32s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 1m22s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 1m32s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 1m35s
CI / Build-Artefakte aktuell (pull_request) Failing after 1m7s
Phase 0: Fundament für Inhaus
- Laravel 13 mit Filament 5 (Admin), Inertia 3 + Vue 3 + Vuetify 4 (Material 3)
- Anmeldung über Fortify (Login, Passwort vergessen/ändern), keine Selbstregistrierung
- Profil mit Profilbild (WebP in festen Größen), Personenseiten, Header mit Avatar-Menü
- Material-3-Farbschema aus der Primärfarbe, hell/dunkel/System pro Person
- Basis-Branding (Portalname, Logo, Primärfarbe) im Admin unter „Erscheinungsbild“
- Benutzerverwaltung im Admin, Zugang vorläufig über is_admin
- vendor/ (ohne Dev-Pakete) und Frontend-Build mitversioniert, Dev-Pakete in vendor-dev/
- PHPUnit-Tests gegen MySQL/MariaDB, Forgejo-CI-Matrix, Docker-Entwicklungsumgebung
- VERSION, CHANGELOG.md und CONTRIBUTING.md mit Release-Ablauf

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-25 20:35:30 +00:00

107 lines
2.7 KiB
PHP

<?php
/**
* League.Uri (https://uri.thephpleague.com)
*
* (c) Ignace Nyamagana Butera <nyamsprod@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace League\Uri\Components\FragmentDirectives;
use BackedEnum;
use League\Uri\Contracts\FragmentDirective;
use League\Uri\Encoder;
use League\Uri\Exceptions\SyntaxError;
use League\Uri\StringCoercionMode;
use Stringable;
use Throwable;
use function explode;
use function str_replace;
final class GenericDirective implements FragmentDirective
{
/**
* @param non-empty-string $name
*/
private function __construct(
private readonly string $name,
private readonly ?string $value = null,
) {
}
/**
* Create a new instance from a string without the Directive delimiter (:~:) or a separator (&).
*/
public static function fromString(BackedEnum|Stringable|string $value): self
{
if ($value instanceof BackedEnum) {
$value = (string) $value->value;
}
[$name, $value] = explode('=', (string) $value, 2) + [1 => null];
(null !== $name && '' !== $name && !str_contains($name, '&')) || throw new SyntaxError('The submitted text is not a valid directive.');
return new self($name, $value);
}
private static function decode(?string $value): ?string
{
return null !== $value ? str_replace('%20', ' ', (string) Encoder::decodeFragment($value)) : null;
}
public function name(): string
{
/** @var non-empty-string $name */
$name = (string) self::decode($this->name);
return $name;
}
public function value(): ?string
{
return self::decode($this->value);
}
public function toString(): string
{
$str = $this->name;
if (null === $this->value) {
return $str;
}
return $str.'='.$this->value;
}
public function __toString(): string
{
return $this->toString();
}
public function toFragmentValue(): string
{
return ':~:'.$this->toString();
}
public function equals(mixed $directive): bool
{
if (null === $directive || ! StringCoercionMode::Native->isCoercible($directive)) {
return false;
}
if (!$directive instanceof FragmentDirective) {
try {
$directive = self::fromString((string) StringCoercionMode::Native->coerce($directive));
} catch (Throwable) {
return false;
}
}
return $directive->toString() === $this->toString();
}
}