定制 phprise/common-contract 二次开发

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

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

phprise/common-contract

最新稳定版本:v1.0.0

Composer 安装命令:

composer require phprise/common-contract

包简介

Common contracts to general usage based in OTAKU philosophy

README 文档

README

Common contracts and interfaces for general usage based on the OTAKU philosophy. This library provides a set of standard interfaces to ensure consistent behavior across your value objects and entities, specifically focusing on string transformations and array conversions.

Installation

composer require phprise/common-contract

Available Contracts

This package provides the following interfaces in the Phprise\Common\Contract namespace:

Transformation Interfaces

Interface Method return type Description
Arrayable toArray() array Converts the object to an array representation.
Camelable toCamel() string Converts the object's value to camelCase.
Kebabable toKebab() string Converts the object's value to kebab-case.
Lowerable toLower() string Converts the object's value to lowercase.
Pascalable toPascal() string Converts the object's value to PascalCase.
Snakeable toSnake() string Converts the object's value to snake_case.
Titleable toTitle() string Converts the object's value to Title Case.
Upperable toUpper() string Converts the object's value to UPPERCASE.

Usage Examples

Here is how you might implement these interfaces in a Value Object:

<?php

declare(strict_types=1);

namespace App\Domain\ValueObject;

use Phprise\Common\Contract\Arrayable;
use Phprise\Common\Contract\Snakeable;

final class UserName implements Arrayable, Snakeable
{
    public function __construct(
        private readonly string $firstName,
        private readonly string $lastName
    ) {}

    public function toArray(): array
    {
        return [
            'first_name' => $this->firstName,
            'last_name' => $this->lastName,
        ];
    }

    public function toSnake(): string
    {
        return strtolower($this->firstName . '_' . $this->lastName);
    }
}

Philosophy

We follow The OTAKU Manifesto: Fluid Structure Design.

  1. O - Own your Discipline
  2. T - Tools for Composition
  3. A - Armor the Core
  4. K - Keep Infrastructure Silent
  5. U - Universal Language & Contracts

Please read more about it in PHILOSOPHY.md.

License

MIT License

Contributing

See how to contribute in CONTRIBUTING.md.

Code of Conduct

See our code of conduct in CODE_OF_CONDUCT.md.

Security

See our security policy in SECURITY.md.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固