https://github.com/imponeer/properties
PHP library for handling strict type class variables (not yet working)
https://github.com/imponeer/properties
php-library properties
Last synced: 3 months ago
JSON representation
PHP library for handling strict type class variables (not yet working)
- Host: GitHub
- URL: https://github.com/imponeer/properties
- Owner: imponeer
- License: mit
- Created: 2016-11-30T14:56:06.000Z (over 8 years ago)
- Default Branch: main
- Last Pushed: 2025-02-21T09:43:46.000Z (5 months ago)
- Last Synced: 2025-04-16T02:04:54.922Z (3 months ago)
- Topics: php-library, properties
- Language: PHP
- Homepage:
- Size: 165 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: License.txt
Awesome Lists containing this project
README
[](License.txt) [](https://github.com/imponeer/properties/releases) [](https://travis-ci.org/imponeer/properties) [](https://packagist.org/packages/imponeer/properties) [](https://codeclimate.com/github/imponeer/properties/maintainability) [](https://codeclimate.com/github/imponeer/properties/test_coverage)
# Properties
PHP library for handling strict type class variables. This package can be used only for adding functionality for other classes.
## Installation
`composer require imponeer/properties`
## Usage
To add some custom properties support to a class first you need to extend that class. Here is example how to do it:
```php5
use Imponeer\Properties;class Base extends Properties {
}
```
Next thing what you need is to define variables in class constructor. Here an example how to do:
```php5
use Imponeer\Properties;class Base extends Properties {
public function __construct() {
$this->initVar('varA', self::DTYPE_INTEGER, null, false);
$this->initVar('varB', self::DTYPE_STRING, null, true, 150);
$this->initVar('varC', self::DTYPE_INTEGER, 100, false);
}
}
```
Than is possible to use such vars. This would work for previous example in such way:
```php5// Creates instance
$obj = new Base();// Print current objects vars
var_dump($obj->toArray());// Modify vars with some integer values and prints
$obj->varA = 57;
$obj->varB = 58;
$obj->varC = 59;
var_dump($obj->toArray());// Modify vars with some string values and prints
$obj->varA = "A";
$obj->varB = "B";
$obj->varC = "C";
var_dump($obj->toArray());```
## How to contribute?
If you want to add some functionality or fix bugs, you can fork, change and create pull request. If you not sure how this works, try[interactive GitHub tutorial](https://skills.github.com).
If you found any bug or have some questions, use [issues tab](https://github.com/imponeer/properties/issues) and write there your questions.