@@ -62,7 +62,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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); |
@@ -106,7 +106,9 @@ discard block |
||
| 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 |
||
| 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; |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | protected $context; |
| 21 | 21 | |
| 22 | 22 | # TODO: move to jskos-php package |
| 23 | - private function jsonLDSerialize($jskos, $context, int $typed=0) { |
|
| 23 | + private function jsonLDSerialize($jskos, $context, int $typed = 0) { |
|
| 24 | 24 | $data = $jskos->jsonLDSerialize($context); |
| 25 | 25 | if ($typed && !count($data['type'] ?? [])) { |
| 26 | 26 | $class = get_class($jskos); |
@@ -43,11 +43,11 @@ discard block |
||
| 43 | 43 | # TODO: put into JSKOS core package? |
| 44 | 44 | if ($jskos instanceof Set) { |
| 45 | 45 | $data = $jskos->map( |
| 46 | - function ($m) { |
|
| 47 | - return json_encode($this->jsonLDSerialize($m,'', 1)); |
|
| 46 | + function($m) { |
|
| 47 | + return json_encode($this->jsonLDSerialize($m, '', 1)); |
|
| 48 | 48 | } |
| 49 | 49 | ); |
| 50 | - $json = '{"@graph":['. implode(',', $data)."]}"; |
|
| 50 | + $json = '{"@graph":['.implode(',', $data)."]}"; |
|
| 51 | 51 | } else { # TODO: throw on unparsable JSKOS |
| 52 | 52 | $data = $this->jsonLDSerialize($jskos, '', 1); |
| 53 | 53 | $json = json_encode($data); |