Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
4 / 4
CRAP
100.00% covered (success)
100.00%
21 / 21
DelimitAttributeList
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
4 / 4
4
100.00% covered (success)
100.00%
21 / 21
 getDelimitAttributes
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
3 / 3
 getDelimitIDAttribute
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
8 / 8
 getValidFromAttribute
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
5 / 5
 getValidUntilAttribute
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
5 / 5
<?php
declare(strict_types = 1);
namespace Siesta\Model;
use Siesta\Sequencer\UUIDSequencer;
/**
 * @author Gregor Müller
 */
class DelimitAttributeList
{
    const COLUMN_DELIMIT_ID = "_delimitId";
    const COLUMN_VALID_FROM = "_validFrom";
    const COLUMN_VALID_UNTIL = "_validUntil";
    /**
     * @return Attribute[]
     */
    public static function getDelimitAttributes(Entity $entity)
    {
        return [
            self::getDelimitIDAttribute($entity),
            self::getValidFromAttribute($entity),
            self::getValidUntilAttribute($entity)
        ];
    }
    protected static function getDelimitIDAttribute(Entity $entity) : Attribute
    {
        $attribute = new Attribute($entity);
        $attribute->setPhpName(self::COLUMN_DELIMIT_ID);
        $attribute->setPhpType(UUIDSequencer::PHP_TYPE);
        $attribute->setDbType(UUIDSequencer::DB_TYPE);
        $attribute->setIsPrimaryKey(true);
        $attribute->setAutoValue(UUIDSequencer::NAME);
        $attribute->setIsRequired(true);
        return $attribute;
    }
    protected static function getValidFromAttribute(Entity $entity) : Attribute
    {
        $attribute = new Attribute($entity);
        $attribute->setPhpName(self::COLUMN_VALID_FROM);
        $attribute->setPhpType(PHPType::SIESTA_DATE_TIME);
        $attribute->setDbType(DBType::DATETIME);
        return $attribute;
    }
    protected static function getValidUntilAttribute(Entity $entity) : Attribute
    {
        $attribute = new Attribute($entity);
        $attribute->setPhpName(self::COLUMN_VALID_UNTIL);
        $attribute->setPhpType(PHPType::SIESTA_DATE_TIME);
        $attribute->setDbType(DBType::DATETIME);
        return $attribute;
    }
}