Magrathea PHP 2

CodeManager extends Singleton
in package

Class for handling automatically generated files

Table of Contents

Properties

$instance  : array<string|int, mixed>|null

Methods

__wakeup()  : mixed
GetCodeForAdmin()  : string
GetCodeForApi()  : string
GetCodeForControl()  : string
GetCodeForObject()  : string
GetCodeForObjectBase()  : string
GetCodeForObjectControlBase()  : string
GetFileList()  : array<string|int, mixed>
GetPaths()  : array<string|int, mixed>
Get paths where code will be written
Instance()  : static|Singleton
MockClass()  : static|Singleton
PrepareCodeFileGeneration()  : array<string|int, mixed>
PrepareFolders()  : array<string|int, mixed>
Create Folders for object
PrepareStructureForCodeGeneration()  : array<string|int, mixed>
Get data for generating a code file
SetInstance()  : mixed
WriteCodeFile()  : array<string|int, mixed>
WriteFile()  : array<string|int, mixed>
Writes a file with some content (code, please)
__clone()  : mixed
__construct()  : mixed
AreAllPathsWritable()  : bool
checks if all paths are writable (thanks, ChatGPT)
GetFileDestination()  : string
PrepareFolderPath()  : array<string|int, mixed>
prepares a folder to receive a code file.

Properties

$instance

protected static array<string|int, mixed>|null $instance = []

Methods

GetCodeForAdmin()

public GetCodeForAdmin(mixed $object) : string
Parameters
$object : mixed
Return values
string

GetCodeForApi()

public GetCodeForApi(mixed $object) : string
Parameters
$object : mixed
Return values
string

GetCodeForControl()

public GetCodeForControl(string $object) : string
Parameters
$object : string

object name

Return values
string

code

GetCodeForObject()

public GetCodeForObject(string $object) : string
Parameters
$object : string

object name

Return values
string

code

GetCodeForObjectBase()

public GetCodeForObjectBase(string $object) : string
Parameters
$object : string

object name

Return values
string

code

GetCodeForObjectControlBase()

public GetCodeForObjectControlBase(string $object) : string
Parameters
$object : string

object name

Return values
string

code

GetFileList()

public GetFileList(string $object) : array<string|int, mixed>
Parameters
$object : string

object name

Return values
array<string|int, mixed>

files that will be generated ["file-name", "file-desc", "gen-function"]

GetPaths()

Get paths where code will be written

public GetPaths(string $type, mixed $mainPath) : array<string|int, mixed>
Parameters
$type : string

"feature" or "mvc"

$mainPath : mixed
Return values
array<string|int, mixed>

("type", "app", "paths" => "{code-file-type}" => $path);

PrepareCodeFileGeneration()

public PrepareCodeFileGeneration(mixed $type, string $object) : array<string|int, mixed>
Parameters
$type : mixed
$object : string

object name

Return values
array<string|int, mixed>

["code", "overwritable", "file-exists", "file-destination"]

PrepareFolders()

Create Folders for object

public PrepareFolders(mixed $object) : array<string|int, mixed>
Parameters
$object : mixed
Return values
array<string|int, mixed>

data ["success", "data"]

PrepareStructureForCodeGeneration()

Get data for generating a code file

public PrepareStructureForCodeGeneration(mixed $object) : array<string|int, mixed>
Parameters
$object : mixed
Return values
array<string|int, mixed>

data

SetInstance()

public SetInstance(mixed $inst) : mixed
Parameters
$inst : mixed

WriteCodeFile()

public WriteCodeFile(string $type, string $obj) : array<string|int, mixed>
Parameters
$type : string

file type ("model-base", "control-base", "model", "control")

$obj : string

object name

Return values
array<string|int, mixed>

[ ["success", "file-name", "error?"]* ]

WriteFile()

Writes a file with some content (code, please)

public WriteFile(string $file, string $content[, bool $overwrite = false ]) : array<string|int, mixed>
Parameters
$file : string

file that will be written

$content : string

content to be written

$overwrite : bool = false

should we overwrite whater is in the file?

Return values
array<string|int, mixed>

["success", "error?", "data?"]

__construct()

private final __construct() : mixed

AreAllPathsWritable()

checks if all paths are writable (thanks, ChatGPT)

private AreAllPathsWritable(array<string|int, mixed> $paths) : bool
Parameters
$paths : array<string|int, mixed>
Return values
bool

GetFileDestination()

private GetFileDestination(mixed $type, mixed $destinationPath, mixed $fileData) : string
Parameters
$type : mixed
$destinationPath : mixed
$fileData : mixed
Return values
string

PrepareFolderPath()

prepares a folder to receive a code file.

private PrepareFolderPath(string $path) : array<string|int, mixed>

it creates the folder (or returns true if it already exists) and checks if it is writable

Parameters
$path : string

path

Return values
array<string|int, mixed>

('created', 'exists', 'writable')


        
On this page

Search results