feat: adds toHaveLineCountLessThan

This commit is contained in:
Nuno Maduro
2024-07-18 20:43:39 +01:00
parent 135c8a0d46
commit 2e411893d2
5 changed files with 39 additions and 2 deletions

View File

@ -447,6 +447,19 @@ final class Expectation
);
}
/**
* Asserts that the given expectation target to have line count less than the given number.
*/
public function toHaveLineCountLessThan(int $lines): ArchExpectation
{
return Targeted::make(
$this,
fn (ObjectDescription $object): bool => count(file($object->path)) < $lines,
sprintf('to have less than %d lines of code', $lines),
FileLineFinder::where(fn (string $line): bool => str_contains($line, '<?php')),
);
}
/**
* Asserts that the given expectation target use the "declare(strict_types=1)" declaration.
*/

View File

@ -88,6 +88,14 @@ final class OppositeExpectation
);
}
/**
* Not supported.
*/
public function toHaveLineCountLessThan(): ArchExpectation
{
throw InvalidExpectation::fromMethods(['not', 'toHaveLineCountLessThan']);
}
/**
* Asserts that the given expectation target does not use the "declare(strict_types=1)" declaration.
*/