Passed
Pull Request — master (#123)
by
unknown
19:58 queued 01:17
created
Classes/Validation/AbstractDlfValidator.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@
 block discarded – undo
48 48
     public function validate($value)
49 49
     {
50 50
         if (!$value instanceof $this->valueClassName) {
51
-            $this->logger->debug('Value must be an instance of ' . $this->valueClassName . '.');
51
+            $this->logger->debug('Value must be an instance of '.$this->valueClassName.'.');
52 52
             throw new InvalidArgumentException('Type of value is not valid.', 1723126505626);
53 53
         }
54 54
         return parent::validate($value);
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -29,8 +29,7 @@  discard block
 block discarded – undo
29 29
  *
30 30
  * @access public
31 31
  */
32
-abstract class AbstractDlfValidator extends AbstractValidator
33
-{
32
+abstract class AbstractDlfValidator extends AbstractValidator {
34 33
     use LoggerAwareTrait;
35 34
 
36 35
     protected string $valueClassName;
@@ -38,15 +37,13 @@  discard block
 block discarded – undo
38 37
     /**
39 38
      * @param $valueClassName string The class name of the value
40 39
      */
41
-    public function __construct(string $valueClassName)
42
-    {
40
+    public function __construct(string $valueClassName) {
43 41
         parent::__construct();
44 42
         $this->logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(static::class);
45 43
         $this->valueClassName = $valueClassName;
46 44
     }
47 45
 
48
-    public function validate($value)
49
-    {
46
+    public function validate($value) {
50 47
         if (!$value instanceof $this->valueClassName) {
51 48
             $this->logger->debug('Value must be an instance of ' . $this->valueClassName . '.');
52 49
             throw new InvalidArgumentException('Type of value is not valid.', 1723126505626);
Please login to merge, or discard this patch.
Classes/Validation/LibXmlTrait.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,8 +14,7 @@
 block discarded – undo
14 14
  * LICENSE.txt file that was distributed with this source code.
15 15
  */
16 16
 
17
-trait LibXmlTrait
18
-{
17
+trait LibXmlTrait {
19 18
     /**
20 19
      * Add the errors from the libxml error buffer as validation error.
21 20
      *
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,11 +34,11 @@
 block discarded – undo
34 34
 
35 35
     public function enableErrorBuffer(): void
36 36
     {
37
-        libxml_use_internal_errors(true);
37
+        libxml_use_internal_errors(TRUE);
38 38
     }
39 39
 
40 40
     public function disableErrorBuffer(): void
41 41
     {
42
-        libxml_use_internal_errors(false);
42
+        libxml_use_internal_errors(FALSE);
43 43
     }
44 44
 }
Please login to merge, or discard this patch.
Classes/Validation/AbstractDlfValidationStack.php 3 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
     {
55 55
         foreach ($configuration as $configurationItem) {
56 56
             if (!class_exists($configurationItem["className"])) {
57
-                $this->logger->error('Unable to load class ' . $configurationItem["className"] . '.');
57
+                $this->logger->error('Unable to load class '.$configurationItem["className"].'.');
58 58
                 throw new InvalidArgumentException('Unable to load validator class.', 1723200537037);
59 59
             }
60 60
             $breakOnError = !isset($configurationItem["breakOnError"]) || $configurationItem["breakOnError"] !== "false";
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
         }
84 84
 
85 85
         if (!$validator instanceof AbstractDlfValidator) {
86
-            $this->logger->error($className . ' must be an instance of AbstractDlfValidator.');
86
+            $this->logger->error($className.' must be an instance of AbstractDlfValidator.');
87 87
             throw new InvalidArgumentException('Class must be an instance of AbstractDlfValidator.', 1723121212747);
88 88
         }
89 89
 
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
     protected function isValid($value): void
105 105
     {
106 106
         if (!$value instanceof $this->valueClassName) {
107
-            $this->logger->error('Value must be an instance of ' . $this->valueClassName . '.');
107
+            $this->logger->error('Value must be an instance of '.$this->valueClassName.'.');
108 108
             throw new InvalidArgumentException('Type of value is not valid.', 1723127564821);
109 109
         }
110 110
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -26,8 +26,7 @@  discard block
 block discarded – undo
26 26
  *
27 27
  * @access public
28 28
  */
29
-abstract class AbstractDlfValidationStack extends AbstractDlfValidator
30
-{
29
+abstract class AbstractDlfValidationStack extends AbstractDlfValidator {
31 30
     use LoggerAwareTrait;
32 31
 
33 32
     const ITEM_KEY_TITLE = "title";
@@ -36,8 +35,7 @@  discard block
 block discarded – undo
36 35
 
37 36
     protected array $validatorStack = [];
38 37
 
39
-    public function __construct(string $valueClassName)
40
-    {
38
+    public function __construct(string $valueClassName) {
41 39
         parent::__construct($valueClassName);
42 40
     }
43 41
 
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -74,9 +74,9 @@
 block discarded – undo
74 74
      *
75 75
      * @return void
76 76
      */
77
-    protected function addValidator(string $className, string $title, bool $breakOnError = true, array $configuration = null): void
77
+    protected function addValidator(string $className, string $title, bool $breakOnError = TRUE, array $configuration = NULL): void
78 78
     {
79
-        if ($configuration === null) {
79
+        if ($configuration === NULL) {
80 80
             $validator = GeneralUtility::makeInstance($className);
81 81
         } else {
82 82
             $validator = GeneralUtility::makeInstance($className, $configuration);
Please login to merge, or discard this patch.
Classes/Validation/SaxonXslToSvrlValidator.php 3 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -61,11 +61,11 @@
 block discarded – undo
61 61
     protected function process(mixed $value): string
62 62
     {
63 63
         // using source from standard input
64
-        $process = new Process(['java', '-jar', $this->jar, '-xsl:' . $this->xsl, '-s:-'], null, null, $value->saveXML());
64
+        $process = new Process(['java', '-jar', $this->jar, '-xsl:'.$this->xsl, '-s:-'], null, null, $value->saveXML());
65 65
         $process->run();
66 66
         // executes after the command finish
67 67
         if (!$process->isSuccessful()) {
68
-            $this->logger->error('Processing exits with code "' . $process->getExitCode() . '"');
68
+            $this->logger->error('Processing exits with code "'.$process->getExitCode().'"');
69 69
             throw new InvalidArgumentException('Processing was not successful.', 1724862680);
70 70
         }
71 71
         return $process->getOutput();
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -31,14 +31,12 @@  discard block
 block discarded – undo
31 31
  *
32 32
  * @access public
33 33
  */
34
-class SaxonXslToSvrlValidator extends AbstractDlfValidator implements LoggerAwareInterface
35
-{
34
+class SaxonXslToSvrlValidator extends AbstractDlfValidator implements LoggerAwareInterface {
36 35
     private string $jar;
37 36
 
38 37
     private string $xsl;
39 38
 
40
-    public function __construct(array $configuration)
41
-    {
39
+    public function __construct(array $configuration) {
42 40
         parent::__construct(DOMDocument::class);
43 41
         $this->jar = GeneralUtility::getFileAbsFileName($configuration["jar"] ?? '');
44 42
         $this->xsl = GeneralUtility::getFileAbsFileName($configuration["xsl"] ?? '');
@@ -52,8 +50,7 @@  discard block
 block discarded – undo
52 50
         }
53 51
     }
54 52
 
55
-    protected function isValid($value)
56
-    {
53
+    protected function isValid($value) {
57 54
         $svrl = $this->process($value);
58 55
         $this->addErrorsOfSvrl($svrl);
59 56
     }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@
 block discarded – undo
61 61
     protected function process(mixed $value): string
62 62
     {
63 63
         // using source from standard input
64
-        $process = new Process(['java', '-jar', $this->jar, '-xsl:' . $this->xsl, '-s:-'], null, null, $value->saveXML());
64
+        $process = new Process(['java', '-jar', $this->jar, '-xsl:' . $this->xsl, '-s:-'], NULL, NULL, $value->saveXML());
65 65
         $process->run();
66 66
         // executes after the command finish
67 67
         if (!$process->isSuccessful()) {
Please login to merge, or discard this patch.
Classes/Middleware/DOMDocumentValidation.php 3 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -78,19 +78,19 @@
 block discarded – undo
78 78
         $validation = GeneralUtility::makeInstance(DOMDocumentValidationStack::class, $settings['domDocumentValidationValidators']);
79 79
 
80 80
         if (!GeneralUtility::isValidUrl($urlParam)) {
81
-            $this->logger->debug('Parameter "' . $urlParam . '" is not a valid url.');
81
+            $this->logger->debug('Parameter "'.$urlParam.'" is not a valid url.');
82 82
             throw new InvalidArgumentException('Value of url parameter is not a valid url.', 1724852611);
83 83
         }
84 84
 
85 85
         $content = GeneralUtility::getUrl($urlParam);
86 86
         if ($content === false) {
87
-            $this->logger->debug('Error while loading content of "' . $urlParam . '"');
87
+            $this->logger->debug('Error while loading content of "'.$urlParam.'"');
88 88
             throw new InvalidArgumentException('Error while loading content of url.', 1724420640);
89 89
         }
90 90
 
91 91
         $document = new DOMDocument();
92 92
         if ($document->loadXML($content) === false) {
93
-            $this->logger->debug('Error converting content of "' . $urlParam . '" to xml.');
93
+            $this->logger->debug('Error converting content of "'.$urlParam.'" to xml.');
94 94
             throw new InvalidArgumentException('Error converting content to xml.', 1724420648);
95 95
         }
96 96
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,8 +33,7 @@
 block discarded – undo
33 33
  * @subpackage dlf
34 34
  * @access public
35 35
  */
36
-class DOMDocumentValidation implements MiddlewareInterface
37
-{
36
+class DOMDocumentValidation implements MiddlewareInterface {
38 37
     use LoggerAwareTrait;
39 38
 
40 39
     /**
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -83,13 +83,13 @@
 block discarded – undo
83 83
         }
84 84
 
85 85
         $content = GeneralUtility::getUrl($urlParam);
86
-        if ($content === false) {
86
+        if ($content === FALSE) {
87 87
             $this->logger->debug('Error while loading content of "' . $urlParam . '"');
88 88
             throw new InvalidArgumentException('Error while loading content of url.', 1724420640);
89 89
         }
90 90
 
91 91
         $document = new DOMDocument();
92
-        if ($document->loadXML($content) === false) {
92
+        if ($document->loadXML($content) === FALSE) {
93 93
             $this->logger->debug('Error converting content of "' . $urlParam . '" to xml.');
94 94
             throw new InvalidArgumentException('Error converting content to xml.', 1724420648);
95 95
         }
Please login to merge, or discard this patch.
Tests/Unit/Validation/SaxonXslToSvrlValidatorTest.php 3 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,8 +28,7 @@
 block discarded – undo
28 28
  *
29 29
  * @access public
30 30
  */
31
-class SaxonXslToSvrlValidatorTest extends UnitTestCase
32
-{
31
+class SaxonXslToSvrlValidatorTest extends UnitTestCase {
33 32
     const SVRL = <<<SVRL
34 33
         <svrl:schematron-output
35 34
             xmlns:svrl="http://purl.oclc.org/dsdl/schematron">
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
     {
49 49
         parent::setUp();
50 50
         $this->resetSingletonInstances = true;
51
-        $this->dlfExtensionPath = Environment::getExtensionsPath() . 'dlf';
51
+        $this->dlfExtensionPath = Environment::getExtensionsPath().'dlf';
52 52
     }
53 53
 
54 54
     public function testJarFileNotFound(): void
@@ -63,12 +63,12 @@  discard block
 block discarded – undo
63 63
         $this->expectException(InvalidArgumentException::class);
64 64
         $this->expectExceptionMessage("XSL Schematron file not found.");
65 65
         // It only checks if a file exists at the specified path, so we can use one of the test files.
66
-        new SaxonXslToSvrlValidator(["jar" => $this->dlfExtensionPath . '/Tests/Fixtures/Format/alto.xml']);
66
+        new SaxonXslToSvrlValidator(["jar" => $this->dlfExtensionPath.'/Tests/Fixtures/Format/alto.xml']);
67 67
     }
68 68
 
69 69
     public function testValidation(): void
70 70
     {
71
-        $saxonXslToSvrlValidator = new SaxonXslToSvrlValidator(["jar" => $this->dlfExtensionPath . '/Tests/Fixtures/Format/alto.xml', "xsl" => $this->dlfExtensionPath . '/Tests/Fixtures/Format/alto.xml']);
71
+        $saxonXslToSvrlValidator = new SaxonXslToSvrlValidator(["jar" => $this->dlfExtensionPath.'/Tests/Fixtures/Format/alto.xml', "xsl" => $this->dlfExtensionPath.'/Tests/Fixtures/Format/alto.xml']);
72 72
         $reflection = new ReflectionClass($saxonXslToSvrlValidator);
73 73
 
74 74
         $result = $reflection->getProperty("result");
Please login to merge, or discard this patch.
Upper-Lower-Casing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
     public function setUp(): void
48 48
     {
49 49
         parent::setUp();
50
-        $this->resetSingletonInstances = true;
50
+        $this->resetSingletonInstances = TRUE;
51 51
         $this->dlfExtensionPath = Environment::getExtensionsPath() . 'dlf';
52 52
     }
53 53
 
@@ -72,11 +72,11 @@  discard block
 block discarded – undo
72 72
         $reflection = new ReflectionClass($saxonXslToSvrlValidator);
73 73
 
74 74
         $result = $reflection->getProperty("result");
75
-        $result->setAccessible(true);
75
+        $result->setAccessible(TRUE);
76 76
         $result->setValue($saxonXslToSvrlValidator, new Result());
77 77
 
78 78
         $method = $reflection->getMethod("addErrorsOfSvrl");
79
-        $method->setAccessible(true);
79
+        $method->setAccessible(TRUE);
80 80
         $method->invoke($saxonXslToSvrlValidator, self::SVRL);
81 81
 
82 82
         self::assertTrue($result->getValue($saxonXslToSvrlValidator)->hasErrors());
Please login to merge, or discard this patch.
Tests/Unit/Validation/DOMDocumentValidationStackTest.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -29,8 +29,7 @@
 block discarded – undo
29 29
  *
30 30
  * @access public
31 31
  */
32
-class DOMDocumentValidationStackTest extends UnitTestCase
33
-{
32
+class DOMDocumentValidationStackTest extends UnitTestCase {
34 33
     public function setUp(): void
35 34
     {
36 35
         parent::setUp();
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@
 block discarded – undo
34 34
     public function setUp(): void
35 35
     {
36 36
         parent::setUp();
37
-        $this->resetSingletonInstances = true;
37
+        $this->resetSingletonInstances = TRUE;
38 38
     }
39 39
 
40 40
     public function testValueTypeException(): void
Please login to merge, or discard this patch.
Tests/Unit/Validation/XmlSchemesValidatorTest.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,8 +26,7 @@
 block discarded – undo
26 26
  *
27 27
  * @access public
28 28
  */
29
-class XmlSchemesValidatorTest extends UnitTestCase
30
-{
29
+class XmlSchemesValidatorTest extends UnitTestCase {
31 30
     const METS = <<<METS
32 31
         <mets:mets
33 32
             xmlns:mets="http://www.loc.gov/METS/"
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@
 block discarded – undo
70 70
     public function setUp(): void
71 71
     {
72 72
         parent::setUp();
73
-        $this->resetSingletonInstances = true;
73
+        $this->resetSingletonInstances = TRUE;
74 74
     }
75 75
 
76 76
     public function testValidation(): void
Please login to merge, or discard this patch.