https://github.com/voku/value_objects
https://github.com/voku/value_objects
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/voku/value_objects
- Owner: voku
- License: mit
- Created: 2023-08-09T00:37:58.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-04-15T10:29:25.000Z (6 months ago)
- Last Synced: 2025-04-29T22:24:37.400Z (6 months ago)
- Language: PHP
- Size: 77.1 KB
- Stars: 7
- Watchers: 3
- Forks: 0
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
[//]: # (AUTO-GENERATED BY "PHP README Helper": base file -> docs/base.md)
[](https://github.com/vshymanskyy/StandWithUkraine/blob/main/docs/README.md)[](https://github.com/voku/value_objects/actions)
[](http://codecov.io/github/voku/value_objects?branch=main)# Value Objects
A collection of value objects that can help you to write more readable,
self-validated and immutable code.### Install with Composer
```shell
composer require voku/value_objects
```### Usage
```php
use voku\ValueObjects\ValueObjectVatPercentage;require_once __DIR__ . '/vendor/autoload.php'; // example path
$vat = ValueObjectVatPercentage::create('16.0');
$vat->getGross(10.0)); // '11.6'
```### Unit Tests
1) [Composer](https://getcomposer.org) is a prerequisite for running the tests.
```shell
composer install
```2) The tests can be executed by running this command from the root directory.
```shell
./vendor/bin/phpunit
```## AbstractHttpProvider methods
create
createEmpty
decryptFromString
encrypt
jsonSerialize
value
valueOrFallback
valueOrThrowException## create(\TCreateValue|null $value): static
↑**Parameters:**
- `\TCreateValue|null $value`**Return:**
- `static`--------
## createEmpty(): static
↑**Parameters:**
__nothing__**Return:**
- `static`--------
## decryptFromString(string $password, string $data): static
↑**Parameters:**
- `string $password`
- `string $data`**Return:**
- `static`--------
## encrypt(string $password):
↑**Parameters:**
- `string $password`**Return:**
- `string`--------
## jsonSerialize(): string
↑**Parameters:**
__nothing__**Return:**
- `string`--------
## value(): TValue|null
↑
Get the value that are used for the database.**Parameters:**
__nothing__**Return:**
- `\TValue|null`--------
## valueOrFallback(\TValueFallback $fallback): TValue|\TValueFallback
↑**Parameters:**
- `\TValueFallback $fallback`**Return:**
- `\TValue|\TValueFallback`--------
## valueOrThrowException(): TValue
↑**Parameters:**
__nothing__**Return:**
- `\TValue`--------
### Thanks
- Thanks to [GitHub](https://github.com) (Microsoft) for hosting the code and a good infrastructure including Issues-Management, etc.
- Thanks to [IntelliJ](https://www.jetbrains.com) as they make the best IDEs for PHP and they gave me an open source license for PhpStorm!
- Thanks to [StyleCI](https://styleci.io/) for the simple but powerful code style check.
- Thanks to [PHPStan](https://github.com/phpstan/phpstan) && [Psalm](https://github.com/vimeo/psalm) for really great Static analysis tools and for discover bugs in the code!