PropertyManager
This page is incomplete |
The Property facade is a laravel facade that provides methods to deal with the management of properties.
Properties
Creating a property
For creating a property there is the createProperty() method. This takes three parameters
Parameter "property"
This parameter could be:
- The instance of a property
- A string, then it could be
- The fully qualified class name (including namespace) of a property
- The name of a class
Parameter "name"
Is a string that gives the name of the property
Parameter "storage"
This parameter could be:
- null then a storage must be defined internally or explicitly via setStorage()
- the instance of a storage
- a string of the fully qualified class name (including namespace) of a storage
- a callable closure. Then a CallbackStorage is created and this closure passed as a callback
Examples:
use Sunhill\Facades\Properties; ... createProperty($property_object,'test'); // Gives the $property_object the name 'test' createProperty(/Namespace/Of/Property/MyProperty, 'test', /Namespace/Of/Storage/MyStorage); // Creates a MyProperty instance, names it 'test' and associates it with a created storage of type 'MyStorage'. createProperty('MyProperty', 'test', $storage_object); // Creates a property of 'MyProperty', names it 'test' and associates $storage_object to it createProperty('MyProperty', 'test', function() { return ['key'=>'value']; }); // Create a property of 'MyProperty', name it 'test', create a CallbackStorage and pass the callback to it. ...
PropertyQuery(): BasicQuery
Creates a property query and returns its instance.
clearRegisteredProperties()
Clears all registered properties
registerProperty(string $property, ?string $alias = null)
Registered a new property to the manager
isPropertyRegistered($property): bool
Returns true, when the given name or class was already registered
getNamespaceOfProperty($property)
Returns the full classname with namespace of the given property
getNameOfProperty($property)
Returns the name of the given property
propertyHasMethod($property, $method)
Testss if the given property has a method with the given name
Units
UnitQuery(): BasicQuery
Creates a UnitQuery and returns its instance.
clearRegisteredUnits()
Clears the currently registered units
registerUnit(string $name, string $unit, string $group, string $basic = , ?callable $calculate_to = null, ?callable $calculate_from = null)
isUnitRegistered(string $property): bool
Returns true if the unit is registered otherwise false
getUnit(string $unit): string
Return the unit of the given unit name
getUnitGroup(string $unit): string
Returns the group of the given unit name
getUnitBasic(string $unit): string
Returns the basic unit name of the given unit name
calculateToBasic(string $unit, float $value): float
Calculates the given $value to the basic unit
calculateFromBasic(string $unit, float $value): float
Calculates the given $value from the basic unit