Passed
Branch dev (be6874)
by Jakob
02:59
created
src/RDFMapping.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
         }
63 63
 
64 64
         foreach ($rules as $field => $config) {
65
-            if (substr($field,0,1) != '_') {
65
+            if (substr($field, 0, 1) != '_') {
66 66
                 $this->rules[$field] = $config;
67 67
             }
68 68
         }
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
         #error_log(print_r($this->rules,1));
82 82
 
83 83
         foreach ($this->rules as $property => $mapping) {
84
-            $type   = $mapping['type'];
84
+            $type = $mapping['type'];
85 85
             if (isset($mapping['jskos']) && in_array($mapping['jskos'], static::$JSKOSClasses)) {
86 86
                 $class = '\JSKOS\\'.$mapping['jskos'];
87 87
             } else {
@@ -108,9 +108,9 @@  discard block
 block discarded – undo
108 108
                         $value = static::cleanString($literal);
109 109
                         if (!isset($value)) continue;
110 110
 
111
-                        if ( $literal->getLang() ) {
111
+                        if ($literal->getLang()) {
112 112
                             $language = $literal->getLang();
113
-                        } elseif ( isset($mapping['_defaultLanguage']) ) {
113
+                        } elseif (isset($mapping['_defaultLanguage'])) {
114 114
                             $language = $mapping['_defaultLanguage'];
115 115
                         } else {
116 116
                             $language = $this->defaultLanguage;
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
      * Silently try to load RDF from an URL.
164 164
      * @return EasyRdf_Resource|null
165 165
      */
166
-    public static function loadRDF($url, $uri=null, $format=null)
166
+    public static function loadRDF($url, $uri = null, $format = null)
167 167
     {
168 168
         try {
169 169
             $rdf = \EasyRdf_Graph::newAndLoad($url, $format);
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -106,7 +106,9 @@  discard block
 block discarded – undo
106 106
                 } elseif ($type == 'literal') {
107 107
                     foreach ($rdf->allLiterals($rdfProperty) as $literal) {
108 108
                         $value = static::cleanString($literal);
109
-                        if (!isset($value)) continue;
109
+                        if (!isset($value)) {
110
+                            continue;
111
+                        }
110 112
 
111 113
                         if ( $literal->getLang() ) {
112 114
                             $language = $literal->getLang();
@@ -131,7 +133,9 @@  discard block
 block discarded – undo
131 133
                 } elseif ($type == 'plain') {
132 134
                     foreach ($rdf->allLiterals($rdfProperty) as $literal) {
133 135
                         $value = static::cleanString($literal);
134
-                        if (!isset($value)) continue;
136
+                        if (!isset($value)) {
137
+                            continue;
138
+                        }
135 139
 
136 140
                         if (isset($mapping['pattern']) && !preg_match($mapping['pattern'], $value)) {
137 141
                             continue;
Please login to merge, or discard this patch.
src/Parser.php 3 patches
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -39,53 +39,53 @@
 block discarded – undo
39 39
         $graph = new EasyRdf_Graph();
40 40
         $this->parse($graph, $rdf);
41 41
 
42
-	    return $graph;
42
+        return $graph;
43 43
     }
44 44
 
45 45
     /**
46 46
      * Parse Quads as returned by JsonLD.
47 47
      */
48
-	public function parse($graph, $data, $format='jsonld', $baseUri=NULL) 
49
- 	{
50
-		parent::checkParseParams($graph, $data, $format, $baseUri);
48
+    public function parse($graph, $data, $format='jsonld', $baseUri=NULL) 
49
+        {
50
+        parent::checkParseParams($graph, $data, $format, $baseUri);
51 51
 
52
-		foreach ($data as $quad) {
53
-		  $subject = (string) $quad->getSubject();
52
+        foreach ($data as $quad) {
53
+            $subject = (string) $quad->getSubject();
54 54
 
55
-		  if ('_:' === substr($subject, 0, 2)) {
56
-			$subject = $this->remapBnode($subject);
57
-		  }
55
+            if ('_:' === substr($subject, 0, 2)) {
56
+            $subject = $this->remapBnode($subject);
57
+            }
58 58
 
59
-		  $predicate = (string) $quad->getProperty();
59
+            $predicate = (string) $quad->getProperty();
60 60
 
61
-		  if ($quad->getObject() instanceof IRI) {
62
-			$object = array(
63
-			  'type' => 'uri',
64
-			  'value' => (string) $quad->getObject()
65
-			);
61
+            if ($quad->getObject() instanceof IRI) {
62
+            $object = array(
63
+                'type' => 'uri',
64
+                'value' => (string) $quad->getObject()
65
+            );
66 66
 
67
-			if ('_:' === substr($object['value'], 0, 2)) {
68
-			  $object = array(
69
-				'type' => 'bnode',
70
-				'value' => $this->remapBnode($object['value'])
71
-			  );
72
-			}
73
-		  }
74
-		  else {
75
-			$object = array(
76
-			  'type' => 'literal',
77
-			  'value' => $quad->getObject()->getValue()
78
-			);
67
+            if ('_:' === substr($object['value'], 0, 2)) {
68
+                $object = array(
69
+                'type' => 'bnode',
70
+                'value' => $this->remapBnode($object['value'])
71
+                );
72
+            }
73
+            }
74
+            else {
75
+            $object = array(
76
+                'type' => 'literal',
77
+                'value' => $quad->getObject()->getValue()
78
+            );
79 79
 
80
-			if ($quad->getObject() instanceof LanguageTaggedString) {
81
-			  $object['lang'] = $quad->getObject()->getLanguage();
82
-			}
83
-			else {
84
-			  $object['datatype'] = $quad->getObject()->getType();
85
-			}
86
-		  }
80
+            if ($quad->getObject() instanceof LanguageTaggedString) {
81
+                $object['lang'] = $quad->getObject()->getLanguage();
82
+            }
83
+            else {
84
+                $object['datatype'] = $quad->getObject()->getType();
85
+            }
86
+            }
87 87
 
88
-		  $this->addTriple($subject, $predicate, $object);
89
-		}
88
+            $this->addTriple($subject, $predicate, $object);
89
+        }
90 90
     }
91 91
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
         $data = $jskos->jsonLDSerialize('');        
31 31
         if (!count($data['type'] ?? [])) { # TODO: put into JSKOS core package?
32 32
             $class = get_class($jskos);
33
-            $data['type'] = [ $class::TYPES[0] ];
33
+            $data['type'] = [$class::TYPES[0]];
34 34
         }
35 35
 
36 36
         $rdf = JsonLD::toRdf(json_encode($data), ['expandContext' => $this->context]);
@@ -45,23 +45,23 @@  discard block
 block discarded – undo
45 45
     /**
46 46
      * Parse Quads as returned by JsonLD.
47 47
      */
48
-	public function parse($graph, $data, $format='jsonld', $baseUri=NULL) 
48
+	public function parse($graph, $data, $format = 'jsonld', $baseUri = NULL) 
49 49
  	{
50 50
 		parent::checkParseParams($graph, $data, $format, $baseUri);
51 51
 
52 52
 		foreach ($data as $quad) {
53
-		  $subject = (string) $quad->getSubject();
53
+		  $subject = (string)$quad->getSubject();
54 54
 
55 55
 		  if ('_:' === substr($subject, 0, 2)) {
56 56
 			$subject = $this->remapBnode($subject);
57 57
 		  }
58 58
 
59
-		  $predicate = (string) $quad->getProperty();
59
+		  $predicate = (string)$quad->getProperty();
60 60
 
61 61
 		  if ($quad->getObject() instanceof IRI) {
62 62
 			$object = array(
63 63
 			  'type' => 'uri',
64
-			  'value' => (string) $quad->getObject()
64
+			  'value' => (string)$quad->getObject()
65 65
 			);
66 66
 
67 67
 			if ('_:' === substr($object['value'], 0, 2)) {
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -70,8 +70,7 @@  discard block
 block discarded – undo
70 70
 				'value' => $this->remapBnode($object['value'])
71 71
 			  );
72 72
 			}
73
-		  }
74
-		  else {
73
+		  } else {
75 74
 			$object = array(
76 75
 			  'type' => 'literal',
77 76
 			  'value' => $quad->getObject()->getValue()
@@ -79,8 +78,7 @@  discard block
 block discarded – undo
79 78
 
80 79
 			if ($quad->getObject() instanceof LanguageTaggedString) {
81 80
 			  $object['lang'] = $quad->getObject()->getLanguage();
82
-			}
83
-			else {
81
+			} else {
84 82
 			  $object['datatype'] = $quad->getObject()->getType();
85 83
 			}
86 84
 		  }
Please login to merge, or discard this patch.