diff --git a/.phpunit.cache/code-coverage/6f76e177da74d8a6947f9e458c43599b b/.phpunit.cache/code-coverage/6f76e177da74d8a6947f9e458c43599b new file mode 100644 index 0000000..ceaccdf --- /dev/null +++ b/.phpunit.cache/code-coverage/6f76e177da74d8a6947f9e458c43599b @@ -0,0 +1 @@ +a:6:{s:9:"classesIn";a:1:{s:26:"FacelessLog\FacelessLogger";a:6:{s:4:"name";s:14:"FacelessLogger";s:14:"namespacedName";s:26:"FacelessLog\FacelessLogger";s:9:"namespace";s:11:"FacelessLog";s:9:"startLine";i:16;s:7:"endLine";i:66;s:7:"methods";a:6:{s:11:"__construct";a:6:{s:10:"methodName";s:11:"__construct";s:9:"signature";s:13:"__construct()";s:10:"visibility";s:6:"public";s:9:"startLine";i:22;s:7:"endLine";i:28;s:3:"ccn";i:1;}s:11:"getInstance";a:6:{s:10:"methodName";s:11:"getInstance";s:9:"signature";s:41:"getInstance(): FacelessLog\FacelessLogger";s:10:"visibility";s:6:"public";s:9:"startLine";i:30;s:7:"endLine";i:36;s:3:"ccn";i:2;}s:11:"addDetector";a:6:{s:10:"methodName";s:11:"addDetector";s:9:"signature";s:119:"addDetector(FacelessLog\Detectors\DetectorInterface $detector, FacelessLog\Anonymizers\AnonymizerInterface $anonymizer)";s:10:"visibility";s:6:"public";s:9:"startLine";i:39;s:7:"endLine";i:43;s:3:"ccn";i:1;}s:21:"clearDefaultDetectors";a:6:{s:10:"methodName";s:21:"clearDefaultDetectors";s:9:"signature";s:23:"clearDefaultDetectors()";s:10:"visibility";s:6:"public";s:9:"startLine";i:46;s:7:"endLine";i:49;s:3:"ccn";i:1;}s:23:"clearDefaultAnonymizers";a:6:{s:10:"methodName";s:23:"clearDefaultAnonymizers";s:9:"signature";s:25:"clearDefaultAnonymizers()";s:10:"visibility";s:6:"public";s:9:"startLine";i:51;s:7:"endLine";i:54;s:3:"ccn";i:1;}s:14:"processMessage";a:6:{s:10:"methodName";s:14:"processMessage";s:9:"signature";s:24:"processMessage($message)";s:10:"visibility";s:6:"public";s:9:"startLine";i:56;s:7:"endLine";i:65;s:3:"ccn";i:3;}}}}s:8:"traitsIn";a:0:{}s:11:"functionsIn";a:0:{}s:14:"linesOfCodeFor";a:3:{s:11:"linesOfCode";i:67;s:18:"commentLinesOfCode";i:0;s:21:"nonCommentLinesOfCode";i:67;}s:15:"ignoredLinesFor";a:1:{i:0;i:16;}s:17:"executableLinesIn";a:16:{i:24;i:4;i:25;i:5;i:26;i:6;i:27;i:7;i:32;i:8;i:33;i:9;i:35;i:10;i:41;i:11;i:42;i:12;i:48;i:13;i:53;i:14;i:58;i:15;i:59;i:16;i:60;i:17;i:61;i:18;i:64;i:19;}} \ No newline at end of file diff --git a/.phpunit.cache/test-results b/.phpunit.cache/test-results index 3d81150..95e8b19 100644 --- a/.phpunit.cache/test-results +++ b/.phpunit.cache/test-results @@ -1 +1 @@ -{"version":1,"defects":{"Unit\\Anonymizers\\CreditCardAnonymizerTest::testAnonymizeCreditCardNumber":7,"Unit\\Anonymizers\\CreditCardAnonymizerTest::testAnonymizeWithDifferentSeparators":8,"Unit\\Anonymizers\\CreditCardAnonymizerTest::testAnonymizeWithoutCreditCardNumber":8,"Unit\\Detectors\\PhoneDetectorTest::testDetectsPhone#5":7},"times":{"Unit\\Anonymizers\\BirthDateAnonymizerTest::testAnonymizeWithDashedDateFormat":0.159,"Unit\\Anonymizers\\BirthDateAnonymizerTest::testAnonymizeWithSlashedDateFormat":0,"Unit\\Anonymizers\\BirthDateAnonymizerTest::testAnonymizeWithoutDate":0,"Unit\\Anonymizers\\CreditCardAnonymizerTest::testAnonymizeCreditCardNumber":0.008,"Unit\\Anonymizers\\CreditCardAnonymizerTest::testAnonymizeWithDifferentSeparators":0,"Unit\\Anonymizers\\CreditCardAnonymizerTest::testAnonymizeWithoutCreditCardNumber":0,"Unit\\Anonymizers\\EmailAnonymizerTest::testAnonymizeEmailAddress":0.008,"Unit\\Anonymizers\\EmailAnonymizerTest::testAnonymizeMultipleEmailAddresses":0,"Unit\\Anonymizers\\EmailAnonymizerTest::testAnonymizeWithoutEmailAddress":0,"Unit\\Anonymizers\\PhoneAnonymizerTest::testAnonymizePhoneNumber":0.009,"Unit\\Anonymizers\\PhoneAnonymizerTest::testAnonymizeMultiplePhoneNumbers":0,"Unit\\Anonymizers\\PhoneAnonymizerTest::testAnonymizeWithoutPhoneNumber":0,"Unit\\Detectors\\BirthDateDetectorTest::testDetectsBrazilianFormatDate":0.014,"Unit\\Detectors\\BirthDateDetectorTest::testDetectsISOFormatDate":0,"Unit\\Detectors\\BirthDateDetectorTest::testDetectsDate#with pt-br date":0.019,"Unit\\Detectors\\BirthDateDetectorTest::testDetectsDate#with iso date":0,"Unit\\Detectors\\BirthDateDetectorTest::testDetectsDate#without date":0,"Unit\\Detectors\\BirthDateDetectorTest::testDetectsDate#without iso date":0,"Unit\\Detectors\\CreditCardDetectorTest::testDetectsCreditCard#0":0.009,"Unit\\Detectors\\CreditCardDetectorTest::testDetectsCreditCard#1":0,"Unit\\Detectors\\CreditCardDetectorTest::testDetectsCreditCard#2":0,"Unit\\Detectors\\CreditCardDetectorTest::testDetectsCreditCard#3":0,"Unit\\Detectors\\CreditCardDetectorTest::testDetectsCreditCard#4":0,"Unit\\Detectors\\CreditCardDetectorTest::testDetectsCreditCard#5":0,"Unit\\Detectors\\CreditCardDetectorTest::testDetectsCreditCard#6":0,"Unit\\Detectors\\EmailDetectorTest::testDetectsEmail#0":0.009,"Unit\\Detectors\\EmailDetectorTest::testDetectsEmail#1":0,"Unit\\Detectors\\EmailDetectorTest::testDetectsEmail#2":0,"Unit\\Detectors\\EmailDetectorTest::testDetectsEmail#3":0,"Unit\\Detectors\\PhoneDetectorTest::testDetectsPhone#0":0.009,"Unit\\Detectors\\PhoneDetectorTest::testDetectsPhone#1":0,"Unit\\Detectors\\PhoneDetectorTest::testDetectsPhone#2":0,"Unit\\Detectors\\PhoneDetectorTest::testDetectsPhone#3":0,"Unit\\Detectors\\PhoneDetectorTest::testDetectsPhone#4":0,"Unit\\Detectors\\PhoneDetectorTest::testDetectsPhone#5":0}} \ No newline at end of file +{"version":1,"defects":{"Unit\\Anonymizers\\CreditCardAnonymizerTest::testAnonymizeCreditCardNumber":7,"Unit\\Anonymizers\\CreditCardAnonymizerTest::testAnonymizeWithDifferentSeparators":8,"Unit\\Anonymizers\\CreditCardAnonymizerTest::testAnonymizeWithoutCreditCardNumber":8,"Unit\\Detectors\\PhoneDetectorTest::testDetectsPhone#5":7,"Unit\\FacelessLoggerTest::testSingletonInstance":8,"Unit\\FacelessLoggerTest::testAddAndProcessDetectorAnonymizer":8,"Unit\\FacelessLoggerTest::testClearDefaultDetectors":8,"Unit\\FacelessLoggerTest::testClearDefaultAnonymizers":8,"Unit\\FacelessLoggerTest::testProcessMessageWithNoDetectors":8},"times":{"Unit\\Anonymizers\\BirthDateAnonymizerTest::testAnonymizeWithDashedDateFormat":0.17,"Unit\\Anonymizers\\BirthDateAnonymizerTest::testAnonymizeWithSlashedDateFormat":0,"Unit\\Anonymizers\\BirthDateAnonymizerTest::testAnonymizeWithoutDate":0,"Unit\\Anonymizers\\CreditCardAnonymizerTest::testAnonymizeCreditCardNumber":0.008,"Unit\\Anonymizers\\CreditCardAnonymizerTest::testAnonymizeWithDifferentSeparators":0,"Unit\\Anonymizers\\CreditCardAnonymizerTest::testAnonymizeWithoutCreditCardNumber":0,"Unit\\Anonymizers\\EmailAnonymizerTest::testAnonymizeEmailAddress":0.008,"Unit\\Anonymizers\\EmailAnonymizerTest::testAnonymizeMultipleEmailAddresses":0,"Unit\\Anonymizers\\EmailAnonymizerTest::testAnonymizeWithoutEmailAddress":0,"Unit\\Anonymizers\\PhoneAnonymizerTest::testAnonymizePhoneNumber":0.008,"Unit\\Anonymizers\\PhoneAnonymizerTest::testAnonymizeMultiplePhoneNumbers":0,"Unit\\Anonymizers\\PhoneAnonymizerTest::testAnonymizeWithoutPhoneNumber":0,"Unit\\Detectors\\BirthDateDetectorTest::testDetectsBrazilianFormatDate":0.014,"Unit\\Detectors\\BirthDateDetectorTest::testDetectsISOFormatDate":0,"Unit\\Detectors\\BirthDateDetectorTest::testDetectsDate#with pt-br date":0.018,"Unit\\Detectors\\BirthDateDetectorTest::testDetectsDate#with iso date":0,"Unit\\Detectors\\BirthDateDetectorTest::testDetectsDate#without date":0,"Unit\\Detectors\\BirthDateDetectorTest::testDetectsDate#without iso date":0,"Unit\\Detectors\\CreditCardDetectorTest::testDetectsCreditCard#0":0.008,"Unit\\Detectors\\CreditCardDetectorTest::testDetectsCreditCard#1":0,"Unit\\Detectors\\CreditCardDetectorTest::testDetectsCreditCard#2":0,"Unit\\Detectors\\CreditCardDetectorTest::testDetectsCreditCard#3":0,"Unit\\Detectors\\CreditCardDetectorTest::testDetectsCreditCard#4":0,"Unit\\Detectors\\CreditCardDetectorTest::testDetectsCreditCard#5":0,"Unit\\Detectors\\CreditCardDetectorTest::testDetectsCreditCard#6":0,"Unit\\Detectors\\EmailDetectorTest::testDetectsEmail#0":0.008,"Unit\\Detectors\\EmailDetectorTest::testDetectsEmail#1":0,"Unit\\Detectors\\EmailDetectorTest::testDetectsEmail#2":0,"Unit\\Detectors\\EmailDetectorTest::testDetectsEmail#3":0,"Unit\\Detectors\\PhoneDetectorTest::testDetectsPhone#0":0.008,"Unit\\Detectors\\PhoneDetectorTest::testDetectsPhone#1":0,"Unit\\Detectors\\PhoneDetectorTest::testDetectsPhone#2":0,"Unit\\Detectors\\PhoneDetectorTest::testDetectsPhone#3":0,"Unit\\Detectors\\PhoneDetectorTest::testDetectsPhone#4":0,"Unit\\Detectors\\PhoneDetectorTest::testDetectsPhone#5":0,"Unit\\FacelessLoggerTest::testSingletonInstance":0.465,"Unit\\FacelessLoggerTest::testAddAndProcessDetectorAnonymizer":0,"Unit\\FacelessLoggerTest::testClearDefaultDetectors":0.008,"Unit\\FacelessLoggerTest::testClearDefaultAnonymizers":0,"Unit\\FacelessLoggerTest::testProcessMessageWithNoDetectors":0}} \ No newline at end of file diff --git a/Anonymizers/AnonymizerInterface.php.html b/Anonymizers/AnonymizerInterface.php.html index de94ea6..984bf41 100644 --- a/Anonymizers/AnonymizerInterface.php.html +++ b/Anonymizers/AnonymizerInterface.php.html @@ -80,7 +80,7 @@

