jeckel-lab/advanced-types

This package is abandoned and no longer maintained. No replacement package was suggested.

Advanced PHP types for DDD projects

Installs: 302

Dependents: 1

Suggesters: 0

Security: 0

Stars: 1

Watchers: 2

Forks: 0

Open Issues: 5

Type:symfony-bundle

0.3.1 2020-06-15 22:30 UTC

README

CircleCI Latest Stable Version Total Downloads Build Status codecov Dependabot Status

Advanced PHP Types

Installation

composer require jeckel-lab/advanced-types

Types

Enum

See documentation of marc-mabe/php-enum.

The only addition is the implementation of JsonSerializable interface to serialize enum as it's value.

Value Object

  • Color
  • DateTimePeriod
  • Email
  • TimeDuration
  • Url

Usage with doctrine

Configure type DBAL:

# config/packages/doctrine.yaml

doctrine:
    dbal:
        types:
            color: JeckelLab\AdvancedTypes\DBAL\Types\ColorType
            email: JeckelLab\AdvancedTypes\DBAL\Types\EmailType
            time_duration: JeckelLab\AdvancedTypes\DBAL\Type\sTimeDurationType
            url: JeckelLab\AdvancedTypes\DBAL\Types\UrlType

Use it in your entity:

<?php

use Doctrine\ORM\Mapping as ORM;
use JeckelLab\Types\ValueObject\TimeDuration;

/**
 * @ORM\Entity(repositoryClass="App\Repository\TimeEntryRepository")
 */
class TimeEntry
{
    // ...

    /**
     * @ORM\Column(type="time_duration", nullable=true)
     * @var TimeDuration|null
     */
    private $duration;

    // ...
}