public function toArray($instance)
 {
     $ref = new ReflectionClass($instance);
     $fields = $ref->getProperties();
     $result = array();
     foreach ($fields as $field) {
         if ($this->reflectionHelper->hasAnnotation($field->getDocComment(), 'jsonIgnore')) {
             continue;
         }
         if ($this->reflectionHelper->hasAnnotation($field->getDocComment(), 'calculatedBy')) {
             $annotations = $this->reflectionHelper->getAnnotations($field->getDocComment());
             $calculatedByAnnotations = $annotations->getWithName('calculatedBy');
             $values = $calculatedByAnnotations[0]->getValues();
             $instance->{$values}[0]();
         }
         $field->setAccessible(true);
         $value = $field->getValue($instance);
         if (!is_null($value)) {
             $result[$field->getName()] = $this->getValue($value);
         }
     }
     return $result;
 }