PHP code example of linio / common

1. Go to this page and download the library: Download linio/common 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/ */

    

linio / common example snippets




use Linio\Common\Type\Dictionary;

$dict = new Dictionary(['foo' => 'bar']);

if ($dict->has('foo')) {
    echo $dict->get('foo');
}

echo $dict->get('i_dont_exist'); // null
echo $dict->get('i_dont_exist', 'default'); // default

if ($dict->contains('bar')) {
    echo 'We have a bar value somewhere!';
}




throw new \Linio\Common\Exception\DomainException(
    'ORDER_COULD_NOT_BE_PROCESSED',
    500,
    'The order could not be processed because the processor is not responding'
);



throw new \Linio\Common\Exception\ClientException(
    'ORDER_INCOMPLETE',
    400,
    'The order could not be processed because the request is incomplete'
);



throw new \Linio\Common\Exception\EntityNotFoundException(
    'Customer',
    'b3ed5dec-a152-4f38-8726-4c4628a6fdbd'
);



throw new \Linio\Common\Exception\EntityNotFoundException(
    'Postcode',
    ['region' => 'Region 1', 'municipality' => 'Municipality 1']
);



class CustomerNotFoundException extends \Linio\Common\Exception\EntityNotFoundException
{
    public function __construct(string $identifier)
    {
        parent::__construct('Customer', $identifier, 'CUSTOMER_NOT_FOUND');
    }
}