Skip to content

d4s6/LineNumber

Repository files navigation

Line number

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

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published