From b740a51b36539b6d5d316ec82b5252bbc29b4107 Mon Sep 17 00:00:00 2001 From: ananiascactus <150080512+ananiascactus@users.noreply.github.com> Date: Sun, 31 Dec 2023 18:16:51 -0300 Subject: [PATCH] test: adding some unit tests --- .phpunit.cache/test-results | 1 + .phpunit.result.cache | 1 + README.md | 60 + composer.json | 9 +- composer.lock | 1529 ++++++++++++++++- phpunit-report.html | 112 ++ phpunit.xml | 16 + phpunit.xml.bak | 19 + src/Anonymizers/CreditCardAnonymizer.php | 4 +- ...Anonymizer.php => LogAnonymizerAspect.php} | 1 - src/Detectors/BirthDateDetector.php | 14 +- src/Detectors/PhoneDetector.php | 4 +- src/FacelessLogger.php | 37 +- .../Anonymizers/BirthDateAnonymizerTest.php | 36 + .../Anonymizers/CreditCardAnonymizerTest.php | 36 + .../Unit/Anonymizers/EmailAnonymizerTest.php | 36 + .../Unit/Anonymizers/PhoneAnonymizerTest.php | 36 + .../Unit/Detectors/BirthDateDetectorTest.php | 35 + .../Unit/Detectors/CreditCardDetectorTest.php | 38 + tests/Unit/Detectors/EmailDetectorTest.php | 35 + tests/Unit/Detectors/PhoneDetectorTest.php | 37 + 21 files changed, 2047 insertions(+), 49 deletions(-) create mode 100644 .phpunit.cache/test-results create mode 100644 .phpunit.result.cache create mode 100644 phpunit-report.html create mode 100644 phpunit.xml create mode 100644 phpunit.xml.bak rename src/Aspect/{LogAnonymizer.php => LogAnonymizerAspect.php} (99%) create mode 100644 tests/Unit/Anonymizers/BirthDateAnonymizerTest.php create mode 100644 tests/Unit/Anonymizers/CreditCardAnonymizerTest.php create mode 100644 tests/Unit/Anonymizers/EmailAnonymizerTest.php create mode 100644 tests/Unit/Anonymizers/PhoneAnonymizerTest.php create mode 100644 tests/Unit/Detectors/BirthDateDetectorTest.php create mode 100644 tests/Unit/Detectors/CreditCardDetectorTest.php create mode 100644 tests/Unit/Detectors/EmailDetectorTest.php create mode 100644 tests/Unit/Detectors/PhoneDetectorTest.php diff --git a/.phpunit.cache/test-results b/.phpunit.cache/test-results new file mode 100644 index 0000000..b782737 --- /dev/null +++ b/.phpunit.cache/test-results @@ -0,0 +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.081,"Unit\\Anonymizers\\BirthDateAnonymizerTest::testAnonymizeWithSlashedDateFormat":0,"Unit\\Anonymizers\\BirthDateAnonymizerTest::testAnonymizeWithoutDate":0,"Unit\\Anonymizers\\CreditCardAnonymizerTest::testAnonymizeCreditCardNumber":0,"Unit\\Anonymizers\\CreditCardAnonymizerTest::testAnonymizeWithDifferentSeparators":0,"Unit\\Anonymizers\\CreditCardAnonymizerTest::testAnonymizeWithoutCreditCardNumber":0,"Unit\\Anonymizers\\EmailAnonymizerTest::testAnonymizeEmailAddress":0,"Unit\\Anonymizers\\EmailAnonymizerTest::testAnonymizeMultipleEmailAddresses":0,"Unit\\Anonymizers\\EmailAnonymizerTest::testAnonymizeWithoutEmailAddress":0,"Unit\\Anonymizers\\PhoneAnonymizerTest::testAnonymizePhoneNumber":0,"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,"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,"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,"Unit\\Detectors\\EmailDetectorTest::testDetectsEmail#1":0,"Unit\\Detectors\\EmailDetectorTest::testDetectsEmail#2":0,"Unit\\Detectors\\EmailDetectorTest::testDetectsEmail#3":0,"Unit\\Detectors\\PhoneDetectorTest::testDetectsPhone#0":0,"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 diff --git a/.phpunit.result.cache b/.phpunit.result.cache new file mode 100644 index 0000000..dc722a3 --- /dev/null +++ b/.phpunit.result.cache @@ -0,0 +1 @@ +{"version":1,"defects":[],"times":{"Unit\\Anonymizers\\BirthDateAnonymizerTest::testAnonymizeWithDashedDateFormat":0.092,"Unit\\Anonymizers\\BirthDateAnonymizerTest::testAnonymizeWithSlashedDateFormat":0,"Unit\\Anonymizers\\BirthDateAnonymizerTest::testAnonymizeWithoutDate":0}} \ No newline at end of file diff --git a/README.md b/README.md index 42a8104..ee44b64 100644 --- a/README.md +++ b/README.md @@ -14,3 +14,63 @@ Para instalar a biblioteca em seu projeto, utilize o gerenciador de pacotes Comp ```bash composer require ananiaslitz/facelesslog ``` +## Características +- Flexibilidade: Fácil de integrar com qualquer aplicação PHP. +- Configuração Customizável: Suporta configuração personalizada para ativar/desativar detectores e anonimizadores específicos. +- Singleton/Factory Pattern: Implementação eficiente para garantir a gestão otimizada de recursos. +- Mapeamento Detector-Anonimizador: Eficiência aprimorada com anonimizadores mapeados para detectores específicos. +- Suporte a Testes Unitários: Compatível com PHPUnit para testes confiáveis e robustos. +- Logging de Erros e Exceções: Registra erros e exceções para manutenção e monitoramento fáceis. +- Documentação e Exemplos: Documentação detalhada e exemplos práticos para facilitar o uso. +- Compatibilidade com Frameworks: Integrações disponíveis para frameworks populares como Laravel e Symfony. +## Configuração +Aqui está um exemplo de como você pode configurar e usar o facelesslog: + +```php +// Exemplo de uso do FacelessLogger +$logger = FacelessLogger::getInstance(); + +// Adicionar detectores e anonimizadores conforme necessário +$logger->addDetector(new EmailDetector(), new EmailAnonymizer()); +// ... + +// Processar uma mensagem +$message = "User email is user@example.com"; +$anonymizedMessage = $logger->processMessage($message); + +echo $anonymizedMessage; // Saída será uma versão anonimizada da mensagem +``` + +## Criação de Detectores e Anonimizadores Customizados +A biblioteca facelesslog foi projetada com flexibilidade em mente, permitindo que os usuários ampliem sua funcionalidade de acordo com suas necessidades específicas. Para criar seus próprios Detectores e Anonimizadores, basta implementar as interfaces DetectorInterface e AnonymizerInterface. + +#### Implementando a DetectorInterface +A DetectorInterface é uma interface simples que requer a implementação do método detect, que retorna um booleano. Este método é responsável por verificar se uma mensagem contém um certo tipo de informação sensível que você deseja detectar. + +```php +class CustomDetector implements DetectorInterface +{ + public function detect(string $message): bool + { + // Lógica para detectar uma informação específica na mensagem + } +} +``` +#### Implementando a AnonymizerInterface +A AnonymizerInterface também é uma interface direta que exige a implementação do método anonymize. Este método deve retornar a mensagem com as informações sensíveis anonimizadas ou ocultadas. +```php +class CustomAnonymizer implements AnonymizerInterface +{ + public function anonymize(string $message): string + { + // Lógica para anonimizar informações sensíveis na mensagem + } +} +``` + +## Contribuição +Sua contribuição é bem-vinda! Se você deseja melhorar a facelesslog, sinta-se à vontade para fazer um fork do repositório e enviar suas pull requests. Para bugs, questões e discussões, por favor, use a seção de issues do GitHub. + +## Licença +Distribuído sob a licença MIT. Veja LICENSE para mais informações. + diff --git a/composer.json b/composer.json index 00bd15f..86c1307 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,8 @@ "type": "library", "require-dev": { "phpunit/php-timer": "^6.0", - "brain/monkey": "^2.6" + "brain/monkey": "^2.6", + "phpunit/phpunit": "^10.5" }, "license": "MIT", "autoload": { @@ -19,7 +20,6 @@ } ], "require": { - "symfony/http-client": "^6.3", "nyholm/psr7": "^1.8", "guzzlehttp/promises": "^2.0", @@ -35,5 +35,8 @@ "allow-plugins": { "php-http/discovery": true } - } + }, + "scripts": { + "test": "phpctl phpunit" + } } diff --git a/composer.lock b/composer.lock index df6ab2f..9ed87e9 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "855d222139189052c7935abdf15cdcee", + "content-hash": "71937a98bd8a5e1ee2371cb9dd39f1fe", "packages": [ { "name": "doctrine/instantiator", @@ -3584,17 +3584,265 @@ "time": "2023-08-09T00:03:52+00:00" }, { - "name": "phpunit/php-timer", - "version": "6.0.0", + "name": "myclabs/deep-copy", + "version": "1.11.1", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "e2a2d67966e740530f4a3343fe2e030ffdc1161d" + "url": "https://github.com/myclabs/DeepCopy.git", + "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/e2a2d67966e740530f4a3343fe2e030ffdc1161d", - "reference": "e2a2d67966e740530f4a3343fe2e030ffdc1161d", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", + "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "conflict": { + "doctrine/collections": "<1.6.8", + "doctrine/common": "<2.13.3 || >=3,<3.2.2" + }, + "require-dev": { + "doctrine/collections": "^1.6.8", + "doctrine/common": "^2.13.3 || ^3.2.2", + "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13" + }, + "type": "library", + "autoload": { + "files": [ + "src/DeepCopy/deep_copy.php" + ], + "psr-4": { + "DeepCopy\\": "src/DeepCopy/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Create deep copies (clones) of your objects", + "keywords": [ + "clone", + "copy", + "duplicate", + "object", + "object graph" + ], + "support": { + "issues": "https://github.com/myclabs/DeepCopy/issues", + "source": "https://github.com/myclabs/DeepCopy/tree/1.11.1" + }, + "funding": [ + { + "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", + "type": "tidelift" + } + ], + "time": "2023-03-08T13:26:56+00:00" + }, + { + "name": "phar-io/manifest", + "version": "2.0.3", + "source": { + "type": "git", + "url": "https://github.com/phar-io/manifest.git", + "reference": "97803eca37d319dfa7826cc2437fc020857acb53" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/97803eca37d319dfa7826cc2437fc020857acb53", + "reference": "97803eca37d319dfa7826cc2437fc020857acb53", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-phar": "*", + "ext-xmlwriter": "*", + "phar-io/version": "^3.0.1", + "php": "^7.2 || ^8.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", + "support": { + "issues": "https://github.com/phar-io/manifest/issues", + "source": "https://github.com/phar-io/manifest/tree/2.0.3" + }, + "time": "2021-07-20T11:28:43+00:00" + }, + { + "name": "phar-io/version", + "version": "3.2.1", + "source": { + "type": "git", + "url": "https://github.com/phar-io/version.git", + "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/version/zipball/4f7fd7836c6f332bb2933569e566a0d6c4cbed74", + "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Library for handling version information and constraints", + "support": { + "issues": "https://github.com/phar-io/version/issues", + "source": "https://github.com/phar-io/version/tree/3.2.1" + }, + "time": "2022-02-21T01:04:05+00:00" + }, + { + "name": "phpunit/php-code-coverage", + "version": "10.1.10", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "599109c8ca6bae97b23482d557d2874c25a65e59" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/599109c8ca6bae97b23482d557d2874c25a65e59", + "reference": "599109c8ca6bae97b23482d557d2874c25a65e59", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-libxml": "*", + "ext-xmlwriter": "*", + "nikic/php-parser": "^4.15", + "php": ">=8.1", + "phpunit/php-file-iterator": "^4.0", + "phpunit/php-text-template": "^3.0", + "sebastian/code-unit-reverse-lookup": "^3.0", + "sebastian/complexity": "^3.0", + "sebastian/environment": "^6.0", + "sebastian/lines-of-code": "^2.0", + "sebastian/version": "^4.0", + "theseer/tokenizer": "^1.2.0" + }, + "require-dev": { + "phpunit/phpunit": "^10.1" + }, + "suggest": { + "ext-pcov": "PHP extension that provides line coverage", + "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "10.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "keywords": [ + "coverage", + "testing", + "xunit" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", + "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.10" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-12-11T06:28:43+00:00" + }, + { + "name": "phpunit/php-file-iterator", + "version": "4.1.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "a95037b6d9e608ba092da1b23931e537cadc3c3c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/a95037b6d9e608ba092da1b23931e537cadc3c3c", + "reference": "a95037b6d9e608ba092da1b23931e537cadc3c3c", "shasum": "" }, "require": { @@ -3606,7 +3854,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "6.0-dev" + "dev-main": "4.0-dev" } }, "autoload": { @@ -3625,14 +3873,16 @@ "role": "lead" } ], - "description": "Utility class for timing", - "homepage": "https://github.com/sebastianbergmann/php-timer/", + "description": "FilterIterator implementation that filters files based on a list of suffixes.", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", "keywords": [ - "timer" + "filesystem", + "iterator" ], "support": { - "issues": "https://github.com/sebastianbergmann/php-timer/issues", - "source": "https://github.com/sebastianbergmann/php-timer/tree/6.0.0" + "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", + "security": "https://github.com/sebastianbergmann/php-file-iterator/security/policy", + "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/4.1.0" }, "funding": [ { @@ -3640,13 +3890,1262 @@ "type": "github" } ], - "time": "2023-02-03T06:57:52+00:00" + "time": "2023-08-31T06:24:48+00:00" + }, + { + "name": "phpunit/php-invoker", + "version": "4.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-invoker.git", + "reference": "f5e568ba02fa5ba0ddd0f618391d5a9ea50b06d7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/f5e568ba02fa5ba0ddd0f618391d5a9ea50b06d7", + "reference": "f5e568ba02fa5ba0ddd0f618391d5a9ea50b06d7", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "ext-pcntl": "*", + "phpunit/phpunit": "^10.0" + }, + "suggest": { + "ext-pcntl": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Invoke callables with a timeout", + "homepage": "https://github.com/sebastianbergmann/php-invoker/", + "keywords": [ + "process" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-invoker/issues", + "source": "https://github.com/sebastianbergmann/php-invoker/tree/4.0.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-02-03T06:56:09+00:00" + }, + { + "name": "phpunit/php-text-template", + "version": "3.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "0c7b06ff49e3d5072f057eb1fa59258bf287a748" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/0c7b06ff49e3d5072f057eb1fa59258bf287a748", + "reference": "0c7b06ff49e3d5072f057eb1fa59258bf287a748", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Simple template engine.", + "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "keywords": [ + "template" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-text-template/issues", + "security": "https://github.com/sebastianbergmann/php-text-template/security/policy", + "source": "https://github.com/sebastianbergmann/php-text-template/tree/3.0.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-08-31T14:07:24+00:00" + }, + { + "name": "phpunit/php-timer", + "version": "6.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "e2a2d67966e740530f4a3343fe2e030ffdc1161d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/e2a2d67966e740530f4a3343fe2e030ffdc1161d", + "reference": "e2a2d67966e740530f4a3343fe2e030ffdc1161d", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "6.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", + "keywords": [ + "timer" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-timer/issues", + "source": "https://github.com/sebastianbergmann/php-timer/tree/6.0.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-02-03T06:57:52+00:00" + }, + { + "name": "phpunit/phpunit", + "version": "10.5.5", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "ed21115d505b4b4f7dc7b5651464e19a2c7f7856" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/ed21115d505b4b4f7dc7b5651464e19a2c7f7856", + "reference": "ed21115d505b4b4f7dc7b5651464e19a2c7f7856", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-json": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-xml": "*", + "ext-xmlwriter": "*", + "myclabs/deep-copy": "^1.10.1", + "phar-io/manifest": "^2.0.3", + "phar-io/version": "^3.0.2", + "php": ">=8.1", + "phpunit/php-code-coverage": "^10.1.5", + "phpunit/php-file-iterator": "^4.0", + "phpunit/php-invoker": "^4.0", + "phpunit/php-text-template": "^3.0", + "phpunit/php-timer": "^6.0", + "sebastian/cli-parser": "^2.0", + "sebastian/code-unit": "^2.0", + "sebastian/comparator": "^5.0", + "sebastian/diff": "^5.0", + "sebastian/environment": "^6.0", + "sebastian/exporter": "^5.1", + "sebastian/global-state": "^6.0.1", + "sebastian/object-enumerator": "^5.0", + "sebastian/recursion-context": "^5.0", + "sebastian/type": "^4.0", + "sebastian/version": "^4.0" + }, + "suggest": { + "ext-soap": "To be able to generate mocks based on WSDL files" + }, + "bin": [ + "phpunit" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "10.5-dev" + } + }, + "autoload": { + "files": [ + "src/Framework/Assert/Functions.php" + ], + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "The PHP Unit Testing framework.", + "homepage": "https://phpunit.de/", + "keywords": [ + "phpunit", + "testing", + "xunit" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/phpunit/issues", + "security": "https://github.com/sebastianbergmann/phpunit/security/policy", + "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.5" + }, + "funding": [ + { + "url": "https://phpunit.de/sponsors.html", + "type": "custom" + }, + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpunit/phpunit", + "type": "tidelift" + } + ], + "time": "2023-12-27T15:13:52+00:00" + }, + { + "name": "sebastian/cli-parser", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/cli-parser.git", + "reference": "efdc130dbbbb8ef0b545a994fd811725c5282cae" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/efdc130dbbbb8ef0b545a994fd811725c5282cae", + "reference": "efdc130dbbbb8ef0b545a994fd811725c5282cae", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for parsing CLI options", + "homepage": "https://github.com/sebastianbergmann/cli-parser", + "support": { + "issues": "https://github.com/sebastianbergmann/cli-parser/issues", + "source": "https://github.com/sebastianbergmann/cli-parser/tree/2.0.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-02-03T06:58:15+00:00" + }, + { + "name": "sebastian/code-unit", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit.git", + "reference": "a81fee9eef0b7a76af11d121767abc44c104e503" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/a81fee9eef0b7a76af11d121767abc44c104e503", + "reference": "a81fee9eef0b7a76af11d121767abc44c104e503", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Collection of value objects that represent the PHP code units", + "homepage": "https://github.com/sebastianbergmann/code-unit", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit/issues", + "source": "https://github.com/sebastianbergmann/code-unit/tree/2.0.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-02-03T06:58:43+00:00" + }, + { + "name": "sebastian/code-unit-reverse-lookup", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", + "reference": "5e3a687f7d8ae33fb362c5c0743794bbb2420a1d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/5e3a687f7d8ae33fb362c5c0743794bbb2420a1d", + "reference": "5e3a687f7d8ae33fb362c5c0743794bbb2420a1d", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Looks up which function or method a line of code belongs to", + "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues", + "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/3.0.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-02-03T06:59:15+00:00" + }, + { + "name": "sebastian/comparator", + "version": "5.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "2db5010a484d53ebf536087a70b4a5423c102372" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/2db5010a484d53ebf536087a70b4a5423c102372", + "reference": "2db5010a484d53ebf536087a70b4a5423c102372", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-mbstring": "*", + "php": ">=8.1", + "sebastian/diff": "^5.0", + "sebastian/exporter": "^5.0" + }, + "require-dev": { + "phpunit/phpunit": "^10.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "5.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + } + ], + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "https://github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/comparator/issues", + "security": "https://github.com/sebastianbergmann/comparator/security/policy", + "source": "https://github.com/sebastianbergmann/comparator/tree/5.0.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-08-14T13:18:12+00:00" + }, + { + "name": "sebastian/complexity", + "version": "3.1.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/complexity.git", + "reference": "68cfb347a44871f01e33ab0ef8215966432f6957" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/68cfb347a44871f01e33ab0ef8215966432f6957", + "reference": "68cfb347a44871f01e33ab0ef8215966432f6957", + "shasum": "" + }, + "require": { + "nikic/php-parser": "^4.10", + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for calculating the complexity of PHP code units", + "homepage": "https://github.com/sebastianbergmann/complexity", + "support": { + "issues": "https://github.com/sebastianbergmann/complexity/issues", + "security": "https://github.com/sebastianbergmann/complexity/security/policy", + "source": "https://github.com/sebastianbergmann/complexity/tree/3.1.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-09-28T11:50:59+00:00" + }, + { + "name": "sebastian/diff", + "version": "5.1.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "fbf413a49e54f6b9b17e12d900ac7f6101591b7f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/fbf413a49e54f6b9b17e12d900ac7f6101591b7f", + "reference": "fbf413a49e54f6b9b17e12d900ac7f6101591b7f", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0", + "symfony/process": "^4.2 || ^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "5.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + } + ], + "description": "Diff implementation", + "homepage": "https://github.com/sebastianbergmann/diff", + "keywords": [ + "diff", + "udiff", + "unidiff", + "unified diff" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/diff/issues", + "security": "https://github.com/sebastianbergmann/diff/security/policy", + "source": "https://github.com/sebastianbergmann/diff/tree/5.1.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-12-22T10:55:06+00:00" + }, + { + "name": "sebastian/environment", + "version": "6.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "43c751b41d74f96cbbd4e07b7aec9675651e2951" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/43c751b41d74f96cbbd4e07b7aec9675651e2951", + "reference": "43c751b41d74f96cbbd4e07b7aec9675651e2951", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "suggest": { + "ext-posix": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "6.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides functionality to handle HHVM/PHP environments", + "homepage": "https://github.com/sebastianbergmann/environment", + "keywords": [ + "Xdebug", + "environment", + "hhvm" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/environment/issues", + "security": "https://github.com/sebastianbergmann/environment/security/policy", + "source": "https://github.com/sebastianbergmann/environment/tree/6.0.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-04-11T05:39:26+00:00" + }, + { + "name": "sebastian/exporter", + "version": "5.1.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "64f51654862e0f5e318db7e9dcc2292c63cdbddc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/64f51654862e0f5e318db7e9dcc2292c63cdbddc", + "reference": "64f51654862e0f5e318db7e9dcc2292c63cdbddc", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "php": ">=8.1", + "sebastian/recursion-context": "^5.0" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "5.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Provides the functionality to export PHP variables for visualization", + "homepage": "https://www.github.com/sebastianbergmann/exporter", + "keywords": [ + "export", + "exporter" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/exporter/issues", + "security": "https://github.com/sebastianbergmann/exporter/security/policy", + "source": "https://github.com/sebastianbergmann/exporter/tree/5.1.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-09-24T13:22:09+00:00" + }, + { + "name": "sebastian/global-state", + "version": "6.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/global-state.git", + "reference": "7ea9ead78f6d380d2a667864c132c2f7b83055e4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/7ea9ead78f6d380d2a667864c132c2f7b83055e4", + "reference": "7ea9ead78f6d380d2a667864c132c2f7b83055e4", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "sebastian/object-reflector": "^3.0", + "sebastian/recursion-context": "^5.0" + }, + "require-dev": { + "ext-dom": "*", + "phpunit/phpunit": "^10.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "6.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Snapshotting of global state", + "homepage": "http://www.github.com/sebastianbergmann/global-state", + "keywords": [ + "global state" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/global-state/issues", + "security": "https://github.com/sebastianbergmann/global-state/security/policy", + "source": "https://github.com/sebastianbergmann/global-state/tree/6.0.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-07-19T07:19:23+00:00" + }, + { + "name": "sebastian/lines-of-code", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/lines-of-code.git", + "reference": "649e40d279e243d985aa8fb6e74dd5bb28dc185d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/649e40d279e243d985aa8fb6e74dd5bb28dc185d", + "reference": "649e40d279e243d985aa8fb6e74dd5bb28dc185d", + "shasum": "" + }, + "require": { + "nikic/php-parser": "^4.10", + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for counting the lines of code in PHP source code", + "homepage": "https://github.com/sebastianbergmann/lines-of-code", + "support": { + "issues": "https://github.com/sebastianbergmann/lines-of-code/issues", + "security": "https://github.com/sebastianbergmann/lines-of-code/security/policy", + "source": "https://github.com/sebastianbergmann/lines-of-code/tree/2.0.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-08-31T09:25:50+00:00" + }, + { + "name": "sebastian/object-enumerator", + "version": "5.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-enumerator.git", + "reference": "202d0e344a580d7f7d04b3fafce6933e59dae906" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/202d0e344a580d7f7d04b3fafce6933e59dae906", + "reference": "202d0e344a580d7f7d04b3fafce6933e59dae906", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "sebastian/object-reflector": "^3.0", + "sebastian/recursion-context": "^5.0" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "5.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Traverses array structures and object graphs to enumerate all referenced objects", + "homepage": "https://github.com/sebastianbergmann/object-enumerator/", + "support": { + "issues": "https://github.com/sebastianbergmann/object-enumerator/issues", + "source": "https://github.com/sebastianbergmann/object-enumerator/tree/5.0.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-02-03T07:08:32+00:00" + }, + { + "name": "sebastian/object-reflector", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-reflector.git", + "reference": "24ed13d98130f0e7122df55d06c5c4942a577957" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/24ed13d98130f0e7122df55d06c5c4942a577957", + "reference": "24ed13d98130f0e7122df55d06c5c4942a577957", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Allows reflection of object attributes, including inherited and non-public ones", + "homepage": "https://github.com/sebastianbergmann/object-reflector/", + "support": { + "issues": "https://github.com/sebastianbergmann/object-reflector/issues", + "source": "https://github.com/sebastianbergmann/object-reflector/tree/3.0.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-02-03T07:06:18+00:00" + }, + { + "name": "sebastian/recursion-context", + "version": "5.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/recursion-context.git", + "reference": "05909fb5bc7df4c52992396d0116aed689f93712" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/05909fb5bc7df4c52992396d0116aed689f93712", + "reference": "05909fb5bc7df4c52992396d0116aed689f93712", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "5.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides functionality to recursively process PHP variables", + "homepage": "https://github.com/sebastianbergmann/recursion-context", + "support": { + "issues": "https://github.com/sebastianbergmann/recursion-context/issues", + "source": "https://github.com/sebastianbergmann/recursion-context/tree/5.0.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-02-03T07:05:40+00:00" + }, + { + "name": "sebastian/type", + "version": "4.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/type.git", + "reference": "462699a16464c3944eefc02ebdd77882bd3925bf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/462699a16464c3944eefc02ebdd77882bd3925bf", + "reference": "462699a16464c3944eefc02ebdd77882bd3925bf", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Collection of value objects that represent the types of the PHP type system", + "homepage": "https://github.com/sebastianbergmann/type", + "support": { + "issues": "https://github.com/sebastianbergmann/type/issues", + "source": "https://github.com/sebastianbergmann/type/tree/4.0.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-02-03T07:10:45+00:00" + }, + { + "name": "sebastian/version", + "version": "4.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/version.git", + "reference": "c51fa83a5d8f43f1402e3f32a005e6262244ef17" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c51fa83a5d8f43f1402e3f32a005e6262244ef17", + "reference": "c51fa83a5d8f43f1402e3f32a005e6262244ef17", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that helps with managing the version number of Git-hosted PHP projects", + "homepage": "https://github.com/sebastianbergmann/version", + "support": { + "issues": "https://github.com/sebastianbergmann/version/issues", + "source": "https://github.com/sebastianbergmann/version/tree/4.0.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-02-07T11:34:05+00:00" + }, + { + "name": "theseer/tokenizer", + "version": "1.2.2", + "source": { + "type": "git", + "url": "https://github.com/theseer/tokenizer.git", + "reference": "b2ad5003ca10d4ee50a12da31de12a5774ba6b96" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/b2ad5003ca10d4ee50a12da31de12a5774ba6b96", + "reference": "b2ad5003ca10d4ee50a12da31de12a5774ba6b96", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": "^7.2 || ^8.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + } + ], + "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", + "support": { + "issues": "https://github.com/theseer/tokenizer/issues", + "source": "https://github.com/theseer/tokenizer/tree/1.2.2" + }, + "funding": [ + { + "url": "https://github.com/theseer", + "type": "github" + } + ], + "time": "2023-11-20T00:12:19+00:00" } ], "aliases": [], "minimum-stability": "beta", "stability-flags": { - "open-telemetry/api": 10 + "open-telemetry/api": 10, + "open-telemetry/opentelemetry": 10 }, "prefer-stable": false, "prefer-lowest": false, diff --git a/phpunit-report.html b/phpunit-report.html new file mode 100644 index 0000000..6eb2500 --- /dev/null +++ b/phpunit-report.html @@ -0,0 +1,112 @@ + + + + + Test Documentation + + + +

