ScanResultNormalizer::normalize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
1
<?php
2
3
/*
4
 * This file is part of the Veslo project <https://github.com/symfony-doge/veslo>.
5
 *
6
 * (C) 2019 Pavel Petrov <[email protected]>.
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * @license https://opensource.org/licenses/GPL-3.0 GPL-3.0
12
 */
13
14
declare(strict_types=1);
15
16
namespace Veslo\AnthillBundle\Vacancy\Normalizer;
17
18
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
19
20
/**
21
 * Converts vacancy scan result object into a set of arrays/scalars with long text truncation
22
 */
23
class ScanResultNormalizer implements NormalizerInterface
24
{
25
    /**
26
     * Converts an object into a set of arrays/scalars
27
     *
28
     * @var NormalizerInterface
29
     */
30
    private $normalizer;
31
32
    /**
33
     * RawDataPreviewNormalizer constructor.
34
     *
35
     * @param NormalizerInterface $normalizer Converts an object into a set of arrays/scalars
36
     */
37
    public function __construct(NormalizerInterface $normalizer)
38
    {
39
        $this->normalizer = $normalizer;
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45
    public function normalize($object, $format = null, array $context = [])
46
    {
47
        $normalizedData = $this->normalizer->normalize($object, $format, $context);
48
49
        $normalizedData['vacancy']['snippet'] = '...';
50
        $normalizedData['vacancy']['text']    = '...';
51
52
        return $normalizedData;
53
    }
54
55
    /**
56
     * {@inheritdoc}
57
     */
58
    public function supportsNormalization($data, $format = null)
59
    {
60
        return $this->normalizer->supportsNormalization($data, $format);
61
    }
62
}
63