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

DefaultProvider::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12

Duplication

Lines 12
Ratio 100 %

Importance

Changes 0
Metric Value
dl 12
loc 12
rs 9.8666
c 0
b 0
f 0
cc 1
nc 1
nop 4
1
<?php
2
3
namespace Netgen\InformationCollection\Core\EmailDataProvider;
4
5
use Netgen\InformationCollection\API\Action\EmailDataProviderInterface;
6
use Netgen\InformationCollection\API\Value\Event\InformationCollected;
7
use Symfony\Component\Mime\Email;
8
use eZ\Publish\Core\MVC\ConfigResolverInterface;
9
use Netgen\InformationCollection\Core\Action\EmailAction;
10
use function array_key_exists;
11
use eZ\Publish\API\Repository\Values\Content\Field;
12
use eZ\Publish\Core\FieldType\BinaryFile\Value as BinaryFile;
13
use eZ\Publish\Core\Helper\FieldHelper;
14
use eZ\Publish\Core\Helper\TranslationHelper;
15
use Netgen\InformationCollection\API\Value\DataTransfer\EmailContent;
16
use Netgen\InformationCollection\API\Constants;
17
use Netgen\InformationCollection\API\ConfigurationConstants;
18
use Netgen\InformationCollection\API\Exception\MissingEmailBlockException;
19
use Netgen\InformationCollection\API\Exception\MissingValueException;
20
use Netgen\InformationCollection\API\Value\DataTransfer\TemplateContent;
21
use function trim;
22
use Twig\Environment;
23
24
class DefaultProvider implements EmailDataProviderInterface
25
{
26
    /**
27
     * @var array
28
     */
29
    protected $configResolver;
30
31
    /**
32
     * @var \eZ\Publish\Core\Helper\TranslationHelper
33
     */
34
    protected $translationHelper;
35
36
    /**
37
     * @var \eZ\Publish\Core\Helper\FieldHelper
38
     */
39
    protected $fieldHelper;
40
41
    /**
42
     * @var \Twig\Environment
43
     */
44
    protected $twig;
45
46
    /**
47
     * EmailDataFactory constructor.
48
     *
49
     * @param array $config
0 ignored issues
show
Documentation introduced by
There is no parameter named $config. Did you maybe mean $configResolver?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

Consider the following example. The parameter $ireland is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $ireland
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was changed, but the annotation was not.

Loading history...
50
     * @param \eZ\Publish\Core\Helper\TranslationHelper $translationHelper
51
     * @param \eZ\Publish\Core\Helper\FieldHelper $fieldHelper
52
     * @param \Twig\Environment $twig
53
     */
54 View Code Duplication
    public function __construct(
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
55
        ConfigResolverInterface $configResolver,
56
        TranslationHelper $translationHelper,
57
        FieldHelper $fieldHelper,
58
        Environment $twig
59
    ) {
60
        $this->configResolver = $configResolver;
0 ignored issues
show
Documentation Bug introduced by
It seems like $configResolver of type object<eZ\Publish\Core\M...onfigResolverInterface> is incompatible with the declared type array of property $configResolver.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
61
        $this->config = $this->configResolver->getParameter('action_config', 'netgen_information_collection')[EmailAction::$defaultName];
0 ignored issues
show
Bug introduced by
The property config does not seem to exist. Did you mean configResolver?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
62
        $this->translationHelper = $translationHelper;
63
        $this->fieldHelper = $fieldHelper;
64
        $this->twig = $twig;
65
    }
66
67
    /**
68
     * Factory method.
69
     *
70
     * @param InformationCollected $value
71
     *
72
     * @return EmailContent
73
     */
74 View Code Duplication
    public function build(InformationCollected $value): EmailContent
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
75
    {
76
        $contentType = $value->getContentType();
77
78
        $template = $this->resolveTemplate($contentType->identifier);
0 ignored issues
show
Bug introduced by
The method resolveTemplate() does not seem to exist on object<Netgen\Informatio...ovider\DefaultProvider>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
79
80
        $templateWrapper = $this->twig->load($template);
81
        $data = new TemplateContent($value, $templateWrapper);
82
83
        $body = $this->resolveBody($data);
0 ignored issues
show
Bug introduced by
The method resolveBody() does not seem to exist on object<Netgen\Informatio...ovider\DefaultProvider>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
84
85
        return new EmailContent(
86
            $this->resolveEmail($data, Constants::FIELD_RECIPIENT),
0 ignored issues
show
Bug introduced by
The method resolveEmail() does not seem to exist on object<Netgen\Informatio...ovider\DefaultProvider>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
87
            $this->resolveEmail($data, Constants::FIELD_SENDER),
0 ignored issues
show
Bug introduced by
The method resolveEmail() does not seem to exist on object<Netgen\Informatio...ovider\DefaultProvider>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
88
            $this->resolve($data, Constants::FIELD_SUBJECT),
0 ignored issues
show
Bug introduced by
The method resolve() does not seem to exist on object<Netgen\Informatio...ovider\DefaultProvider>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
89
            $body,
90
            $this->resolveAttachments($contentType->identifier, $value->getInformationCollectionStruct()->getFieldsData())
0 ignored issues
show
Bug introduced by
The method resolveAttachments() does not seem to exist on object<Netgen\Informatio...ovider\DefaultProvider>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
91
        );
92
    }
93
94
    public function provide(InformationCollected $value): Email
95
    {
96
        return new Email();
97
    }
98
}
99