Birth Date Anonymizer (Unit\Anonymizers\BirthDateAnonymizer)

+ +

Birth Date Detector (Unit\Detectors\BirthDateDetector)

+ +

Credit Card Anonymizer (Unit\Anonymizers\CreditCardAnonymizer)

+ +

Credit Card Detector (Unit\Detectors\CreditCardDetector)

+ +

Email Anonymizer (Unit\Anonymizers\EmailAnonymizer)

+ +

Email Detector (Unit\Detectors\EmailDetector)

+ +

Phone Anonymizer (Unit\Anonymizers\PhoneAnonymizer)

+ +

Phone Detector (Unit\Detectors\PhoneDetector)

+ + + \ No newline at end of file diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..dfd822e --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,16 @@ + + + + + ./tests + + + + + + + + ./src + + + diff --git a/phpunit.xml.bak b/phpunit.xml.bak new file mode 100644 index 0000000..89d49c2 --- /dev/null +++ b/phpunit.xml.bak @@ -0,0 +1,19 @@ + + + + ./tests + + + + + + ./src + + + + + + + diff --git a/src/Anonymizers/CreditCardAnonymizer.php b/src/Anonymizers/CreditCardAnonymizer.php index b6700c0..b5264c6 100644 --- a/src/Anonymizers/CreditCardAnonymizer.php +++ b/src/Anonymizers/CreditCardAnonymizer.php @@ -7,8 +7,8 @@ class CreditCardAnonymizer implements AnonymizerInterface public function anonymize(string $message): string { return preg_replace( - '/(\d{4}[-.\s]?)\d{4}[-.\s]?\d{4}[-.\s]?/', - '$1XXXX-XXXX-', + '/(\d{4})[-.\s]?\d{4}[-.\s]?\d{4}[-.\s]?\d{4}/', + '$1-XXXX-XXXX-XXXX', $message ); } diff --git a/src/Aspect/LogAnonymizer.php b/src/Aspect/LogAnonymizerAspect.php similarity index 99% rename from src/Aspect/LogAnonymizer.php rename to src/Aspect/LogAnonymizerAspect.php index c45b9e3..5be244e 100644 --- a/src/Aspect/LogAnonymizer.php +++ b/src/Aspect/LogAnonymizerAspect.php @@ -9,7 +9,6 @@ class LogAnonymizerAspect extends AbstractAspect { - /** * @var FacelessLogger */ diff --git a/src/Detectors/BirthDateDetector.php b/src/Detectors/BirthDateDetector.php index 9e9a889..a3ba5d1 100644 --- a/src/Detectors/BirthDateDetector.php +++ b/src/Detectors/BirthDateDetector.php @@ -2,13 +2,13 @@ namespace FacelessLog\Detectors; -class BirthDateDetector implements DetectorInterface -{ - public function detect(string $message): bool + class BirthDateDetector implements DetectorInterface { - $patternBR = "/\b\d{2}\/\d{2}\/\d{4}\b/"; - $patternISO = "/\b\d{4}-\d{2}-\d{2}\b/"; + public function detect(string $message): bool + { + $patternBR = "/\b\d{2}\/\d{2}\/\d{4}\b/"; + $patternISO = "/\b\d{4}-\d{2}-\d{2}\b/"; - return preg_match($patternBR, $message) || preg_match($patternISO, $message); + return preg_match($patternBR, $message) || preg_match($patternISO, $message); + } } -} diff --git a/src/Detectors/PhoneDetector.php b/src/Detectors/PhoneDetector.php index 3c1798a..0fab5cb 100644 --- a/src/Detectors/PhoneDetector.php +++ b/src/Detectors/PhoneDetector.php @@ -6,6 +6,6 @@ class PhoneDetector implements DetectorInterface { public function detect(string $message): bool { - return preg_match('/\+?\d{1,4}[-.\s]?\(?\d{1,4}\)?[-.\s]?\d{1,4}[-.\s]?\d{4,6}/', $message); + return preg_match('/\+?\d{1,4}[-.\s]?\(?\d{2,4}\)?[-.\s]?\d{3,4}[-.\s]?\d{4,6}/', $message); } -} +} \ No newline at end of file diff --git a/src/FacelessLogger.php b/src/FacelessLogger.php index c203d92..537b20a 100644 --- a/src/FacelessLogger.php +++ b/src/FacelessLogger.php @@ -15,34 +15,34 @@ class FacelessLogger { + private static FacelessLogger $instance; private $detectors = []; private $anonymizers = []; public function __construct() { - $this->addDetector(new EmailDetector()); - $this->addAnonymizer(new EmailAnonymizer()); - - $this->addDetector(new PhoneDetector()); - $this->addAnonymizer(new PhoneAnonymizer()); - - $this->addDetector(new CreditCardDetector()); - $this->addAnonymizer(new CreditCardAnonymizer()); - - $this->addDetector(new BirthDateDetector()); - $this->addAnonymizer(new BirthDateAnonymizer()); + $this->addDetector(new EmailDetector(), new EmailAnonymizer()); + $this->addDetector(new PhoneDetector(), new PhoneAnonymizer()); + $this->addDetector(new CreditCardDetector(), new CreditCardAnonymizer()); + $this->addDetector(new BirthDateDetector(), new BirthDateAnonymizer()); } - public function addDetector(DetectorInterface $detector) + public static function getInstance() { - $this->detectors[] = $detector; + if (self::$instance === null) { + self::$instance = new FacelessLogger(); + } + return self::$instance; } - public function addAnonymizer(AnonymizerInterface $anonymizer) + + public function addDetector(DetectorInterface $detector, AnonymizerInterface $anonymizer) { - $this->anonymizers[] = $anonymizer; + $this->detectors[get_class($detector)] = $detector; + $this->anonymizers[get_class($detector)] = $anonymizer; } + public function clearDefaultDetectors() { $this->detectors = []; @@ -55,11 +55,10 @@ public function clearDefaultAnonymizers() public function processMessage($message) { - foreach ($this->detectors as $detector) { + foreach ($this->detectors as $detectorClass => $detector) { if ($detector->detect($message)) { - foreach ($this->anonymizers as $anonymizer) { - $message = $anonymizer->anonymize($message); - } + $anonymizer = $this->anonymizers[$detectorClass]; + $message = $anonymizer->anonymize($message); } } return $message; diff --git a/tests/Unit/Anonymizers/BirthDateAnonymizerTest.php b/tests/Unit/Anonymizers/BirthDateAnonymizerTest.php new file mode 100644 index 0000000..0ced4cf --- /dev/null +++ b/tests/Unit/Anonymizers/BirthDateAnonymizerTest.php @@ -0,0 +1,36 @@ +anonymizer = new BirthDateAnonymizer(); + } + + public function testAnonymizeWithDashedDateFormat() + { + $originalMessage = "User's birth date is 1990-01-01."; + $expectedMessage = "User's birth date is XXXX-XX-XX."; + $this->assertEquals($expectedMessage, $this->anonymizer->anonymize($originalMessage)); + } + + public function testAnonymizeWithSlashedDateFormat() + { + $originalMessage = "User's birth date is 01/01/1990."; + $expectedMessage = "User's birth date is XX/XX/XXXX."; + $this->assertEquals($expectedMessage, $this->anonymizer->anonymize($originalMessage)); + } + + public function testAnonymizeWithoutDate() + { + $originalMessage = "No date in this message."; + $this->assertEquals($originalMessage, $this->anonymizer->anonymize($originalMessage)); + } +} diff --git a/tests/Unit/Anonymizers/CreditCardAnonymizerTest.php b/tests/Unit/Anonymizers/CreditCardAnonymizerTest.php new file mode 100644 index 0000000..1e47933 --- /dev/null +++ b/tests/Unit/Anonymizers/CreditCardAnonymizerTest.php @@ -0,0 +1,36 @@ +anonymizer = new CreditCardAnonymizer(); + } + + public function testAnonymizeCreditCardNumber() + { + $originalMessage = "The credit card number is 1234-5678-9012-3456."; + $expectedMessage = "The credit card number is 1234-XXXX-XXXX-XXXX."; + $this->assertEquals($expectedMessage, $this->anonymizer->anonymize($originalMessage)); + } + + public function testAnonymizeWithDifferentSeparators() + { + $originalMessage = "Cards: 1234 5678 9012 3456, 1234.5678.9012.3456."; + $expectedMessage = "Cards: 1234-XXXX-XXXX-XXXX, 1234-XXXX-XXXX-XXXX."; + $this->assertEquals($expectedMessage, $this->anonymizer->anonymize($originalMessage)); + } + + public function testAnonymizeWithoutCreditCardNumber() + { + $originalMessage = "This message does not contain a credit card number."; + $this->assertEquals($originalMessage, $this->anonymizer->anonymize($originalMessage)); + } +} \ No newline at end of file diff --git a/tests/Unit/Anonymizers/EmailAnonymizerTest.php b/tests/Unit/Anonymizers/EmailAnonymizerTest.php new file mode 100644 index 0000000..df18387 --- /dev/null +++ b/tests/Unit/Anonymizers/EmailAnonymizerTest.php @@ -0,0 +1,36 @@ +anonymizer = new EmailAnonymizer(); + } + + public function testAnonymizeEmailAddress() + { + $originalMessage = "Contact me at john.doe@example.com."; + $expectedMessage = "Contact me at j***.d**@example.com."; + $this->assertEquals($expectedMessage, $this->anonymizer->anonymize($originalMessage)); + } + + public function testAnonymizeMultipleEmailAddresses() + { + $originalMessage = "Emails: alice@example.com and bob@example.com."; + $expectedMessage = "Emails: a****@example.com and b**@example.com."; + $this->assertEquals($expectedMessage, $this->anonymizer->anonymize($originalMessage)); + } + + public function testAnonymizeWithoutEmailAddress() + { + $originalMessage = "This message does not contain an email address."; + $this->assertEquals($originalMessage, $this->anonymizer->anonymize($originalMessage)); + } +} diff --git a/tests/Unit/Anonymizers/PhoneAnonymizerTest.php b/tests/Unit/Anonymizers/PhoneAnonymizerTest.php new file mode 100644 index 0000000..2f311fd --- /dev/null +++ b/tests/Unit/Anonymizers/PhoneAnonymizerTest.php @@ -0,0 +1,36 @@ +anonymizer = new PhoneAnonymizer(); + } + + public function testAnonymizePhoneNumber() + { + $originalMessage = "Contact number is +123 4567 8901."; + $expectedMessage = "Contact number is +123 4567 XXXX."; + $this->assertEquals($expectedMessage, $this->anonymizer->anonymize($originalMessage)); + } + + public function testAnonymizeMultiplePhoneNumbers() + { + $originalMessage = "Numbers are (123) 456-7890 and 123.456.7890."; + $expectedMessage = "Numbers are (123) 456-XXXX and 123.456.XXXX."; + $this->assertEquals($expectedMessage, $this->anonymizer->anonymize($originalMessage)); + } + + public function testAnonymizeWithoutPhoneNumber() + { + $originalMessage = "This message does not contain a phone number."; + $this->assertEquals($originalMessage, $this->anonymizer->anonymize($originalMessage)); + } +} diff --git a/tests/Unit/Detectors/BirthDateDetectorTest.php b/tests/Unit/Detectors/BirthDateDetectorTest.php new file mode 100644 index 0000000..7acccd6 --- /dev/null +++ b/tests/Unit/Detectors/BirthDateDetectorTest.php @@ -0,0 +1,35 @@ +detector = new BirthDateDetector(); + } + + /** + * @dataProvider dateMessageProvider + */ + public function testDetectsDate(string $message, bool $expectedResult) + { + $this->assertEquals($expectedResult, $this->detector->detect($message)); + } + + public static function dateMessageProvider() + { + return [ + "with pt-br date" => ["A data de nascimento é 01/01/1990.", true], + "with iso date" => ["The birth date is 1990-01-01.", true], + + "without date" => ["Este texto não tem uma data.", false], + "without iso date" => ["This text doesn't have a date.", false], + ]; + } +} diff --git a/tests/Unit/Detectors/CreditCardDetectorTest.php b/tests/Unit/Detectors/CreditCardDetectorTest.php new file mode 100644 index 0000000..b4bc03e --- /dev/null +++ b/tests/Unit/Detectors/CreditCardDetectorTest.php @@ -0,0 +1,38 @@ +detector = new CreditCardDetector(); + } + + /** + * @dataProvider creditCardMessageProvider + */ + public function testDetectsCreditCard(string $message, bool $expectedResult) + { + $this->assertEquals($expectedResult, $this->detector->detect($message)); + } + + public static function creditCardMessageProvider() + { + return [ + ["Credit card number is 1234-5678-9012-3456", true], + ["Another card: 1234567890123456", true], + ["Card with spaces: 1234 5678 9012 3456", true], + ["Card with dots: 1234.5678.9012.3456", true], + + ["No card number here", false], + ["Random numbers: 1234-5678", false], + ["Incomplete card number: 1234-5678-9012", false], + ]; + } +} \ No newline at end of file diff --git a/tests/Unit/Detectors/EmailDetectorTest.php b/tests/Unit/Detectors/EmailDetectorTest.php new file mode 100644 index 0000000..a43b32f --- /dev/null +++ b/tests/Unit/Detectors/EmailDetectorTest.php @@ -0,0 +1,35 @@ +detector = new EmailDetector(); + } + + /** + * @dataProvider emailMessageProvider + */ + public function testDetectsEmail(string $message, bool $expectedResult) + { + $this->assertEquals($expectedResult, $this->detector->detect($message)); + } + + public static function emailMessageProvider() + { + return [ + ["Contact me at john.doe@example.com", true], + ["Email: jane_doe123@subdomain.example.co.uk", true], + + ["This is a plain text without email.", false], + ["Just a website www.example.com, no email here.", false], + ]; + } +} diff --git a/tests/Unit/Detectors/PhoneDetectorTest.php b/tests/Unit/Detectors/PhoneDetectorTest.php new file mode 100644 index 0000000..0c9a93e --- /dev/null +++ b/tests/Unit/Detectors/PhoneDetectorTest.php @@ -0,0 +1,37 @@ +detector = new PhoneDetector(); + } + + /** + * @dataProvider phoneMessageProvider + */ + public function testDetectsPhone(string $message, bool $expectedResult) + { + $this->assertEquals($expectedResult, $this->detector->detect($message)); + } + + public static function phoneMessageProvider() + { + return [ + ["Call me at +123 4567 8901", true], + ["Phone: (123) 456-7890", true], + ["Mobile: 123.456.7890", true], + ["Contact: 1234567890", true], + + ["No phone number here", false], + ["Random numbers: 1234-5678", false], + ]; + } +} \ No newline at end of file