Legend

Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable

- Generated by php-code-coverage 10.1.10 using PHP 8.2.14 and PHPUnit 10.5.5 at Sun Dec 31 21:41:09 UTC 2023. + Generated by php-code-coverage 10.1.10 using PHP 8.2.14 and PHPUnit 10.5.5 at Sun Dec 31 21:48:12 UTC 2023.

diff --git a/Anonymizers/BirthDateAnonymizer.php.html b/Anonymizers/BirthDateAnonymizer.php.html index 715440d..0c59225 100644 --- a/Anonymizers/BirthDateAnonymizer.php.html +++ b/Anonymizers/BirthDateAnonymizer.php.html @@ -151,7 +151,7 @@

Legend

Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable

- Generated by php-code-coverage 10.1.10 using PHP 8.2.14 and PHPUnit 10.5.5 at Sun Dec 31 21:41:09 UTC 2023. + Generated by php-code-coverage 10.1.10 using PHP 8.2.14 and PHPUnit 10.5.5 at Sun Dec 31 21:48:12 UTC 2023.

diff --git a/Anonymizers/CreditCardAnonymizer.php.html b/Anonymizers/CreditCardAnonymizer.php.html index 60c4390..920f2be 100644 --- a/Anonymizers/CreditCardAnonymizer.php.html +++ b/Anonymizers/CreditCardAnonymizer.php.html @@ -153,7 +153,7 @@

