| Conditions | 24 | 
| Paths | 1158 | 
| Total Lines | 103 | 
| Code Lines | 61 | 
| Lines | 0 | 
| Ratio | 0 % | 
| 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  | 
            ||
| 145 | public function read(JsonReadable $reader)  | 
            ||
| 146 |     { | 
            ||
| 147 |         if ($this->skipDeserialize) { | 
            ||
| 148 | $reader->skipValue();  | 
            ||
| 149 | return null;  | 
            ||
| 150 | }  | 
            ||
| 151 | |||
| 152 |         if ($reader->peek() === JsonToken::NULL) { | 
            ||
| 153 | $reader->nextNull();  | 
            ||
| 154 | return null;  | 
            ||
| 155 | }  | 
            ||
| 156 | |||
| 157 | $object = $this->objectConstructor->construct();  | 
            ||
| 158 | $exclusionData = $this->hasClassDeserializationStrategies || $this->hasPropertyDeserializationStrategies  | 
            ||
| 159 | ? new DefaultDeserializationExclusionData(  | 
            ||
| 160 | $reader->getPayload(),  | 
            ||
| 161 | clone $object,  | 
            ||
| 162 | $reader->getContext(),  | 
            ||
| 163 |                 function() use ($reader) { return $reader->getPath(); } | 
            ||
| 164 | )  | 
            ||
| 165 | : null;  | 
            ||
| 166 | |||
| 167 |         if ($this->hasClassDeserializationStrategies && $exclusionData) { | 
            ||
| 168 | $this->excluder->applyClassDeserializationExclusionData($exclusionData);  | 
            ||
| 169 | |||
| 170 |             if ($this->excluder->excludeClassByDeserializationStrategy($this->classMetadata)) { | 
            ||
| 171 | $reader->skipValue();  | 
            ||
| 172 | return null;  | 
            ||
| 173 | }  | 
            ||
| 174 | }  | 
            ||
| 175 | |||
| 176 |         if ($this->hasPropertyDeserializationStrategies && $exclusionData) { | 
            ||
| 177 | $this->excluder->applyPropertyDeserializationExclusionData($exclusionData);  | 
            ||
| 178 | }  | 
            ||
| 179 | |||
| 180 | $reader->beginObject();  | 
            ||
| 181 | |||
| 182 |         if ($this->classVirtualProperty !== null) { | 
            ||
| 183 | $reader->nextName();  | 
            ||
| 184 | $reader->beginObject();  | 
            ||
| 185 | }  | 
            ||
| 186 | |||
| 187 | $usesExisting = $reader->getContext()->usesExistingObject();  | 
            ||
| 188 | |||
| 189 |         while ($reader->hasNext()) { | 
            ||
| 190 | $name = $reader->nextName();  | 
            ||
| 191 | $property = $this->propertyCache[$name] ?? $this->propertyCache[$name] = $this->properties->getBySerializedName($name);  | 
            ||
| 192 | |||
| 193 |             if ($property === null) { | 
            ||
| 194 | $reader->skipValue();  | 
            ||
| 195 | continue;  | 
            ||
| 196 | }  | 
            ||
| 197 | |||
| 198 | $realName = $property->getName();  | 
            ||
| 199 | |||
| 200 | if (  | 
            ||
| 201 | $property->skipDeserialize()  | 
            ||
| 202 | || (  | 
            ||
| 203 | $this->hasPropertyDeserializationStrategies && $exclusionData  | 
            ||
| 204 | && $this->excluder->excludePropertyByDeserializationStrategy($property)  | 
            ||
| 205 | )  | 
            ||
| 206 |             ) { | 
            ||
| 207 | $reader->skipValue();  | 
            ||
| 208 | continue;  | 
            ||
| 209 | }  | 
            ||
| 210 | |||
| 211 | $adapter = $this->adapters[$realName] ?? null;  | 
            ||
| 212 |             if ($adapter === null) { | 
            ||
| 213 | /** @var JsonAdapter $jsonAdapterAnnotation */  | 
            ||
| 214 | $jsonAdapterAnnotation = $property->getAnnotations()->get(JsonAdapter::class);  | 
            ||
| 215 | $adapter = null === $jsonAdapterAnnotation  | 
            ||
| 216 | ? $this->typeAdapterProvider->getAdapter($property->getType())  | 
            ||
| 217 | : $this->typeAdapterProvider->getAdapterFromAnnotation(  | 
            ||
| 218 | $property->getType(),  | 
            ||
| 219 | $jsonAdapterAnnotation  | 
            ||
| 220 | );  | 
            ||
| 221 | $this->adapters[$realName] = $adapter;  | 
            ||
| 222 | }  | 
            ||
| 223 | |||
| 224 |             if ($adapter instanceof ObjectConstructorAware && $usesExisting) { | 
            ||
| 225 |                 try { | 
            ||
| 226 | $nestedObject = $property->get($object);  | 
            ||
| 227 |                 } /** @noinspection BadExceptionsProcessingInspection */ catch (TypeError $error) { | 
            ||
| 228 | // this may occur when attempting to get a nested object that doesn't exist and  | 
            ||
| 229 | // the method return is not nullable. The type error only occurs because we are  | 
            ||
| 230 | // may be calling the getter before data exists.  | 
            ||
| 231 | $nestedObject = null;  | 
            ||
| 232 | }  | 
            ||
| 233 | |||
| 234 |                 if ($nestedObject !== null) { | 
            ||
| 235 | $adapter->setObjectConstructor(new CreateFromInstance($nestedObject));  | 
            ||
| 236 | }  | 
            ||
| 237 | }  | 
            ||
| 238 | |||
| 239 | $property->set($object, $adapter->read($reader));  | 
            ||
| 240 | }  | 
            ||
| 241 | $reader->endObject();  | 
            ||
| 242 | |||
| 243 |         if ($this->classVirtualProperty !== null) { | 
            ||
| 244 | $reader->endObject();  | 
            ||
| 245 | }  | 
            ||
| 246 | |||
| 247 | return $object;  | 
            ||
| 248 | }  | 
            ||
| 324 |