Index

MMO\core\code

MMO\core\code · 8 symbols · generated 5 Oct 2026

function

checkName

code.php:257
function checkName(string $name, string $what): string
Namespace
MMO\core\code
$namestring
$whatstringwhat the name is for, in the error message
returnsstring$name, when it is a valid PHP identifier
throwsif it is not
Call graph
function

controller

code.php:137

The source of a new controller class.

function controller(string $class, array $routes = [], string $base = 'aDataController'): string
Namespace
MMO\core\code
$classstringfully-qualified, e.g. App\controllers\WidgetController
$routes = []array
$base = 'aDataController'stringaDataController (routes return plain arrays, sent as JSON) or aController (routes return an iResponse themselves)
returnsstring
throwsfor an invalid name or base
controller('App\controllers\WidgetController', [['name' => 'routeList', 'url' => 'GET|widgets.json']]);
Call graph
function

defaultValue

code.php:63

The PHP literal a property of $type defaults to.

function defaultValue(string $type): string
Namespace
MMO\core\code
$typestringas returned by propertyType
returnsstring
defaultValue('int'); // '0'defaultValue('?string'); // 'null'
Call graph

Used by (1)

function

entity

code.php:89

The source of a new entity class.

function entity( string $class, array $properties = [], array $unique = [], string $base = 'Entity' ): string
Namespace
MMO\core\code
See
Collection::getOrCreateEntity
$classstringfully-qualified, e.g. App\entities\Person
$properties = []array
$unique = []arraythe property (or properties, for a compound key) identifying an entity, for
$base = 'Entity'stringEntity (stored in a collection) or EmbeddedEntity (a nested value of another entity)
returnsstring
throwsfor an invalid name or type, or a property Entity already declares
entity('App\entities\Person', [['name' => 'email', 'description' => '@format email']], ['email']);
Call graph
function

propertyType

code.php:47

The type a generated property is declared with: a non-nullable class type becomes nullable, so that the property can default to null (a typed property has to be initialized before it is read, and DateTime $d = null is a compile error).

function propertyType(string $type): string
Namespace
MMO\core\code
$typestringa PHP type, e.g. string, ?int, array, \DateTimeImmutable
returnsstring
throwsif $type is not a plain (optionally nullable) type name
propertyType('int'); // 'int'propertyType('\DateTimeImmutable'); // '?\DateTimeImmutable'
Call graph

Used by (1)

function

splitClass

code.php:28

Split a class name into its namespace and its short name.

function splitClass(string $class): array
Namespace
MMO\core\code
$classstringa class name, with or without its leading \
returnsarraystring, 1: string} [namespace ('' when there is none), short name]
throwsif $class is not a valid class name
splitClass('MMO\core\entities\Entity'); // ['MMO\core\entities', 'Entity']splitClass('Person'); // ['', 'Person']
Call graph
function

test

code.php:191

The source of a first test for a class, for the library's phpunit suite.

function test( string $class, string $testClass, string $kind = 'class', ?string $property = null ): string
Namespace
MMO\core\code
$classstringthe class under test, fully-qualified
$testClassstringthe test class, fully-qualified, e.g. App\tests\entities\TestPerson
$kind = 'class'stringentity (checks it holds its data), controller (checks it declares routes) or class
$property = nullnull | stringfor an entity: a string property to round-trip, if it has one
returnsstring
throwsfor an invalid class name or kind
test('App\entities\Person', 'App\tests\entities\TestPerson', 'entity', 'email');
Call graph