Legend

Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable

- Generated by php-code-coverage 10.1.10 using PHP 8.2.14 and PHPUnit 10.5.5 at Sun Dec 31 21:41:09 UTC 2023. + Generated by php-code-coverage 10.1.10 using PHP 8.2.14 and PHPUnit 10.5.5 at Sun Dec 31 21:48:12 UTC 2023.

diff --git a/Anonymizers/EmailAnonymizer.php.html b/Anonymizers/EmailAnonymizer.php.html index bb30f6a..c2cef75 100644 --- a/Anonymizers/EmailAnonymizer.php.html +++ b/Anonymizers/EmailAnonymizer.php.html @@ -136,19 +136,19 @@ 6{ 7    public function anonymize(string $message): string 8    { - 9        return preg_replace_callback('/\b([A-Za-z0-9._%+-]+)@([A-Za-z0-9.-]+\.[A-Z|a-z]{2,})\b/', function ($matches) { - 10            $localPart = $matches[1]; - 11            $domain = $matches[2]; + 9        return preg_replace_callback('/\b([A-Za-z0-9._%+-]+)@([A-Za-z0-9.-]+\.[A-Z|a-z]{2,})\b/', function ($matches) { + 10            $localPart = $matches[1]; + 11            $domain = $matches[2]; 12 - 13            $parts = explode('.', $localPart); - 14            $anonymizedParts = array_map(function ($part) { - 15                return $part[0] . str_repeat('*', strlen($part) - 1); - 16            }, $parts); + 13            $parts = explode('.', $localPart); + 14            $anonymizedParts = array_map(function ($part) { + 15                return $part[0] . str_repeat('*', strlen($part) - 1); + 16            }, $parts); 17 - 18            $anonymizedLocalPart = implode('.', $anonymizedParts); + 18            $anonymizedLocalPart = implode('.', $anonymizedParts); 19 - 20            return $anonymizedLocalPart . '@' . $domain; - 21        }, $message); + 20            return $anonymizedLocalPart . '@' . $domain; + 21        }, $message); 22    } 23} @@ -161,7 +161,7 @@

Legend

Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable

- Generated by php-code-coverage 10.1.10 using PHP 8.2.14 and PHPUnit 10.5.5 at Sun Dec 31 21:41:09 UTC 2023. + Generated by php-code-coverage 10.1.10 using PHP 8.2.14 and PHPUnit 10.5.5 at Sun Dec 31 21:48:12 UTC 2023.

