Passed
Pull Request — master (#119)
by
unknown
07:31
created
Classes/Services/MetsExporter.php 1 patch
Braces   +24 added lines, -48 removed lines patch added patch discarded remove patch
@@ -17,8 +17,7 @@  discard block
 block discarded – undo
17 17
 /**
18 18
  * MetsExporter
19 19
  */
20
-class MetsExporter
21
-{
20
+class MetsExporter {
22 21
     /**
23 22
      * formData
24 23
      *
@@ -96,8 +95,7 @@  discard block
 block discarded – undo
96 95
     /**
97 96
      * Constructor
98 97
      */
99
-    public function __construct()
100
-    {
98
+    public function __construct() {
101 99
         // mets data beginning
102 100
         $this->metsHeader = '<mets:mets xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
103 101
                             xmlns:mets="http://www.loc.gov/METS/" xmlns:xlink="http://www.w3.org/1999/xlink"
@@ -138,8 +136,7 @@  discard block
 block discarded – undo
138 136
      * returns the mets xml string
139 137
      * @return string mets xml
140 138
      */
141
-    public function getMetsData()
142
-    {
139
+    public function getMetsData() {
143 140
         $xml = $this->metsData->saveXML();
144 141
 
145 142
         $xml = preg_replace("/eww=\"\d-\d-\d\"/", '${1}${2}${3}', $xml);
@@ -152,8 +149,7 @@  discard block
 block discarded – undo
152 149
      * returns the mods xml string
153 150
      * @return string mods xml
154 151
      */
155
-    public function getModsData()
156
-    {
152
+    public function getModsData() {
157 153
         return $this->modsData->saveXML();
158 154
     }
159 155
 
@@ -161,8 +157,7 @@  discard block
 block discarded – undo
161 157
      * Build mets data structure
162 158
      * @return string mets xml
163 159
      */
164
-    public function buildMets()
165
-    {
160
+    public function buildMets() {
166 161
         // get mods domDocument
167 162
         $modsWrap = $this->buildModsWrap();
168 163
         // get mets filesection
@@ -203,8 +198,7 @@  discard block
 block discarded – undo
203 198
      * @param  xml $xml xml data which should be wrapped with mods
204 199
      * @return xml wrapped xml
205 200
      */
206
-    public function wrapMods($xml)
207
-    {
201
+    public function wrapMods($xml) {
208 202
         $newXML = $this->modsHeader;
209 203
 
210 204
         $newXML = str_replace("</mods:mods>", $xml . "</mods:mods>", $newXML);
@@ -212,8 +206,7 @@  discard block
 block discarded – undo
212 206
         return $newXML;
213 207
     }
214 208
 
215
-    public function wrapSlub($xml)
216
-    {
209
+    public function wrapSlub($xml) {
217 210
         $newXML = $this->slubHeader;
218 211
 
219 212
         $newXML = str_replace("</slub:info>", $xml . "</slub:info>", $newXML);
@@ -225,8 +218,7 @@  discard block
 block discarded – undo
225 218
      * build mods from form array
226 219
      * @param array $array structured form data array
227 220
      */
228
-    public function buildModsFromForm($array)
229
-    {
221
+    public function buildModsFromForm($array) {
230 222
         $this->xmlData = $this->modsData;
231 223
         // Build xml mods from form fields
232 224
         // loop each group
@@ -308,8 +300,7 @@  discard block
 block discarded – undo
308 300
      * @param  xpath $xPath xPath expression
309 301
      * @return xml
310 302
      */
311
-    public function parseXPath($xPath)
312
-    {
303
+    public function parseXPath($xPath) {
313 304
 
314 305
         $this->parser->loop($xPath);
315 306
         $xml = $this->parser->getXML();
@@ -323,8 +314,7 @@  discard block
 block discarded – undo
323 314
      * @param  string $value form value
324 315
      * @return xml    created xml
325 316
      */
326
-    public function customXPath($xPath, $newGroupFlag = false, $value = '', $attributeOnly = false)
327
-    {
317
+    public function customXPath($xPath, $newGroupFlag = false, $value = '', $attributeOnly = false) {
328 318
         if (!$attributeOnly) {
329 319
             // Explode xPath
330 320
             $newPath = explode('%', $xPath);
@@ -495,8 +485,7 @@  discard block
 block discarded – undo
495 485
         return $this->xmlData->saveXML();
496 486
     }
497 487
 
498
-    public function customXPathSlub($xPath, $newGroupFlag = false, $value = '', $attributeOnly = false)
499
-    {
488
+    public function customXPathSlub($xPath, $newGroupFlag = false, $value = '', $attributeOnly = false) {
500 489
         if (!$attributeOnly) {
501 490
             // Explode xPath
502 491
             $newPath = explode('%', $xPath);
@@ -610,8 +599,7 @@  discard block
 block discarded – undo
610 599
      * Builds the xml wrapping part for mods
611 600
      * @return xml
612 601
      */
613
-    public function buildModsWrap()
614
-    {
602
+    public function buildModsWrap() {
615 603
         // Build wrap for mod
616 604
 
617 605
         $domDocument = new \DOMDocument();
@@ -649,8 +637,7 @@  discard block
 block discarded – undo
649 637
      * Builds xml amdSection
650 638
      * @return xml
651 639
      */
652
-    public function buildAmdSection()
653
-    {
640
+    public function buildAmdSection() {
654 641
         // Build xml amd:sec
655 642
 
656 643
         $domDocument = new \DOMDocument();
@@ -661,8 +648,7 @@  discard block
 block discarded – undo
661 648
         $amdSec = $domDocument->createElement('mets:amdSec');
662 649
     }
663 650
 
664
-    public function setMods($value = '')
665
-    {
651
+    public function setMods($value = '') {
666 652
         $domDocument = new \DOMDocument();
667 653
         if (is_null(@$domDocument->loadXML($value))) {
668 654
             throw new \Exception("Couldn't load MODS data");
@@ -670,13 +656,11 @@  discard block
 block discarded – undo
670 656
         $this->modsData = $domDocument;
671 657
     }
672 658
 
673
-    public function setFileData($value = '')
674
-    {
659
+    public function setFileData($value = '') {
675 660
         $this->files = $value;
676 661
     }
677 662
 
678
-    public function loopFiles($array, $domElement, $domDocument)
679
-    {
663
+    public function loopFiles($array, $domElement, $domDocument) {
680 664
         $i = 0;
681 665
         // set xml for uploded files
682 666
         foreach ($array as $key => $value) {
@@ -721,8 +705,7 @@  discard block
 block discarded – undo
721 705
      * Builds the xml fileSection part if files are uploaded
722 706
      * @return xml
723 707
      */
724
-    public function buildFileSection()
725
-    {
708
+    public function buildFileSection() {
726 709
         if (empty($this->files['original']) && empty($this->files['download'])) {
727 710
             return;
728 711
         }
@@ -769,8 +752,7 @@  discard block
 block discarded – undo
769 752
      * Builds the xml structMap part if files are uploaded
770 753
      * @return xml
771 754
      */
772
-    public function buildStructureMap()
773
-    {
755
+    public function buildStructureMap() {
774 756
         // Build xml Mets:structMap
775 757
 
776 758
         $domDocument = new \DOMDocument();
@@ -809,8 +791,7 @@  discard block
 block discarded – undo
809 791
         return $domDocument;
810 792
     }
811 793
 
812
-    public function setSlubInfo($value = '')
813
-    {
794
+    public function setSlubInfo($value = '') {
814 795
         // build DOMDocument with slub xml
815 796
         $domDocument = new \DOMDocument();
816 797
         $domDocument->loadXML($value);
@@ -822,8 +803,7 @@  discard block
 block discarded – undo
822 803
      * @param  Array $array Array with slub information
823 804
      * @return xml        xml slubInfo
824 805
      */
825
-    public function buildMetsSlub()
826
-    {
806
+    public function buildMetsSlub() {
827 807
         $domDocument = new \DOMDocument();
828 808
         $domDocument->loadXML('<mets:amdSec ID="AMD_000" xmlns:mets="http://www.loc.gov/METS/"></mets:amdSec>');
829 809
         $domWrapElement = $domDocument->firstChild;
@@ -864,8 +844,7 @@  discard block
 block discarded – undo
864 844
      * returns the mods xml string
865 845
      * @return string mods xml
866 846
      */
867
-    public function getSlubData()
868
-    {
847
+    public function getSlubData() {
869 848
         return $this->slubData->saveXML();
870 849
     }
871 850
 
@@ -873,8 +852,7 @@  discard block
 block discarded – undo
873 852
      *
874 853
      * @param string $slubInfoData
875 854
      */
876
-    public function buildSlubInfoFromForm($slubInfoData, $documentType, $processNumber)
877
-    {
855
+    public function buildSlubInfoFromForm($slubInfoData, $documentType, $processNumber) {
878 856
         $this->xmlData = $this->slubData;
879 857
         if (is_array($slubInfoData['metadata'])) {
880 858
             foreach ($slubInfoData['metadata'] as $key => $group) {
@@ -957,8 +935,7 @@  discard block
 block discarded – undo
957 935
      *
958 936
      * @return string slub info xml
959 937
      */
960
-    public function getSlubInfoData()
961
-    {
938
+    public function getSlubInfoData() {
962 939
         return $this->slubData->saveXML();
963 940
     }
964 941
 
@@ -967,8 +944,7 @@  discard block
 block discarded – undo
967 944
      * @param string $objId
968 945
      * @return void
969 946
      */
970
-    public function setObjId($objId)
971
-    {
947
+    public function setObjId($objId) {
972 948
         $this->objId = $objId;
973 949
     }
974 950
 }
Please login to merge, or discard this patch.
Classes/Services/XPathXMLGenerator.php 3 patches
Upper-Lower-Casing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
         $i = 0;
39 39
         $predicateStack = 0;
40 40
         $tokenStack = 0;
41
-        $insidePredicate = false;
41
+        $insidePredicate = FALSE;
42 42
         $predicateString = "";
43 43
         $loopStack = array();
44 44
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 
48 48
             if ($firstChar === '[' || $insidePredicate) {
49 49
                 // get corresponding bracket
50
-                $insidePredicate = true;
50
+                $insidePredicate = TRUE;
51 51
 
52 52
                 $predicateString .= $value;
53 53
 
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 
57 57
                     if ($predicateStack === 0) {
58 58
                         // corresponding bracket found
59
-                        $insidePredicate = false;
59
+                        $insidePredicate = FALSE;
60 60
 
61 61
                         if (!empty($predicateString)) {
62 62
                             // recursive call with predicate string
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
         $tokenStack = 0;
49 49
         $insidePredicate = false;
50 50
         $predicateString = "";
51
-        $loopStack = array();
51
+        $loopStack = array ();
52 52
 
53 53
         foreach ($matches[0] as $key => $value) {
54 54
             $firstChar = substr($value, 0, 1);
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
                 $this->endAttribute();
89 89
                 array_pop($loopStack);
90 90
                 $predicateStack--;
91
-            } else if ($firstChar !== '=' && $firstChar !== '[' && $firstChar !== '@' && $firstChar !== '/' && $firstChar!== '.') {
91
+            } else if ($firstChar !== '=' && $firstChar !== '[' && $firstChar !== '@' && $firstChar !== '/' && $firstChar !== '.') {
92 92
                 $this->startToken($value);
93 93
                 $loopStack[] = 'token';
94 94
                 if ($predicateStack > 0) {
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
                 $this->endToken();
107 107
             }
108 108
         }
109
-        $this->stack = array();
109
+        $this->stack = array ();
110 110
 
111 111
     }
112 112
 
Please login to merge, or discard this patch.
Braces   +10 added lines, -20 removed lines patch added patch discarded remove patch
@@ -19,14 +19,12 @@  discard block
 block discarded – undo
19 19
  * Generates XML elements for a given xpath
20 20
  * Notice: Not all sytax from the original xpath is implemented
21 21
  */
22
-class XPathXMLGenerator
23
-{
22
+class XPathXMLGenerator {
24 23
     protected $regex = '/[a-zA-Z:]+|[<=>]|[@][a-zA-Z][a-zA-Z0-9_\-\:\.]*|\[|\'.*?\'|".*?"|\]|\//';
25 24
 
26 25
     private $xmlWriter;
27 26
 
28
-    public function __construct()
29
-    {
27
+    public function __construct() {
30 28
         $this->xmlWriter = new \XMLWriter();
31 29
         $this->xmlWriter->openMemory();
32 30
     }
@@ -39,8 +37,7 @@  discard block
 block discarded – undo
39 37
         return str_replace("%%nl%%", "\n", $string);
40 38
     }
41 39
 
42
-    function loop($xpath)
43
-    {
40
+    function loop($xpath) {
44 41
         // split xpath to find predicates, attributes and texts
45 42
         preg_match_all($this->regex, $this->replaceLineBreaks($xpath), $matches);
46 43
         $i = 0;
@@ -115,16 +112,14 @@  discard block
 block discarded – undo
115 112
      * Starts an XML element
116 113
      * <$value>
117 114
      */
118
-    function startToken($value)
119
-    {
115
+    function startToken($value) {
120 116
         $this->xmlWriter->startElement($value);
121 117
     }
122 118
 
123 119
     /**
124 120
      * Ends the last token
125 121
      */
126
-    function endToken()
127
-    {
122
+    function endToken() {
128 123
         $this->xmlWriter->endElement();
129 124
     }
130 125
 
@@ -133,8 +128,7 @@  discard block
 block discarded – undo
133 128
      * Adds content to an XML element or attribute
134 129
      * <mods:mods>$value</mods:mods>
135 130
      */
136
-    function setText($value)
137
-    {
131
+    function setText($value) {
138 132
         $this->xmlWriter->text($value);
139 133
     }
140 134
 
@@ -144,8 +138,7 @@  discard block
 block discarded – undo
144 138
      * It adds an attribute with name and value to an XML element
145 139
      * <mods:mods $name=$value>
146 140
      */
147
-    function addAttribute($name, $value)
148
-    {
141
+    function addAttribute($name, $value) {
149 142
         $this->xmlWriter->writeAttribute($name, $value);
150 143
     }
151 144
 
@@ -153,16 +146,14 @@  discard block
 block discarded – undo
153 146
      * @param $name
154 147
      * Starts an attribute
155 148
      */
156
-    function startAttribute($name)
157
-    {
149
+    function startAttribute($name) {
158 150
         $this->xmlWriter->startAttribute($name);
159 151
     }
160 152
 
161 153
     /**
162 154
      * Ends the last started attribute
163 155
      */
164
-    function endAttribute()
165
-    {
156
+    function endAttribute() {
166 157
         $this->xmlWriter->endAttribute();
167 158
     }
168 159
 
@@ -170,8 +161,7 @@  discard block
 block discarded – undo
170 161
      * @return string
171 162
      * Returns the created XML
172 163
      */
173
-    function getXML()
174
-    {
164
+    function getXML() {
175 165
         return $this->xmlWriter->outputMemory();
176 166
     }
177 167
 }
Please login to merge, or discard this patch.
Tests/Unit/Services/XPathXMLGeneratorTest.php 2 patches
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
     /**
23 23
      * @var XPathXMLGenerator
24 24
      */
25
-    private $xpathGenerator = null;
25
+    private $xpathGenerator = NULL;
26 26
 
27 27
     protected function setUp() {
28 28
         $this->xpathGenerator = new \EWW\Dpf\Services\XPathXMLGenerator();
Please login to merge, or discard this patch.
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -17,8 +17,7 @@  discard block
 block discarded – undo
17 17
 use Nimut\TestingFramework\TestCase\UnitTestCase;
18 18
 include_once 'Classes/Services/XPathXMLGenerator.php';
19 19
 
20
-class XPathXMLGeneratorTest extends UnitTestCase
21
-{
20
+class XPathXMLGeneratorTest extends UnitTestCase {
22 21
 
23 22
     /**
24 23
      * @var XPathXMLGenerator
@@ -32,8 +31,7 @@  discard block
 block discarded – undo
32 31
     /**
33 32
      * @test
34 33
      */
35
-    public function testXMLGeneration1()
36
-    {
34
+    public function testXMLGeneration1() {
37 35
         $xpath = 'mods:name[mods:role/mods:roleTerm[@type="code"][@authority="marcrelator"]="edt"]/mods:displayForm';
38 36
         $expectedXml = '<mods:name><mods:role><mods:roleTerm type="code" authority="marcrelator">edt</mods:roleTerm></mods:role><mods:displayForm/></mods:name>';
39 37
 
@@ -48,8 +46,7 @@  discard block
 block discarded – undo
48 46
     /**
49 47
      * @test
50 48
      */
51
-    public function testXMLGeneration2()
52
-    {
49
+    public function testXMLGeneration2() {
53 50
         $xpath = 'mods:language/mods:languageTerm[@authority="iso639-2b"][@type="code"]="ger"';
54 51
         $expectedXml = '<mods:language><mods:languageTerm authority="iso639-2b" type="code">ger</mods:languageTerm></mods:language>';
55 52
 
@@ -64,8 +61,7 @@  discard block
 block discarded – undo
64 61
     /**
65 62
      * @test
66 63
      */
67
-    public function testXMLGeneration3()
68
-    {
64
+    public function testXMLGeneration3() {
69 65
         $xpath = 'mods:originInfo[@eventType="publication"]';
70 66
         $expectedXml = '<mods:originInfo eventType="publication"/>';
71 67
 
Please login to merge, or discard this patch.