codemagpie / class-generator
A class generator,Support array to generate class files
1.0.1
2022-05-27 10:00 UTC
Requires
- php: >=7.4
- ext-json: *
- codemagpie/utils: ^1.0
- hyperf/utils: ^2.2
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.1
- phpunit/phpunit: ^9.5
README
Introduction
A class generator, Support array to generate class files
Installation
composer require codemagpie/class-generator --dev
Usage
To use:
$config = new Config( dirname(__DIR__), // project directory path DeclareTypeModel::INNER, // default inner, outer: Will be in the class attribute comments above statement; inner: Inside the class declaration attributes PropertyModel::SMALL_HUMP, // default small_hump, underline: Properties of keys into underline; small_hump: Properties of keys into a small hump Person::class, // The generated object will extend the class [DanceInterface::class], // The generated object will implement this interfaces [PlayTrait::class], // The generated object will use this traits 'Nest', // Nested objects directory suffix '', // default bash path .php-cs-fixer.php, cs-fixer config file ); ClassGeneratorBuilder::create($config)->gen([ 'name' => 'test', 'age' => 12, 'score' => 80.5, 'teacher' => [ 'name' => 'wang', ], 'hobby' => ['ping-pong'], 'choose_classes' => [[ 'name' => 'math', ]], ], 'src/Model', 'Student');
Result: