定制 phariscope/doctrineenumtype 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

phariscope/doctrineenumtype

最新稳定版本:v1.0.0

Composer 安装命令:

composer require phariscope/doctrineenumtype

包简介

A way to create quickly and well tested doctrine type for your php enums

README 文档

README

To persist php enum fields with Doctrine, you have to create doctrine an enum type class for each enum.

To keep it easy and reduce the amount of tests use EnumType.

Installation

composer require phariscope/doctrineenumtype

Usage

Create your enum object as usual. For example:

enum Example: string
{
    case EXAMPLE = 'EXAMPLE';
    case FAKE = 'FAKE';
    case REAL = 'REAL';
}

Create your doctrine enum type test. For example:

class ExampleTypeTest extends TestCase
{
    public function testGetName(): void
    {
        $this->assertEquals('enum_example', (new ExampleType())->getName());
    }

Your production code source will be very short and look like to this:

use Phariscope\DoctrineEnumType\EnumType;

class ExampleType extends EnumType
{
    protected string $name = "enum_example";
    protected string $className = EnumExample::class;
}

Now you can use this new 'ExampleType' with Doctrine ORM.

<field name="myExample" type="enum_example" column="my_example"/>

of course don't forget to declare this new type to doctrine (Type::addType("enum_example", ExampleType::class) somewhere in your application).

To Contribute to phariscope/DoctrineEnumType

Requirements

  • docker
  • git

Install

git clone git@github.com:phariscope/DoctrineEnumType.git
cd DoctrineEnumType
./install

Installation will load php docker image and composer install, so all commands contained in the 'bin' folder will be easily accessbile.

Example:

bin/php -v

Unit test

bin/phpunit

Using Test-Driven Development (TDD) principles (thanks to Kent Beck and others), following good practices (thanks to Uncle Bob and others).

Quality

  • phpcs PSR12
  • phpstan level 9
  • coverage 100%
  • infection MSI >99%

Quick check with:

./codecheck

Check coverage with:

bin/phpunit --coverage-html var

and view 'var/index.html' with your browser

Check infection with:

bin/infection

and view 'var/infection.html' with your browser

统计信息

  • 总下载量: 1.22k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-11-26