StringField   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 7
dl 0
loc 24
c 0
b 0
f 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B getDocumentFieldValue() 0 18 7
1
<?php
2
3
namespace Mdiyakov\DoctrineSolrBundle\Schema\Field\Entity;
4
5
class StringField extends Field
6
{
7
    /**
8
     * @param object $entity
9
     * @return string
10
     */
11
    public function getDocumentFieldValue($entity)
12
    {
13
        $entityValue = $this->getEntityFieldValue($entity);
14
        $documentValue = '';
15
        if (is_scalar($entityValue)) {
16
            $documentValue = strval($entityValue);
17
        } elseif (is_array($entityValue) || $entityValue instanceof \Iterator || $entityValue instanceof \IteratorAggregate) {
18
            $documentValue = [];
19
            foreach ($entityValue as $value) {
20
                $documentValue[] = (string) $value;
21
            }
22
23
            $documentValue = join(',', $documentValue);
24
        } elseif (is_object($entityValue)) {
25
            $documentValue = (string) $entityValue;
26
        }
27
28
        return $documentValue;
29
    }
30
}