PHP code example of switon / dict

1. Go to this page and download the library: Download switon/dict library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

switon / dict example snippets


use Switon\Dict\Dict;
use Switon\Dict\Attribute\DictValue;

final class OrderStatus extends Dict
{
    public static function typeCode(): ?string
    {
        return 'order.status';
    }
}

final class OrderController
{
    public function updateAction(OrderStatus $status): void
    {
        $code = $status->getItemCode();
        $label = $status->getItemName();
        $value = $status->getValue();
    }
}