Skip to content

Latest commit

 

History

History
163 lines (132 loc) · 2.15 KB

docs.md

File metadata and controls

163 lines (132 loc) · 2.15 KB

API examples

Make an empty file

PHPFile::make()->file('dummy.php')

Make a class

PHPFile::make()->class(\App\Models\Car::class)

Load an existing file

PHPFile::load('app/Models/User.php')

Load an existing class by name

PHPFile::load(\App\Models\User::class)

Make a file from a string

PHPFile::fromString('<?php $hey = 1337;')

Make a file from a pseudo php string

PHPFile::addMissingTags()->fromString('$hey = 1337')

Render file

$file->render()

Save file

Saves a file to disk

$file->save()

Save file to a new location

$file->save('app/helpers.php')

Get class name

$file->className();

Change class name

$file->className('NewName')

Get a class constant

$file->classConstant('HOME')

Set a class constant

$file->classConstant('HOME', '/new/home')

Remove a class constant

$file->remove()->classConstant('HOME')

Get class extends

$file->extends();

Set class extends

$file->extends(SomeBaseClass::class)

Get class implements

$file->implements();

Set class implements

$file->implements([SomeInterface::class])

Get class method names

$file->methodNames()

Get namespace

$file->namespace();

Set class namespace

$file->namespace('New\Namespace')

Get a property

$file->property('table');

Set a property

$file->property('table', 'new_table');

Set property visibility

$file->private()->property('table', 'secret');

Remove property

$file->remove()->property('table');

Clear a property

$file->clear()->property('fillable');

Empty property

$file->empty()->property('fillable');

Add item to array property

$file->add('column')->to()->property('fillable');

Get use statements

$file->use()

Set use statements

$file->use([
	Class1::class,
	Class2::class,
])

Add use statements

$file->add()->use([
	Extra1::class,
	Extra2::class,
])