PHP code example of marekskopal / cycle-decimal

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

    

marekskopal / cycle-decimal example snippets


use Cycle\Annotated\Annotation\Column;
use Cycle\Annotated\Annotation\Entity;
use Cycle\ORM\Parser\Typecast;
use Decimal\Decimal;
use MarekSkopal\Cycle\Decimal\ColumnDecimal;
use MarekSkopal\Cycle\Decimal\DecimalTypecast;

#[Entity(
    typecast: [
        Typecast::class,
        DecimalTypecast::class,
    ]
)]
class MyEntity
{
    #[Column(type: 'decimal(8,2)', typecast: DecimalTypecast::Type)]
    public Decimal $value;
    
    #[Column(type: 'decimal(8,2)', typecast: 'decimal(8,2)')]
    public Decimal $valueWithPrecision;
    
    #[ColumnDecimal(precision: 8, scale: 2)]
    public Decimal $valueWithAttribute;
}