Skip to content

Commit

Permalink
v1.0.1
Browse files Browse the repository at this point in the history
- add example in README.md
- fix typo NegativeResultError->message
- improve tests
- cleanup
  • Loading branch information
d4s6 committed Jan 15, 2023
1 parent 3113546 commit 1266931
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
9 changes: 0 additions & 9 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
<?php

/*
* This file is part of "genug".
*
* (c) David Schwarz / Ringsdorf
* https://davidschwarz.eu
*
* License: MIT License
*/

use PhpCsFixer\{
Config,
Finder
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ $otherLine->equals($startLine); // FALSE
$otherLine->equals(2); // TRUE

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

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

Expand Down
2 changes: 1 addition & 1 deletion src/NegativeResultError.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ class NegativeResultError extends Error
public function __construct(int $a, string $operator, int $b, int $result, ?Throwable $previous = null)
{
$computation = ''.$a.$operator.$b;
parent::__construct(sprintf('The result "%s of "%s" is less than zero.', $result, $computation), previous: $previous);
parent::__construct(sprintf('The result "%s" of "%s" is less than zero.', $result, $computation), previous: $previous);
}
}
4 changes: 4 additions & 0 deletions tests/LineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ public function testAdd(): void
{
$this->assertSame(7, Line::number(5)->add(2)->i);
$this->assertSame(3, Line::number(5)->add(-2)->i);

$this->assertSame(7, Line::number(5)->add(Line::number(2))->i);
}

public function testErrorOnNegativeSum(): void
Expand All @@ -76,6 +78,8 @@ public function testSubtract(): void
{
$this->assertSame(7, Line::number(9)->subtract(2)->i);
$this->assertSame(7, Line::number(5)->subtract(-2)->i);

$this->assertSame(7, Line::number(9)->subtract(Line::number(2))->i);
}

public function testErrorOnNegativeDifference(): void
Expand Down

0 comments on commit 1266931

Please sign in to comment.