https://github.com/siguici/typed
Customize Object-Oriented PHP Variable Types
https://github.com/siguici/typed
oop oriented-object-programming php8 sikessem type-library var-type
Last synced: 6 days ago
JSON representation
Customize Object-Oriented PHP Variable Types
- Host: GitHub
- URL: https://github.com/siguici/typed
- Owner: siguici
- License: mit
- Created: 2022-09-13T01:20:59.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-09-13T02:08:30.000Z (over 2 years ago)
- Last Synced: 2025-04-02T03:16:25.861Z (about 2 months ago)
- Topics: oop, oriented-object-programming, php8, sikessem, type-library, var-type
- Language: PHP
- Homepage: https://packagist.org/packages/sikessem/type
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
***
# Customize Object-Oriented PHP Variable Types
This package allows to define variable types or to declare PHP variables from already existing object types.
## Installation
Using [composer](https://getcomposer.org/), you can install Type with the following command:
```bash
composer require sikessem/type
```## Usage
Define a variable type:
```php
setValue($value);
}protected string $value;
public function setValue(string $value): self {
$this->value = $value;
return $this;
}public function getValue(): string {
return $this->value;
}public function dump(): void {
exit($this->value);
}// The method to define to parse a value
public static function parse(mixed $value): self {
return new self((string)$value);
}
}```
Declare a variable with the defined type:
```php
dump(); // Exit with the string 'Hello'```
## License
This library is distributed under the [](https://opensource.org/licenses/MIT)
## Security Reports
Please send any sensitive issue to [[email protected]](mailto:[email protected]). Thanks!