CampaignController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 22
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A indexAction() 0 15 2
1
<?php
2
3
/**
4
 * MIT License
5
 * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
6
 */
7
8
namespace SprykerEco\Yves\FactFinder\Controller;
9
10
use Generated\Shared\Transfer\FactFinderSdkProductCampaignRequestTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...CampaignRequestTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use Spryker\Yves\Kernel\Controller\AbstractController;
12
use Symfony\Component\HttpFoundation\Request;
13
14
/**
15
 * @method \SprykerEco\Yves\FactFinder\FactFinderFactory getFactory()
16
 */
17
class CampaignController extends AbstractController
18
{
19
    /**
20
     * @param \Symfony\Component\HttpFoundation\Request $request
21
     *
22
     * @return array
23
     */
24
    public function indexAction(Request $request)
25
    {
26
        $factFinderProductCampaignRequestTransfer = new FactFinderSdkProductCampaignRequestTransfer();
27
        $factFinderProductCampaignRequestTransfer->fromArray($request->query->all());
28
29
        $factFinderProductCampaignResponseTransfer = $this->getFactory()
30
            ->getFactFinderClient()
31
            ->getProductCampaigns($factFinderProductCampaignRequestTransfer);
32
33
        if (!$factFinderProductCampaignResponseTransfer->getCampaignIterator()) {
34
            return $this->jsonResponse(null, 400);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->jsonResponse(null, 400) returns the type Symfony\Component\HttpFoundation\JsonResponse which is incompatible with the documented return type array.
Loading history...
35
        }
36
        $campaigns = $factFinderProductCampaignResponseTransfer->getCampaignIterator();
37
38
        return $this->jsonResponse($campaigns);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->jsonResponse($campaigns) returns the type Symfony\Component\HttpFoundation\JsonResponse which is incompatible with the documented return type array.
Loading history...
39
    }
40
}
41