Debian Codegraph @

lib/3rdParty/composer/spomky-labs/pki-framework/src/X501/MatchingRule/StringPrepMatchingRule.php

raw symbols SCIP
1 <?php
2
3 declare(strict_types=1);
4
5 namespace SpomkyLabs\Pki\X501\MatchingRule;
6
7 use SpomkyLabs\Pki\X501\StringPrep\StringPreparer;
8
9 /**
10 * Base class for matching rules employing string preparement semantics.
11 */
12 abstract class StringPrepMatchingRule extends MatchingRule
13 {
14 protected function __construct(
15 private readonly StringPreparer $preparer
16 ) {
17 }
18
19 public function compare(string $assertion, string $value): ?bool
20 {
21 $assertion = $this->preparer->prepare($assertion);
22 $value = $this->preparer->prepare($value);
23 return strcmp($assertion, $value) === 0;
24 }
25 }