PHP code example of michael-rubel / laravel-value-objects
1. Go to this page and download the library: Download michael-rubel/laravel-value-objects 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/ */
michael-rubel / laravel-value-objects example snippets
$number = new Number('10.20999', scale: 2);
$number = Number::make('10.20999', scale: 2);
$number = Number::from('10.20999', scale: 2);
$number->value(); // '10.20'
(string) $number; // '10.20'
$number->toArray(); // ['10.20']
// Starting from version `3.5.0` also
// accepts locale-formatted numbers:
$number = new Number('1.230,00');
$number->value(); // '1230.00'
$number = new Number('1,230.00');
$number->value(); // '1230.00'
$number = new Number('1 230,00');
$number->value(); // '1230.00'
$number = new Number('1 230.00');
$number->value(); // '1230.00'
$text = new Text('Lorem Ipsum is simply dummy text.');
$text = Text::make('Lorem Ipsum is simply dummy text.');
$text = Text::from('Lorem Ipsum is simply dummy text.');
$text->value(); // 'Lorem Ipsum is simply dummy text.'
(string) $text; // 'Lorem Ipsum is simply dummy text.'
$text->toArray(); // ['Lorem Ipsum is simply dummy text.']