Download the PHP package actualwave/object without Composer
On this page you can find all versions of the php package actualwave/object. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download actualwave/object
More information about actualwave/object
Files in actualwave/object
Package object
Short Description Non dynamic base Object class with getters/setters implementation
License MIT
Homepage https://github.com/burdiuz/php-object
Informations about the package object
PHP-Object
Non dynamic base object class for PHP. Allows making getters and setters via get*
and set*
methods with public/protected accessor. Not defined properties will throw error.
Installation
Via composer
Usage
Basically instead of shared magic methods __set
, __get
, __isset
, __unset
you can define individual methods for each property:
- get* - get[Property name from upper-case char], for reading property value.
- set* - set[Property name from upper-case char], for setting property new value.
- has* - has[Property name from upper-case char], for checking is property set.
- remove* - remove[Property name from upper-case char], for removing(using
unset()
on it) property.
has*
and remove*
methods have default action and are optional. By default, has*
will always return true
for properties with defined getter and remove*
will try to pass null
into setter.
Instances of MyObject
will be non-dynamic objects with one read-write property property
that can be accessed via $instance->property
and two read-only properties -- hiddenProperty
and its alias data
.
You can change behaviour of your property when isset
/unset
are used via has*
and remove*
methods.
Then check if your property is empty or set it to be empty:
Note: Defining has*
and remove*
methods is optional, but without them you will not be able to define logic for isset()
and unset()
actions over your property. Without them unset/delete property via unset()
just tries to pass null
into property mutator method and even if property set to null
, isset()
will always return true
: