summaryrefslogtreecommitdiff
path: root/app/Report/ReportParserBase.php
diff options
context:
space:
mode:
authorGreg Roach <fisharebest@webtrees.net>2018-10-06 17:32:59 +0100
committerGreg Roach <fisharebest@webtrees.net>2018-10-06 17:32:59 +0100
commit208e9f762b2d87324d4f7e01791fd398ccf1cc27 (patch)
treefc2fe63e9b48ce2182ac52f6dacf530b3c383322 /app/Report/ReportParserBase.php
parent6a4bb6faa480bc80b248f41909ba029b2f443b35 (diff)
downloadwebtrees-208e9f762b2d87324d4f7e01791fd398ccf1cc27.tar.gz
webtrees-208e9f762b2d87324d4f7e01791fd398ccf1cc27.tar.bz2
webtrees-208e9f762b2d87324d4f7e01791fd398ccf1cc27.zip
Refactor reports
Diffstat (limited to 'app/Report/ReportParserBase.php')
-rw-r--r--app/Report/ReportParserBase.php12
1 files changed, 8 insertions, 4 deletions
diff --git a/app/Report/ReportParserBase.php b/app/Report/ReportParserBase.php
index 6918d01623..e17cc796e9 100644
--- a/app/Report/ReportParserBase.php
+++ b/app/Report/ReportParserBase.php
@@ -17,7 +17,9 @@ declare(strict_types=1);
namespace Fisharebest\Webtrees\Report;
+use DomainException;
use Fisharebest\Webtrees\Tree;
+use function method_exists;
/**
* Class ReportParserBase
@@ -54,7 +56,7 @@ class ReportParserBase
$fp = fopen($report, 'r');
while (($data = fread($fp, 4096))) {
if (!xml_parse($this->xml_parser, $data, feof($fp))) {
- throw new \DomainException(sprintf(
+ throw new DomainException(sprintf(
'XML error: %s at line %d',
xml_error_string(xml_get_error_code($this->xml_parser)),
xml_get_current_line_number($this->xml_parser)
@@ -74,12 +76,13 @@ class ReportParserBase
*
* @return void
*/
- protected function startElement($parser, $name, $attrs)
+ protected function startElement($parser, string $name, array $attrs)
{
$method = $name . 'StartHandler';
+
if (method_exists($this, $method)) {
$this->$method($attrs);
- }
+ }
}
/**
@@ -90,9 +93,10 @@ class ReportParserBase
*
* @return void
*/
- protected function endElement($parser, $name)
+ protected function endElement($parser, string $name)
{
$method = $name . 'EndHandler';
+
if (method_exists($this, $method)) {
$this->$method();
}