voku/value_objects

0.1.0 2023-08-10 22:59 UTC

README

SWUbanner

Build Status codecov.io

Value Objects

A collection of value objects that can help you to write more readable, self-validated and immutable code.

Install with Composer

composer require voku/value_objects

Usage

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 is a prerequisite for running the tests.
composer install
  1. The tests can be executed by running this command from the root directory.
./vendor/bin/phpunit

AbstractHttpProvider methods

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 (Microsoft) for hosting the code and a good infrastructure including Issues-Management, etc.
  • Thanks to IntelliJ as they make the best IDEs for PHP and they gave me an open source license for PhpStorm!
  • Thanks to StyleCI for the simple but powerful code style check.
  • Thanks to PHPStan && Psalm for really great Static analysis tools and for discover bugs in the code!