diff --git a/Anonymizers/PhoneAnonymizer.php.html b/Anonymizers/PhoneAnonymizer.php.html index aec0da2..93661ee 100644 --- a/Anonymizers/PhoneAnonymizer.php.html +++ b/Anonymizers/PhoneAnonymizer.php.html @@ -153,7 +153,7 @@

Legend

Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable

- Generated by php-code-coverage 10.1.10 using PHP 8.2.14 and PHPUnit 10.5.5 at Sun Dec 31 21:41:09 UTC 2023. + Generated by php-code-coverage 10.1.10 using PHP 8.2.14 and PHPUnit 10.5.5 at Sun Dec 31 21:48:12 UTC 2023.

diff --git a/Anonymizers/dashboard.html b/Anonymizers/dashboard.html index 18076f0..3df9a93 100644 --- a/Anonymizers/dashboard.html +++ b/Anonymizers/dashboard.html @@ -136,7 +136,7 @@

Project Risks

diff --git a/Anonymizers/index.html b/Anonymizers/index.html index 59686cb..d1740f8 100644 --- a/Anonymizers/index.html +++ b/Anonymizers/index.html @@ -208,7 +208,7 @@

Legend

High: 90% to 100%

- Generated by php-code-coverage 10.1.10 using PHP 8.2.14 and PHPUnit 10.5.5 at Sun Dec 31 21:41:09 UTC 2023. + Generated by php-code-coverage 10.1.10 using PHP 8.2.14 and PHPUnit 10.5.5 at Sun Dec 31 21:48:12 UTC 2023.

diff --git a/Aspect/LogAnonymizerAspect.php.html b/Aspect/LogAnonymizerAspect.php.html index b5f25e4..e569646 100644 --- a/Aspect/LogAnonymizerAspect.php.html +++ b/Aspect/LogAnonymizerAspect.php.html @@ -195,7 +195,7 @@

Legend

Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable

- Generated by php-code-coverage 10.1.10 using PHP 8.2.14 and PHPUnit 10.5.5 at Sun Dec 31 21:41:09 UTC 2023. + Generated by php-code-coverage 10.1.10 using PHP 8.2.14 and PHPUnit 10.5.5 at Sun Dec 31 21:48:12 UTC 2023.

diff --git a/Aspect/dashboard.html b/Aspect/dashboard.html index c8efc50..1bc9a7e 100644 --- a/Aspect/dashboard.html +++ b/Aspect/dashboard.html @@ -139,7 +139,7 @@

Project Risks

diff --git a/Aspect/index.html b/Aspect/index.html index 568adb8..6b85716 100644 --- a/Aspect/index.html +++ b/Aspect/index.html @@ -111,7 +111,7 @@

Legend

High: 90% to 100%

- Generated by php-code-coverage 10.1.10 using PHP 8.2.14 and PHPUnit 10.5.5 at Sun Dec 31 21:41:09 UTC 2023. + Generated by php-code-coverage 10.1.10 using PHP 8.2.14 and PHPUnit 10.5.5 at Sun Dec 31 21:48:12 UTC 2023.

diff --git a/Detectors/BirthDateDetector.php.html b/Detectors/BirthDateDetector.php.html index 4b2d033..84bd69d 100644 --- a/Detectors/BirthDateDetector.php.html +++ b/Detectors/BirthDateDetector.php.html @@ -136,10 +136,10 @@ 6    { 7        public function detect(string $message): bool 8        { - 9            $patternBR = "/\b\d{2}\/\d{2}\/\d{4}\b/"; - 10            $patternISO = "/\b\d{4}-\d{2}-\d{2}\b/"; + 9            $patternBR = "/\b\d{2}\/\d{2}\/\d{4}\b/"; + 10            $patternISO = "/\b\d{4}-\d{2}-\d{2}\b/"; 11 - 12            return preg_match($patternBR, $message) || preg_match($patternISO, $message); + 12            return preg_match($patternBR, $message) || preg_match($patternISO, $message); 13        } 14    } @@ -152,7 +152,7 @@

Legend

Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable

- Generated by php-code-coverage 10.1.10 using PHP 8.2.14 and PHPUnit 10.5.5 at Sun Dec 31 21:41:09 UTC 2023. + Generated by php-code-coverage 10.1.10 using PHP 8.2.14 and PHPUnit 10.5.5 at Sun Dec 31 21:48:12 UTC 2023.

diff --git a/Detectors/CreditCardDetector.php.html b/Detectors/CreditCardDetector.php.html index 6390de6..1d7209c 100644 --- a/Detectors/CreditCardDetector.php.html +++ b/Detectors/CreditCardDetector.php.html @@ -136,7 +136,7 @@ 6{ 7    public function detect(string $message): bool 8    { - 9        return preg_match('/\d{4}[-.\s]?\d{4}[-.\s]?\d{4}[-.\s]?\d{4}/', $message); + 9        return preg_match('/\d{4}[-.\s]?\d{4}[-.\s]?\d{4}[-.\s]?\d{4}/', $message); 10    } 11} @@ -149,7 +149,7 @@

Legend

Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable

- Generated by php-code-coverage 10.1.10 using PHP 8.2.14 and PHPUnit 10.5.5 at Sun Dec 31 21:41:09 UTC 2023. + Generated by php-code-coverage 10.1.10 using PHP 8.2.14 and PHPUnit 10.5.5 at Sun Dec 31 21:48:12 UTC 2023.

diff --git a/Detectors/DetectorInterface.php.html b/Detectors/DetectorInterface.php.html index caf1b43..e96d493 100644 --- a/Detectors/DetectorInterface.php.html +++ b/Detectors/DetectorInterface.php.html @@ -80,7 +80,7 @@

