| Conditions | 13 |
| Paths | 37 |
| Total Lines | 60 |
| Code Lines | 39 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 23 |
| CRAP Score | 13.2597 |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 89 | 4 | public function asTurtleFragment() |
|
| 90 | { |
||
| 91 | 4 | static $uriVars = array( |
|
| 92 | 'gender' => 'schema:gender', |
||
| 93 | 'worksFor' => 'schema:worksFor', |
||
| 94 | ); |
||
| 95 | 4 | static $stringVars = array( |
|
| 96 | 'taxID' => 'schema:taxID', |
||
| 97 | 'givenName' => 'schema:givenName', |
||
| 98 | 'familyName' => 'schema:familyName', |
||
| 99 | 'additionalName' => 'schema:additionalName', |
||
| 100 | 'telephone' => 'schema:telephone', |
||
| 101 | 'faxNumber' => 'schema:faxNumber', |
||
| 102 | 'jobTitle' => 'schema:jobTitle', |
||
| 103 | 'honorificPrefix' => 'schema:honorificPrefix', |
||
| 104 | 'honorificSuffix' => 'schema:honorificSuffix', |
||
| 105 | 'email' => 'schema:email', |
||
| 106 | 'spokenLanguage' => 'schema:spokenLanguage', |
||
| 107 | ); |
||
| 108 | |||
| 109 | |||
| 110 | 4 | if(is_null($this->rdf)) { |
|
| 111 | |||
| 112 | // make a default for altenatename (can be empty) before calling parent::asTurtleFragment |
||
| 113 | 4 | if(empty($this->data['alternateName'])){ |
|
| 114 | 3 | $this->data['alternateName'] =''; |
|
| 115 | 3 | if(!empty($this->data['givenName'])) { $this->data['alternateName'].= $this->data['givenName'].' ';} |
|
| 116 | 3 | if(!empty($this->data['additionalName'])) { $this->data['alternateName'].= $this->data['additionalName'].' ';} |
|
| 117 | 3 | if(!empty($this->data['familyName'])) { $this->data['alternateName'].= $this->data['familyName'].' ';} |
|
| 118 | } |
||
| 119 | 4 | $this->rdf = parent::asTurtleFragment(); |
|
| 120 | |||
| 121 | 4 | $personUri = $this->getUri(); |
|
| 122 | |||
| 123 | // serialize schema:LocalBusiness |
||
| 124 | 4 | $this->rdf .= "<$personUri> "; |
|
| 125 | 4 | foreach ( $uriVars as $uriVar => $property) { |
|
| 126 | 4 | if(!empty($this->data[$uriVar])){ |
|
| 127 | 4 | $this->addFragment("$property <%s>;", $this->data[$uriVar],false); |
|
| 128 | } |
||
| 129 | } |
||
| 130 | 4 | foreach ($stringVars as $stringVar => $property) { |
|
| 131 | 4 | if(!empty($this->data[$stringVar])){ |
|
| 132 | 4 | $this->addFragment("$property \"%s\";", $this->data[$stringVar]); |
|
| 133 | } |
||
| 134 | } |
||
| 135 | 4 | !empty($this->data['hasOptInOptOutDate'])&& $this->addFragment('botk:hasOptInOptOutDate "%s"^^xsd:dateTime;', $this->data['hasOptInOptOutDate']); |
|
| 136 | 4 | !empty($this->data['privacyFlag']) && $this->addFragment('botk:privacyFlag %s ;', $this->data['privacyFlag']); |
|
| 137 | 4 | $this->addFragment('a schema:Person.', $personUri); |
|
| 138 | |||
| 139 | 4 | if(!empty($this->data['aggregateRatingValue'])){ |
|
| 140 | $ratingUri=$this->data['base'].'rating_'.$this->data['aggregateRatingValue']. |
||
|
1 ignored issue
–
show
|
|||
| 141 | $this->rdf .= "<$personUri> schema:aggregateRating <$ratingUri>.<$ratingUri> schema:ratingValue \"{$this->data['aggregateRatingValue']}\"^^xsd:float."; |
||
|
1 ignored issue
–
show
|
|||
| 142 | $this->tripleCount +=2; |
||
| 143 | } |
||
| 144 | |||
| 145 | } |
||
| 146 | |||
| 147 | 4 | return $this->rdf; |
|
| 148 | } |
||
| 149 | |||
| 150 | } |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.