GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#73)
by
unknown
14:32
created

FieldRenderingRuntime   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 4
dl 0
loc 49
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A renderField() 0 11 2
A getRenderFieldBlockName() 0 6 1
A getDefaultRenderFieldBlockName() 0 4 1
A getTemplate() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Netgen\Bundle\InformationCollectionBundle\Templating\Twig\Extensions;
6
7
use eZ\Publish\Core\MVC\ConfigResolverInterface;
8
use Netgen\InformationCollection\API\Value\Attribute;
9
use Netgen\InformationCollection\API\Value\Collection;
10
use Twig\Environment;
11
use Twig\TemplateWrapper;
12
13
class FieldRenderingRuntime
14
{
15
    public const FIELD_VIEW_SUFFIX = '_field';
16
17
    /**
18
     * @var \Twig\Environment
19
     */
20
    protected $environment;
21
22
    /**
23
     * @var \eZ\Publish\Core\MVC\ConfigResolverInterface
24
     */
25
    protected $configResolver;
26
27
    public function __construct(Environment $environment, ConfigResolverInterface $configResolver)
28
    {
29
        $this->environment = $environment;
30
        $this->configResolver = $configResolver;
31
    }
32
33
    public function renderField(Collection $collection, Attribute $attribute): string
34
    {
35
        $template = $this->getTemplate();
36
        $blockName = $this->getRenderFieldBlockName($attribute);
37
38
        if (!$template->hasBlock($blockName)) {
39
            return $template->renderBlock($this->getDefaultRenderFieldBlockName(), ['collection' => $collection, 'attribute' => $attribute]);
40
        }
41
42
        return $template->renderBlock($blockName, ['collection' => $collection, 'attribute' => $attribute]);
43
    }
44
45
    protected function getRenderFieldBlockName(Attribute $attribute): string
46
    {
47
        $fieldTypeIdentifier = $attribute->getFieldDefinition()->fieldTypeIdentifier;
48
49
        return $fieldTypeIdentifier . self::FIELD_VIEW_SUFFIX;
50
    }
51
52
    protected function getDefaultRenderFieldBlockName(): string
53
    {
54
        return 'default' . self::FIELD_VIEW_SUFFIX;
55
    }
56
57
    protected function getTemplate(): TemplateWrapper
58
    {
59
        return $this->environment->load('@NetgenInformationCollection/admin/content_fields.html.twig');
60
    }
61
}
62