承接 flux-eco/php-model-class-generator 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

flux-eco/php-model-class-generator

Composer 安装命令:

composer require flux-eco/php-model-class-generator

包简介

Writes model classes from json schema files

README 文档

README

This component creates model classes from json schema files

Functional Usage

accounts.yaml

name: accounts
type: object
properties:
  personId:
    type: integer
  firstname:
    type: string
  lastname:
    type: string
  email:
    type: string
  type:
    type: string
  lastChanged:
    type: string

generateAccounts.php

fluxPhpModelClassGenerator\generateModelClass(
        __DIR__ . '/accounts.yaml',
        'FluxCap\ExampleApp\Core\Domain\Models',
        __DIR__ . '/generated'
);

generates: Accounts.php

<?php
namespace FluxCap\ExampleApp\Core\Domain\Models;

use JsonSerializable;

class Accounts implements JsonSerializable {

	private int $personId;

	private string $firstname;

	private string $lastname;

	private string $email;

	private string $type;

	private string $lastChanged;

	private function __construct(
		int $personId,
		string $firstname,
		string $lastname,
		string $email,
		string $type,
		string $lastChanged,
	) {
		$this->personId = $personId;
		$this->firstname = $firstname;
		$this->lastname = $lastname;
		$this->email = $email;
		$this->type = $type;
		$this->lastChanged = $lastChanged;
	}

	public static function new(
		int $personId,
		string $firstname,
		string $lastname,
		string $email,
		string $type,
		string $lastChanged,
	): self {
		return new self(
			$personId, $firstname, $lastname, $email, $type, $lastChanged
		);
	}

	final public function getPersonId(): int {
		return $this->personId;
	}

	final public function getFirstname(): string {
		return $this->firstname;
	}

	final public function getLastname(): string {
		return $this->lastname;
	}

	final public function getEmail(): string {
		return $this->email;
	}

	final public function getType(): string {
		return $this->type;
	}

	final public function getLastChanged(): string {
		return $this->lastChanged;
	}

	final public function toJson(): string {
		return json_encode($this, JSON_THROW_ON_ERROR);
	}

	final public function toArray(): array {
		return get_object_vars($this);
	}
	final public function jsonSerialize(): array {
		return $this->toArray();
	}
}

Contributing 💜

Please ...

  1. ... register an account at https://git.fluxlabs.ch
  2. ... create pull requests 🔥

Adjustment suggestions / bug reporting 🐾

Please ...

  1. ... register an account at https://git.fluxlabs.ch
  2. ... ask us for a Service Level Agreement: support@fluxlabs.ch 😘
  3. ... read and create issues

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-3.0-only
  • 更新时间: 2022-04-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固