|
Server : Apache System : Linux server.mata-lashes.com 3.10.0-1160.90.1.el7.x86_64 #1 SMP Thu May 4 15:21:22 UTC 2023 x86_64 User : matalashes ( 1004) PHP Version : 8.1.29 Disable Function : NONE Directory : /home/matalashes/www/kite.mata-lashes.com/vendor/nexusphp/tachycardia/src/Util/ |
Upload File : |
<?php
declare(strict_types=1);
/**
* This file is part of Nexus Tachycardia.
*
* (c) 2021 John Paul E. Balandan, CPA <paulbalandan@gmail.com>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Nexus\PHPUnit\Extension\Util;
/**
* @internal
*/
final class Parser
{
/**
* @var string
*/
public const REGEX_TEST_CASE_NAME = '/^(?:(?P<class>[A-Z][A-Za-z0-9_\\\\]+)::(?P<name>\S+))(?:(?P<dataname> with data set (?:#\d+|"[^"]+"))\s\()?/u';
private static ?Parser $instance;
/**
* @codeCoverageIgnore
*/
private function __construct()
{
}
public static function getInstance(): self
{
self::$instance = self::$instance ?? new self();
return self::$instance;
}
public function parseTest(string $test): TestCase
{
$matches = [];
preg_match(self::REGEX_TEST_CASE_NAME, $test, $matches);
return new TestCase($matches['class'], $matches['name'], $matches['dataname'] ?? '');
}
}