Вход Регистрация
Файл: vendor/laravel/framework/src/Illuminate/Container/Attributes/Context.php
Строк: 51
<?php

namespace IlluminateContainerAttributes;

use 
Attribute;
use 
IlluminateContractsContainerContainer;
use 
IlluminateContractsContainerContextualAttribute;
use 
IlluminateLogContextRepository;

#[Attribute(Attribute::TARGET_PARAMETER)]
class Context implements ContextualAttribute
{
    
/**
     * Create a new attribute instance.
     */
    
public function __construct(public string $key, public mixed $default null, public bool $hidden false)
    {
    }

    
/**
     * Resolve the context value.
     *
     * @param  self  $attribute
     * @param  IlluminateContractsContainerContainer  $container
     * @return mixed
     */
    
public static function resolve(self $attributeContainer $container): mixed
    
{
        
$repository $container->make(Repository::class);

        return 
match ($attribute->hidden) {
            
true => $repository->getHidden($attribute->key$attribute->default),
            
false => $repository->get($attribute->key$attribute->default),
        };
    }
}
Онлайн: 3
Реклама