classUnit
final class Unit
Public API: explicitly declared with
@visibility public.A complete unit of source text at a stable location, such as a paragraph or a line.
\Requirements\Source\Unit::normalize(" Names\n\tstart with a letter. ") // => 'Names start with a letter.'$unit = new \Requirements\Source\Unit('line:1', 'Names start with a letter.');
strlen($unit->key(new \Requirements\Model\Source('notes', 'notes.txt', 'text', 'lines:1'))) // => 64Properties§
public string $locationpublic string $textMethods§
public function __construct(public string $location, public string $text)Parameters
$location | string | The stable location of the unit within its source |
$text | string | The complete normalized text of the unit |
public function key(Source $source): stringIdentifies the unit by its source URI, format and location.
Parameters
$source | Source | The source the unit belongs to |
Returns
string The SHA-256 hex digest identifying the unitTest cases 16
AnalyzerTest::testAnalyzeKeepsTheValidEvidenceOfAnItemThatClaimsNothingcallsAnalyzerTest::testAnalyzeReadsPinnedSnapshotsUnlessLivecallsAnalyzerTest::testAnalyzeRecordsScopesEvidenceAndClaimscallsAnalyzerTest::testAnalyzeResolvesTheEvidenceOfItemsAfterAnItemWithoutSourcecallsEvidenceMatcherTest::testMatchReadsTheSnapshotUnlessLivecallsEvidenceMatcherTest::testMatchRejectsAPartialQuotationcallsEvidenceMatcherTest::testMatchRejectsAUnitOutsideTheScopecallsEvidenceMatcherTest::testMatchRejectsTheTextOfTheOtherReadingModecallsEvidenceMatcherTest::testMatchReturnsTheKeyOfTheQuotedUnitcallsUnitCollectorTest::testCollectAddsTheSelectedUnitsByKeycallsUnitCollectorTest::testCollectKeepsTheUnitsAddedBeforeARejectedUnitcallsUnitCollectorTest::testCollectListsARepeatedUnitOncecallsUnitCollectorTest::testCollectSharesAUnitBetweenScopesOfTheSameDocumentcallsUnitTest::testKeyDistinguishesUnitscallsUnitTest::testKeyHashesTheUriFormatAndLocationcallsUnitTest::testKeyIgnoresTheIdSelectorAndTextcalls
Calls 1
- function-call
hashline 39
public static function normalize(string $text): stringCollapses whitespace, including no-break spaces, and trims the text.
Parameters
$text | string | The text |
Returns
string The normalized textTest cases 1
UnitTest::testNormalizecalls
Called from 9
- static-call Requirements\Config\Markdown\Citation::selector() packages/requirements/src/Config/Markdown/Citation.php:52
- static-call Requirements\Config\Markdown\Citation::validate() packages/requirements/src/Config/Markdown/Citation.php:79
- static-call Requirements\Report\EvidenceMatcher::match() packages/requirements/src/Report/EvidenceMatcher.php:50
- static-call Requirements\Source\DomSource::select() packages/requirements/src/Source/DomSource.php:81
- static-call Requirements\Source\JsonSource::select() packages/requirements/src/Source/JsonSource.php:47
- static-call Requirements\Source\TextFragment::text() packages/requirements/src/Source/TextFragment.php:43
- static-call Requirements\Source\TextFragment::text() packages/requirements/src/Source/TextFragment.php:46
- static-call Requirements\Source\TextFragment::create() packages/requirements/src/Source/TextFragment.php:58
- static-call Requirements\Source\TextSource::select() packages/requirements/src/Source/TextSource.php:49
Test cases 72§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 4
Other tests reaching this symbol 68
MemorySource::selectcallsCardReaderTestcallsCitationTestcallsQuotationBlocksTestcallsQuotationTestcallsCardWriterTestcallsMarkdownDocumentTestcallsApplicationTestcallsCommandHandlerTestcallsExecutorTestcallsAnalysisTest::testSummaryCountsTheGivenUnitscallsAnalyzerTest::testAnalyzeKeepsTheValidEvidenceOfAnItemThatClaimsNothingcallsAnalyzerTest::testAnalyzeReadsPinnedSnapshotsUnlessLivecallsAnalyzerTest::testAnalyzeRecordsScopesEvidenceAndClaimscallsAnalyzerTest::testAnalyzeResolvesTheEvidenceOfItemsAfterAnItemWithoutSourcecallsClaimsTest::testAssignKeepsOtherSpecificationsWhenOneIsInvalidcallsClaimsTest::testAssignLetsASpecificationClaimTheEvidenceOfTheRequirementsItRefinescallsClaimsTest::testAssignLetsNoRequirementClaimItsOwnEvidencecallsClaimsTest::testAssignOrdersTheUnitsByKeycallsClaimsTest::testAssignRecordsTheEvidenceOfASpecificationcallsClaimsTest::testAssignSkipsASpecificationRefiningARequirementWithInvalidEvidencecallsClaimsTest::testAssignSkipsASpecificationWithInvalidEvidencecallsCoverageTest::testReportAppliesTheDifferentialThresholdToNewAndChangedUnitscallsCoverageTest::testReportAppliesTheOverallThresholdcallsCoverageTest::testReportAppliesTheSourceThresholdscallsCoverageTest::testReportDescribesEveryUnitAndPassesWithoutGatescallsCoverageTest::testReportRejectsRemovedUnitsUnlessAllowedcallsCoverageTest::testReportSkipsTheDifferentialThresholdWithoutChangedUnitscallsEvidenceMatcherTest::testMatchReadsTheSnapshotUnlessLivecallsEvidenceMatcherTest::testMatchRejectsAPartialQuotationcallsEvidenceMatcherTest::testMatchRejectsAUnitOutsideTheScopecallsEvidenceMatcherTest::testMatchRejectsTheTextOfTheOtherReadingModecallsEvidenceMatcherTest::testMatchReturnsTheKeyOfTheQuotedUnitcallsSnapshotTest::testCompareListsNewAndChangedUnitsAndRemovedKeyscallsSnapshotTest::testCreateListsTheFingerprintOfEveryUnitcallsSourceUnitTest::testFingerprintChangesWithTheRefinedRequirementRecordcallsSourceUnitTest::testFingerprintHashesClaimsAndRefinedRequirementsByIDcallsSourceUnitTest::testFingerprintHashesTheTextWithoutClaimscallsSourceUnitTest::testFingerprintIgnoresTheOrderOfClaimscallsSourceUnitTest::testSupportedIsFalseWithOnlyUnsupportedClaimscallsSourceUnitTest::testSupportedIsFalseWithoutClaimscallsSourceUnitTest::testSupportedIsTrueWhenAnyClaimIsSupportedcallsSourceUnitTest::testToArrayReportsAnUncoveredUnitcallsSourceUnitTest::testToArrayReportsAnUnsupportedUnitcallsSourceUnitTest::testToArrayReportsASupportedUnitcallsUnitCollectorTest::testCollectAcceptsUnitsThatDoNotOverlapcallsUnitCollectorTest::testCollectAddsTheSelectedUnitsByKeycallsUnitCollectorTest::testCollectKeepsTheUnitsAddedBeforeARejectedUnitcallsUnitCollectorTest::testCollectListsARepeatedUnitOncecallsUnitCollectorTest::testCollectRejectsABlankUnitcallsUnitCollectorTest::testCollectRejectsAncestorsAndDescendantsAcrossScopescallsUnitCollectorTest::testCollectRejectsConflictingTextOfTheSameUnitcallsUnitCollectorTest::testCollectSharesAUnitBetweenScopesOfTheSameDocumentcallsUnitCollectorTest::testOpenClearsTheUnitKeysOfAReopenedScopecallsDomSourceTest::providerSelectUnitscallsDomSourceTest::testSelectAcceptsSiblingsSharingALocationPrefixcallsDomSourceTest::testSelectDirectiveSelectsEveryUnitWithTheTextcallsDomSourceTest::testSelectStableDistinctUnitscallsJsonSourceTest::providerSelectUnitscallsJsonSourceTest::testSelectReadsThroughTheGivenLoadercallsJsonSourceTest::testSelectStableDistinctUnitscallsRegistryTest::testGetSharesOneLoaderAcrossFormatscallsSourceExtensionTest::testSelectReturnsTheUnitsOfTheScopeOrOfAnEvidenceSelectorcallsTextFragmentTestcallsTextSourceTest::providerSelectUnitscallsTextSourceTest::testSelectReadsThroughTheGivenLoadercallsTextSourceTest::testSelectStableDistinctUnitscallsVerifierTestcalls
Relations§
Instantiated in 3
Static calls 9
- static-call Requirements\Config\Markdown\Citation::selector() packages/requirements/src/Config/Markdown/Citation.php:52
- static-call Requirements\Config\Markdown\Citation::validate() packages/requirements/src/Config/Markdown/Citation.php:79
- static-call Requirements\Report\EvidenceMatcher::match() packages/requirements/src/Report/EvidenceMatcher.php:50
- static-call Requirements\Source\DomSource::select() packages/requirements/src/Source/DomSource.php:81
- static-call Requirements\Source\JsonSource::select() packages/requirements/src/Source/JsonSource.php:47
- static-call Requirements\Source\TextFragment::text() packages/requirements/src/Source/TextFragment.php:43
- static-call Requirements\Source\TextFragment::text() packages/requirements/src/Source/TextFragment.php:46
- static-call Requirements\Source\TextFragment::create() packages/requirements/src/Source/TextFragment.php:58
- static-call Requirements\Source\TextSource::select() packages/requirements/src/Source/TextSource.php:49