\Piko

Piko is the helper class for the Piko framework.

Properties summary

Name Description
protected $aliases The aliases container.

Methods summary

Name Description
public configureObject Configure public properties of an object.
public createObject Generic factory method.
public getAlias Translates a path alias into an actual path.
public reset Reset aliases
public setAlias Registers a path alias. A path alias is a short na…

Properties

protected $aliases : string[]

The aliases container.


Methods

public configureObject(): void

public static  configureObject(object  $object, array<string,mixed>  $data = []): void

Configure public properties of an object.

Parameters

$object : The object instance.

$data (default: []): A key-value array corresponding to the public properties of an object.


public createObject(): object

public static  createObject(class-string|array<string,mixed>  $type, array<string,mixed>  $properties = []): object

Generic factory method.

Parameters

$type : The object type. If it is a string, it should be the fully qualified name of the class. If an array given, it must contain the key ‘class’ with the value corresponding to the fully qualified name of the class. It should also contain the key ‘construct’ to give an array of constuctor arguments

$properties (default: []): A key-value paired array corresponding to the object public properties.

Return:

object


public getAlias(): string|bool

public static  getAlias(string  $alias): string|bool

Translates a path alias into an actual path.

Parameters

$alias : The alias to be translated.

Return:

string|bool The path corresponding to the alias. False if the alias is not registered.


public reset(): void

public static  reset(): void

Reset aliases


public setAlias(): void

public static  setAlias(string  $alias, string  $path): void

Registers a path alias. A path alias is a short name representing a long path (a file path, a URL, etc.)

Parameters

$alias : The alias name (e.g. “@web”). It must start with a ‘@’ character.

$path : the path corresponding to the alias.

throws \InvalidArgumentExceptionif $path is an invalid alias.

see \Piko::getAlias()