1. Go to this page and download the library: Download uk/dynamic-properties library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
uk / dynamic-properties example snippets
# use UK\DynamicProperties\ExplicitGetter;
/**
* @property-read string $foo …
* @property-read bool $bar …
*/
class MyClass extends ExplicitGetter
{
private $properties = [
'foo' => 'foo',
'bar' => true
];
public function getFoo() : string
{
return $this->properties[ 'foo' ];
}
public function getBar() : bool
{
return $this->properties[ 'bar' ];
}
}
#
use UK\DynamicProperties\ExplicitGetterSetter;
/**
* @property string $foo …
* @property-read bool $bar …
*/
class MyClass extends ExplicitGetterSetter
{
private $properties = [
'foo' => 'foo',
'bar' => true
];
public function getFoo() : string
{
return $this->properties[ 'foo' ];
}
public function getBar() : bool
{
return $this->properties[ 'bar' ];
}
public function setFoo( string $value ) : MyClass
{
if ( \strlen( $value ) < 1 )
{
throw new \LogicException( 'Foo can not use an empty string' );
}
$this->properties[ 'foo' ] = $value;
return $this;
}
}
public function __construct()
{
// ignore the getBar() method
$this->ignoreGetProperties = [ 'bar' ];
// If the class extends from ExplicitGetterSetter you can also
// Define the getter that should be ignored. e.g.: ignore setFoo()
$this->ignoreSetProperties = [ 'foo' ];
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.