m2collective/laravel-value-types

Maintainers

Package info

github.com/m2collective/laravel-value-types

pkg:composer/m2collective/laravel-value-types

Transparency log

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

0.1.1 2026-07-31 14:00 UTC

This package is not auto-updated.

Last update: 2026-07-31 20:24:25 UTC


README

Laravel PHP

Installation

You can install the package via composer:

composer require m2collective/laravel-value-types

The package will automatically register itself.

Usage

An example of using a package with the facades:

use Illuminate\View\View;
use M2Collective\ValueTypes\Contracts\ArrayValue;
use M2Collective\ValueTypes\Contracts\StringValue;
use M2Collective\ValueTypes\Facades\ArrayValue as ArrayValueFacade;
use M2Collective\ValueTypes\Facades\StringValue as StringValueFacade;

final class Example 
{
    /**
     * @var ArrayValue 
     */
    protected ArrayValue $title;
    
    /**
     * @var StringValue 
     */
    protected StringValue $subtitle;
    
    /**
     * @param string|null $titleText
     * @param string|null $titleHref
     */
    public function __construct(
        ?string $titleText = null,
        ?string $titleHref = null,
        ?string $subtitle = null
    ) {
        $this->title = ArrayValueFacade::set([
              'href' => $titleHref ?? '#',
              'text' => $titleText ?? 'Text'
        ]);
        
        $this->subtitle = StringValueFacade::set($subtitle ?? 'Subtitle')
    }
    
    /**
     * @return View
     */
    public function render(): View
    {
        return view('example', [
            'title' => $this->title,
            'subtitle' => $this->subtitle,
        ]);
    }
}
<a class="title" href="{{ $title->get('href') }}" title="{{ $title->get('text') }}">
    {{ $title->get('text') }}
</a>
<p class="subtitle">
    {{ $subtitle->get() }}
</p>

License

The MIT License (MIT). Please see the License file for more information.