jeckel-lab / advanced-types
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
Requires
- php: ^7.2
- ext-json: *
- beberlei/assert: ^3.2
- jeckel-lab/contract: >=0.1.2
- marc-mabe/php-enum: ^4.1
Requires (Dev)
- d0x2f/clover-merge: ^1.0
- doctrine/dbal: ^2.10
- friends-of-phpspec/phpspec-code-coverage: ^4.3
- fzaninotto/faker: ^1.9
- phpmd/phpmd: ^2.7
- phpro/grumphp: ^0.19.0
- phpspec/phpspec: ^6.1
- phpunit/phpunit: ^8.5
- roave/security-advisories: dev-master
- squizlabs/php_codesniffer: ^3.5
- symfony/form: ^5.0
- symfony/http-kernel: ^4 || ^5
- twig/twig: ^3.0
- vimeo/psalm: ^3.8
Suggests
- doctrine/dbal: Integrate Value Object as doctrine types
This package is auto-updated.
Last update: 2022-03-01 00:32:54 UTC
README
Advanced PHP Types
- Enum (based on marc-mabe/php-enum)
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
- 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; // ... }