davidschwarz/line-number

Line numbers as immutable value objects. With a WeakMap based repository in the background.

Installs: 0

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:value-object

v1.0.3 2023-01-18 20:27 UTC

This package is auto-updated.

Last update: 2024-04-18 23:24:25 UTC


README

Line numbers as immutable value objects.
With a WeakMap based repository in the background.

installation

composer require davidschwarz/line-number

example

require __DIR__ . '/vendor/autoload.php';

use DavidSchwarz\LineNumber\Line;

$startLine = Line::number(0);
$otherLine = $startLine->add(2);

$otherLine->equals($startLine); // FALSE
$otherLine->equals(2);          // TRUE

(string) Line::number(7);       // '7'
Line::number(7)->i;             // 7

Line::number(-1);               // throws ...\NegativeValueError

Line::number(0)->subtract(2);   // throws ...\NegativeResultError

license

MIT License

author

David Schwarz / Ringsdorf