Skip to content

Commit

Permalink
Merge pull request #1 from NigelRel3/Composer
Browse files Browse the repository at this point in the history
Updated project structure for composer
  • Loading branch information
NigelRel3 committed Mar 8, 2020
2 parents aacab19 + fa7c919 commit 65ea387
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 11 deletions.
18 changes: 16 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
{
"name" : "xmlreaderreg/xmlreaderreg",
"name" : "nigelrel3/xml-reader-reg",
"description" : "XMLReader higher level interface",
"type" : "library",
"license" : "MIT",
"authors" : [{
"name" : "NigelR",
"email" : "[email protected]"
}
],
"require-dev" : {
"phpunit/phpunit" : "~8.4"
"phpunit/phpunit" : "8.5.2",
"symplify/easy-coding-standard" : "~7.2"
},
"autoload" : {
"psr-4" : {
"XMLReaderReg\\" : "src"
}
}
}
5 changes: 2 additions & 3 deletions examples/XMLReaderBasic.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<?php
require_once __DIR__ . '/../vendor/autoload.php';

error_reporting(E_ALL);
ini_set('display_errors', 1);

require_once __DIR__ . '/../XMLReaderReg.php';

$inputFile = __DIR__ ."/../tests/data/simpleTest1.xml";
$reader = new XMLReaderReg();
$reader = new XMLReaderReg\XMLReaderReg();
$reader->open($inputFile);

$reader->process([
Expand Down
File renamed without changes.
15 changes: 12 additions & 3 deletions XMLReaderReg.php → src/XMLReaderReg.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
<?php

declare(strict_types=1);

namespace XMLReaderReg;

use DOMDocument;
use DOMElement;
use DOMXPath;
use ReflectionFunction;
use SimpleXMLElement;
use XMLReader;

/**
* @author NigelRen <[email protected]>
*/
Expand Down Expand Up @@ -53,13 +61,13 @@ class XMLReaderReg extends XMLReader {

/**
* Document used for importing data to SimpleXML or DOMElement
* @var DOMDocument
* @var \DOMDocument
*/
private $doc = null;

/**
* Used for processing namespace removal.
* @var DOMXPath
* @var \DOMXPath
*/
private $xpath = null;

Expand Down Expand Up @@ -204,6 +212,7 @@ protected function startElement(): void {
// See if interesed in this data
foreach ( $this->dataMatch as $pathReg => $closure ) {
// Check if matches regex...
$matches = [];
if ( preg_match('#^'.$pathReg.'$#', $path, $matches) ) {
$closure($this->{$this->callableParam [ $pathReg ]}(), $matches );
}
Expand Down
5 changes: 2 additions & 3 deletions tests/XMLReaderRegTest.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?php
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../XMLReaderReg.php';

use PHPUnit\Framework\TestCase;
use XMLReaderReg\XMLReaderReg;

/**
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
Expand Down

0 comments on commit 65ea387

Please sign in to comment.