Legend

Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable

- Generated by php-code-coverage 10.1.10 using PHP 8.2.14 and PHPUnit 10.5.5 at Sun Dec 31 21:41:09 UTC 2023. + Generated by php-code-coverage 10.1.10 using PHP 8.2.14 and PHPUnit 10.5.5 at Sun Dec 31 21:48:12 UTC 2023.

diff --git a/Detectors/EmailDetector.php.html b/Detectors/EmailDetector.php.html index f59cb7e..a44118b 100644 --- a/Detectors/EmailDetector.php.html +++ b/Detectors/EmailDetector.php.html @@ -136,8 +136,8 @@ 6{ 7    public function detect(string $message): bool 8    { - 9        $emailPattern = '/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b/'; - 10        return preg_match($emailPattern, $message) > 0; + 9        $emailPattern = '/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b/'; + 10        return preg_match($emailPattern, $message) > 0; 11    } 12} @@ -150,7 +150,7 @@

Legend

Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable

- Generated by php-code-coverage 10.1.10 using PHP 8.2.14 and PHPUnit 10.5.5 at Sun Dec 31 21:41:09 UTC 2023. + Generated by php-code-coverage 10.1.10 using PHP 8.2.14 and PHPUnit 10.5.5 at Sun Dec 31 21:48:12 UTC 2023.

diff --git a/Detectors/PhoneDetector.php.html b/Detectors/PhoneDetector.php.html index 77b7d0a..1129b8f 100644 --- a/Detectors/PhoneDetector.php.html +++ b/Detectors/PhoneDetector.php.html @@ -136,7 +136,7 @@ 6{ 7    public function detect(string $message): bool 8    { - 9        return preg_match('/\+?\d{1,4}[-.\s]?\(?\d{2,4}\)?[-.\s]?\d{3,4}[-.\s]?\d{4,6}/', $message); + 9        return preg_match('/\+?\d{1,4}[-.\s]?\(?\d{2,4}\)?[-.\s]?\d{3,4}[-.\s]?\d{4,6}/', $message); 10    } 11} @@ -149,7 +149,7 @@

Legend

Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable

- Generated by php-code-coverage 10.1.10 using PHP 8.2.14 and PHPUnit 10.5.5 at Sun Dec 31 21:41:09 UTC 2023. + Generated by php-code-coverage 10.1.10 using PHP 8.2.14 and PHPUnit 10.5.5 at Sun Dec 31 21:48:12 UTC 2023.

diff --git a/Detectors/dashboard.html b/Detectors/dashboard.html index f9233b9..9d0f92d 100644 --- a/Detectors/dashboard.html +++ b/Detectors/dashboard.html @@ -136,7 +136,7 @@

Project Risks

diff --git a/Detectors/index.html b/Detectors/index.html index 9a5a1bb..6b4e161 100644 --- a/Detectors/index.html +++ b/Detectors/index.html @@ -208,7 +208,7 @@

Legend

High: 90% to 100%

- Generated by php-code-coverage 10.1.10 using PHP 8.2.14 and PHPUnit 10.5.5 at Sun Dec 31 21:41:09 UTC 2023. + Generated by php-code-coverage 10.1.10 using PHP 8.2.14 and PHPUnit 10.5.5 at Sun Dec 31 21:48:12 UTC 2023.

