1. Go to this page and download the library: Download coduo/php-matcher library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use Coduo\PHPMatcher\PHPMatcher;
$matcher = new PHPMatcher();
$match = $matcher->match("lorem ipsum dolor", "@string@");
if (!$match) {
echo "Error: " . $matcher->error();
echo "Backtrace: \n";
echo (string) $matcher->backtrace();
}
use Coduo\PHPMatcher\PHPUnit\PHPMatcherTestCase;
class MatcherTest extends PHPMatcherTestCase
{
public function test_matcher_that_value_matches_pattern()
{
$this->assertMatchesPattern('{"name": "@string@"}', '{"name": "Norbert"}');
}
}
use Coduo\PHPMatcher\PHPUnit\PHPMatcherAssertions;
use PHPUnit\Framework\TestCase;
class MatcherTest extends TestCase
{
use PHPMatcherAssertions;
public function test_matcher_that_value_matches_pattern()
{
$this->assertMatchesPattern('{"name": "@string@"}', '{"name": "Norbert"}');
}
}
use Coduo\PHPMatcher\PHPMatcher;
$matcher = new PHPMatcher();
$matcher->match(1, 1);
$matcher->match('string', 'string');
use Coduo\PHPMatcher\PHPMatcher;
$matcher = new PHPMatcher();
$matcher->match('Norbert', '@string@');
$matcher->match("lorem ipsum dolor", "@[email protected]('lorem').contains('ipsum').endsWith('dolor')");
use Coduo\PHPMatcher\PHPMatcher;
$matcher = new PHPMatcher();
$matcher->match('00:00:00', '@time@');
$matcher->match('00:01:00.000000', '@time@');
$matcher->match('00:01:00', '@[email protected]("00:00:00")');
$matcher->match('00:00:00', '@[email protected]("01:00:00")');
use Coduo\PHPMatcher\PHPMatcher;
$matcher = new PHPMatcher();
$matcher->match('2014-08-19', '@date@');
$matcher->match('2020-01-11', '@date@');
$matcher->match('2014-08-19', '@[email protected]("2016-08-19")');
$matcher->match('2014-08-19', '@[email protected]("today").after("+ 100year")');
use Coduo\PHPMatcher\PHPMatcher;
$matcher = new PHPMatcher();
$matcher->match('2014-08-19', '@datetime@');
$matcher->match('2020-01-11 00:00:00', '@datetime@');
$matcher->match('2014-08-19', '@[email protected]("2016-08-19")');
$matcher->match('2014-08-19', '@[email protected]("today").after("+ 100year")');
use Coduo\PHPMatcher\PHPMatcher;
$matcher = new PHPMatcher();
$matcher->match(<<<XML
<?xml version="1.0"
namespace Coduo\PHPMatcher\Tests\PHPUnit;
use Coduo\PHPMatcher\PHPUnit\PHPMatcherAssertions;
use PHPUnit\Framework\TestCase;
class PHPMatcherAssertionsTest extends TestCase
{
use PHPMatcherAssertions;
public function test_it_asserts_if_a_value_matches_the_pattern()
{
$this->assertMatchesPattern('@string@', 'foo');
}
}