diff --git a/FacelessLogger.php.html b/FacelessLogger.php.html index eab7fb8..9ddc4d2 100644 --- a/FacelessLogger.php.html +++ b/FacelessLogger.php.html @@ -42,193 +42,193 @@ - Total -
-
- 0.00% covered (danger) + Total +
+
+ 100.00% covered (success)
-
0.00%
-
0 / 16
-
-
- 0.00% covered (danger) +
100.00%
+
16 / 16
+
+
+ 100.00% covered (success)
-
0.00%
-
0 / 6
- CRAP -
-
- 0.00% covered (danger) +
100.00%
+
6 / 6
+ CRAP +
+
+ 100.00% covered (success)
-
0.00%
-
0 / 1
+
100.00%
+
1 / 1
- FacelessLogger -
-
- 0.00% covered (danger) + FacelessLogger +
+
+ 100.00% covered (success)
-
0.00%
-
0 / 16
-
-
- 0.00% covered (danger) +
100.00%
+
16 / 16
+
+
+ 100.00% covered (success)
-
0.00%
-
0 / 6
- 90 -
-
- 0.00% covered (danger) +
100.00%
+
6 / 6
+ 9 +
+
+ 100.00% covered (success)
-
0.00%
-
0 / 1
+
100.00%
+
1 / 1
-  __construct -
-
- 0.00% covered (danger) +  __construct +
+
+ 100.00% covered (success)
-
0.00%
-
0 / 4
-
-
- 0.00% covered (danger) +
100.00%
+
4 / 4
+
+
+ 100.00% covered (success)
-
0.00%
-
0 / 1
- 2 - +
100.00%
+
1 / 1
+ 1 + -  getInstance -
-
- 0.00% covered (danger) +  getInstance +
+
+ 100.00% covered (success)
-
0.00%
-
0 / 3
-
-
- 0.00% covered (danger) +
100.00%
+
3 / 3
+
+
+ 100.00% covered (success)
-
0.00%
-
0 / 1
- 6 - +
100.00%
+
1 / 1
+ 2 + -  addDetector -
-
- 0.00% covered (danger) +  addDetector +
+
+ 100.00% covered (success)
-
0.00%
-
0 / 2
-
-
- 0.00% covered (danger) +
100.00%
+
2 / 2
+
+
+ 100.00% covered (success)
-
0.00%
-
0 / 1
- 2 - +
100.00%
+
1 / 1
+ 1 + -  clearDefaultDetectors -
-
- 0.00% covered (danger) +  clearDefaultDetectors +
+
+ 100.00% covered (success)
-
0.00%
-
0 / 1
-
-
- 0.00% covered (danger) +
100.00%
+
1 / 1
+
+
+ 100.00% covered (success)
-
0.00%
-
0 / 1
- 2 - +
100.00%
+
1 / 1
+ 1 + -  clearDefaultAnonymizers -
-
- 0.00% covered (danger) +  clearDefaultAnonymizers +
+
+ 100.00% covered (success)
-
0.00%
-
0 / 1
-
-
- 0.00% covered (danger) +
100.00%
+
1 / 1
+
+
+ 100.00% covered (success)
-
0.00%
-
0 / 1
- 2 - +
100.00%
+
1 / 1
+ 1 + -  processMessage -
-
- 0.00% covered (danger) +  processMessage +
+
+ 100.00% covered (success)
-
0.00%
-
0 / 5
-
-
- 0.00% covered (danger) +
100.00%
+
5 / 5
+
+
+ 100.00% covered (success)
-
0.00%
-
0 / 1
- 12 - +
100.00%
+
1 / 1
+ 3 + @@ -254,53 +254,53 @@ 15 16class FacelessLogger 17{ - 18    private static FacelessLogger $instance; + 18    private static ?FacelessLogger $instance = null; 19    private $detectors = []; 20    private $anonymizers = []; 21 22    public function __construct() 23    { - 24        $this->addDetector(new EmailDetector(), new EmailAnonymizer()); - 25        $this->addDetector(new PhoneDetector(), new PhoneAnonymizer()); - 26        $this->addDetector(new CreditCardDetector(), new CreditCardAnonymizer()); - 27        $this->addDetector(new BirthDateDetector(), new BirthDateAnonymizer()); + 24        $this->addDetector(new EmailDetector(), new EmailAnonymizer()); + 25        $this->addDetector(new PhoneDetector(), new PhoneAnonymizer()); + 26        $this->addDetector(new CreditCardDetector(), new CreditCardAnonymizer()); + 27        $this->addDetector(new BirthDateDetector(), new BirthDateAnonymizer()); 28    } 29 - 30    public static function getInstance() + 30    public static function getInstance(): FacelessLogger 31    { - 32        if (self::$instance === null) { - 33            self::$instance = new FacelessLogger(); + 32        if (self::$instance === null) { + 33            self::$instance = new self(); 34        } - 35        return self::$instance; + 35        return self::$instance; 36    } 37 38 39    public function addDetector(DetectorInterface $detector, AnonymizerInterface $anonymizer) 40    { - 41        $this->detectors[get_class($detector)] = $detector; - 42        $this->anonymizers[get_class($detector)] = $anonymizer; + 41        $this->detectors[get_class($detector)] = $detector; + 42        $this->anonymizers[get_class($detector)] = $anonymizer; 43    } 44 45 46    public function clearDefaultDetectors() 47    { - 48        $this->detectors = []; + 48        $this->detectors = []; 49    } 50 51    public function clearDefaultAnonymizers() 52    { - 53        $this->anonymizers = []; + 53        $this->anonymizers = []; 54    } 55 56    public function processMessage($message) 57    { - 58        foreach ($this->detectors as $detectorClass => $detector) { - 59            if ($detector->detect($message)) { - 60                $anonymizer = $this->anonymizers[$detectorClass]; - 61                $message = $anonymizer->anonymize($message); + 58        foreach ($this->detectors as $detectorClass => $detector) { + 59            if ($detector->detect($message)) { + 60                $anonymizer = $this->anonymizers[$detectorClass]; + 61                $message = $anonymizer->anonymize($message); 62            } 63        } - 64        return $message; + 64        return $message; 65    } 66} @@ -313,7 +313,7 @@

Legend

Covered by small (and larger) testsCovered by medium (and large) testsCovered by large tests (and tests of unknown size)Not coveredNot coverable

- Generated by php-code-coverage 10.1.10 using PHP 8.2.14 and PHPUnit 10.5.5 at Sun Dec 31 21:41:09 UTC 2023. + Generated by php-code-coverage 10.1.10 using PHP 8.2.14 and PHPUnit 10.5.5 at Sun Dec 31 21:48:12 UTC 2023.

diff --git a/coverage.xml b/coverage.xml index a842fad..f37975b 100644 --- a/coverage.xml +++ b/coverage.xml @@ -1,6 +1,6 @@ - - + + @@ -29,17 +29,17 @@ - - - - - - - - - - - + + + + + + + + + + + @@ -70,18 +70,18 @@ - - - - + + + + - - + + @@ -91,47 +91,47 @@ - - - + + + - - + + - + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - + diff --git a/dashboard.html b/dashboard.html index 11baee6..a81c50d 100644 --- a/dashboard.html +++ b/dashboard.html @@ -58,7 +58,6 @@

Insufficient Coverage

FacelessLog\Aspect\LogAnonymizerAspect0% - FacelessLog\FacelessLogger0% @@ -75,7 +74,6 @@

Project Risks

- FacelessLog\FacelessLogger90 @@ -115,12 +113,6 @@

Insufficient Coverage

__construct0% process0% - __construct0% - getInstance0% - addDetector0% - clearDefaultDetectors0% - clearDefaultAnonymizers0% - processMessage0% @@ -137,8 +129,6 @@

Project Risks

- processMessage12 - getInstance6 @@ -148,7 +138,7 @@

Project Risks

@@ -167,7 +157,7 @@

Project Risks

.yAxis.tickFormat(d3.format('d')); d3.select('#classCoverageDistribution svg') - .datum(getCoverageDistributionData([2,0,0,0,0,0,0,0,0,0,0,8], "Class Coverage")) + .datum(getCoverageDistributionData([1,0,0,0,0,0,0,0,0,0,0,9], "Class Coverage")) .transition().duration(500).call(chart); nv.utils.windowResize(chart.update); @@ -185,7 +175,7 @@

Project Risks

.yAxis.tickFormat(d3.format('d')); d3.select('#methodCoverageDistribution svg') - .datum(getCoverageDistributionData([8,0,0,0,0,0,0,0,0,0,0,8], "Method Coverage")) + .datum(getCoverageDistributionData([2,0,0,0,0,0,0,0,0,0,0,14], "Method Coverage")) .transition().duration(500).call(chart); nv.utils.windowResize(chart.update); @@ -235,7 +225,7 @@

Project Risks

chart.yAxis.axisLabel('Cyclomatic Complexity'); d3.select('#classComplexity svg') - .datum(getComplexityData([[100,1,"FacelessLog\\Anonymizers\\BirthDateAnonymizer<\/a>"],[100,1,"FacelessLog\\Anonymizers\\CreditCardAnonymizer<\/a>"],[100,1,"FacelessLog\\Anonymizers\\EmailAnonymizer<\/a>"],[100,1,"FacelessLog\\Anonymizers\\PhoneAnonymizer<\/a>"],[0,2,"FacelessLog\\Aspect\\LogAnonymizerAspect<\/a>"],[100,2,"FacelessLog\\Detectors\\BirthDateDetector<\/a>"],[100,1,"FacelessLog\\Detectors\\CreditCardDetector<\/a>"],[100,1,"FacelessLog\\Detectors\\EmailDetector<\/a>"],[100,1,"FacelessLog\\Detectors\\PhoneDetector<\/a>"],[0,9,"FacelessLog\\FacelessLogger<\/a>"]], 'Class Complexity')) + .datum(getComplexityData([[100,1,"FacelessLog\\Anonymizers\\BirthDateAnonymizer<\/a>"],[100,1,"FacelessLog\\Anonymizers\\CreditCardAnonymizer<\/a>"],[100,1,"FacelessLog\\Anonymizers\\EmailAnonymizer<\/a>"],[100,1,"FacelessLog\\Anonymizers\\PhoneAnonymizer<\/a>"],[0,2,"FacelessLog\\Aspect\\LogAnonymizerAspect<\/a>"],[100,2,"FacelessLog\\Detectors\\BirthDateDetector<\/a>"],[100,1,"FacelessLog\\Detectors\\CreditCardDetector<\/a>"],[100,1,"FacelessLog\\Detectors\\EmailDetector<\/a>"],[100,1,"FacelessLog\\Detectors\\PhoneDetector<\/a>"],[100,9,"FacelessLog\\FacelessLogger<\/a>"]], 'Class Complexity')) .transition() .duration(500) .call(chart); @@ -259,7 +249,7 @@

Project Risks

chart.yAxis.axisLabel('Method Complexity'); d3.select('#methodComplexity svg') - .datum(getComplexityData([[100,1,"
FacelessLog\\Anonymizers\\BirthDateAnonymizer::anonymize<\/a>"],[100,1,"FacelessLog\\Anonymizers\\CreditCardAnonymizer::anonymize<\/a>"],[100,1,"FacelessLog\\Anonymizers\\EmailAnonymizer::anonymize<\/a>"],[100,1,"FacelessLog\\Anonymizers\\PhoneAnonymizer::anonymize<\/a>"],[0,1,"FacelessLog\\Aspect\\LogAnonymizerAspect::__construct<\/a>"],[0,1,"FacelessLog\\Aspect\\LogAnonymizerAspect::process<\/a>"],[100,2,"FacelessLog\\Detectors\\BirthDateDetector::detect<\/a>"],[100,1,"FacelessLog\\Detectors\\CreditCardDetector::detect<\/a>"],[100,1,"FacelessLog\\Detectors\\EmailDetector::detect<\/a>"],[100,1,"FacelessLog\\Detectors\\PhoneDetector::detect<\/a>"],[0,1,"FacelessLog\\FacelessLogger::__construct<\/a>"],[0,2,"FacelessLog\\FacelessLogger::getInstance<\/a>"],[0,1,"FacelessLog\\FacelessLogger::addDetector<\/a>"],[0,1,"FacelessLog\\FacelessLogger::clearDefaultDetectors<\/a>"],[0,1,"FacelessLog\\FacelessLogger::clearDefaultAnonymizers<\/a>"],[0,3,"FacelessLog\\FacelessLogger::processMessage<\/a>"]], 'Method Complexity')) + .datum(getComplexityData([[100,1,"FacelessLog\\Anonymizers\\BirthDateAnonymizer::anonymize<\/a>"],[100,1,"FacelessLog\\Anonymizers\\CreditCardAnonymizer::anonymize<\/a>"],[100,1,"FacelessLog\\Anonymizers\\EmailAnonymizer::anonymize<\/a>"],[100,1,"FacelessLog\\Anonymizers\\PhoneAnonymizer::anonymize<\/a>"],[0,1,"FacelessLog\\Aspect\\LogAnonymizerAspect::__construct<\/a>"],[0,1,"FacelessLog\\Aspect\\LogAnonymizerAspect::process<\/a>"],[100,2,"FacelessLog\\Detectors\\BirthDateDetector::detect<\/a>"],[100,1,"FacelessLog\\Detectors\\CreditCardDetector::detect<\/a>"],[100,1,"FacelessLog\\Detectors\\EmailDetector::detect<\/a>"],[100,1,"FacelessLog\\Detectors\\PhoneDetector::detect<\/a>"],[100,1,"FacelessLog\\FacelessLogger::__construct<\/a>"],[100,2,"FacelessLog\\FacelessLogger::getInstance<\/a>"],[100,1,"FacelessLog\\FacelessLogger::addDetector<\/a>"],[100,1,"FacelessLog\\FacelessLogger::clearDefaultDetectors<\/a>"],[100,1,"FacelessLog\\FacelessLogger::clearDefaultAnonymizers<\/a>"],[100,3,"FacelessLog\\FacelessLogger::processMessage<\/a>"]], 'Method Complexity')) .transition() .duration(500) .call(chart); diff --git a/index.html b/index.html index adfc224..afb133c 100644 --- a/index.html +++ b/index.html @@ -42,31 +42,31 @@ - Total -
-
- 59.18% covered (warning) + Total +
+
+ 91.84% covered (success)
-
59.18%
-
29 / 49
-
-
- 50.00% covered (danger) +
91.84%
+
45 / 49
+
+
+ 87.50% covered (warning)
-
50.00%
-
8 / 16
-
-
- 80.00% covered (warning) +
87.50%
+
14 / 16
+
+
+ 90.00% covered (success)
-
80.00%
-
8 / 10
+
90.00%
+
9 / 10
@@ -154,31 +154,31 @@ -
FacelessLogger.php -
-
- 0.00% covered (danger) + FacelessLogger.php +
+
+ 100.00% covered (success)
-
0.00%
-
0 / 16
-
-
- 0.00% covered (danger) +
100.00%
+
16 / 16
+
+
+ 100.00% covered (success)
-
0.00%
-
0 / 6
-
-
- 0.00% covered (danger) +
100.00%
+
6 / 6
+
+
+ 100.00% covered (success)
-
0.00%
-
0 / 1
+
100.00%
+
1 / 1
@@ -194,7 +194,7 @@

Legend

High: 90% to 100%

- Generated by php-code-coverage 10.1.10 using PHP 8.2.14 and PHPUnit 10.5.5 at Sun Dec 31 21:41:09 UTC 2023. + Generated by php-code-coverage 10.1.10 using PHP 8.2.14 and PHPUnit 10.5.5 at Sun Dec 31 21:48:12 UTC 2023.

diff --git a/phpunit-report.html b/phpunit-report.html index 6eb2500..d95a6ac 100644 --- a/phpunit-report.html +++ b/phpunit-report.html @@ -93,6 +93,14 @@

Email Detector (Unit\Detectors\EmailDetector)

  • Detects email with data set #2
  • Detects email with data set #3
  • +

    Faceless Logger (Unit\FacelessLogger)

    +
      +
    • Singleton instance
    • +
    • Add and process detector anonymizer
    • +
    • Clear default detectors
    • +
    • Clear default anonymizers
    • +
    • Process message with no detectors
    • +

    Phone Anonymizer (Unit\Anonymizers\PhoneAnonymizer)

    • Anonymize phone number
    • diff --git a/src/FacelessLogger.php b/src/FacelessLogger.php index 537b20a..bf46faf 100644 --- a/src/FacelessLogger.php +++ b/src/FacelessLogger.php @@ -15,7 +15,7 @@ class FacelessLogger { - private static FacelessLogger $instance; + private static ?FacelessLogger $instance = null; private $detectors = []; private $anonymizers = []; @@ -27,10 +27,10 @@ public function __construct() $this->addDetector(new BirthDateDetector(), new BirthDateAnonymizer()); } - public static function getInstance() + public static function getInstance(): FacelessLogger { if (self::$instance === null) { - self::$instance = new FacelessLogger(); + self::$instance = new self(); } return self::$instance; } diff --git a/tests/Unit/FacelessLoggerTest.php b/tests/Unit/FacelessLoggerTest.php new file mode 100644 index 0000000..a85da93 --- /dev/null +++ b/tests/Unit/FacelessLoggerTest.php @@ -0,0 +1,75 @@ +logger = FacelessLogger::getInstance(); + } + + public function testSingletonInstance() + { + $logger1 = FacelessLogger::getInstance(); + $logger2 = FacelessLogger::getInstance(); + $this->assertSame($logger1, $logger2); + } + + public function testAddAndProcessDetectorAnonymizer() + { + $email = "test@example.com"; + $anonymizedEmail = "t***@example.com"; + + $this->logger->addDetector(new EmailDetector(), new EmailAnonymizer()); + $result = $this->logger->processMessage($email); + + $this->assertEquals($anonymizedEmail, $result); + } + + public function testClearDefaultDetectors() + { + $this->logger->addDetector(new EmailDetector(), new EmailAnonymizer()); + + $this->logger->clearDefaultDetectors(); + + $detectors = $this->getPrivateProperty($this->logger, 'detectors'); + $this->assertEmpty($detectors); + } + + public function testClearDefaultAnonymizers() + { + $this->logger->addDetector(new EmailDetector(), new EmailAnonymizer()); + + $this->logger->clearDefaultAnonymizers(); + + $anonymizers = $this->getPrivateProperty($this->logger, 'anonymizers'); + $this->assertEmpty($anonymizers); + } + + public function testProcessMessageWithNoDetectors() + { + $this->logger->clearDefaultDetectors(); + + $message = "test@example.com"; + $processedMessage = $this->logger->processMessage($message); + + $this->assertEquals($message, $processedMessage); + } + + private function getPrivateProperty($object, $propertyName) + { + $reflector = new \ReflectionClass($object); + $property = $reflector->getProperty($propertyName); + $property->setAccessible(true); + + return $property->getValue($object); + } +}