Facade   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
eloc 8
c 2
b 0
f 0
dl 0
loc 24
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getRequest() 0 5 2
A sanitize() 0 5 1
A getParamsWrapperKey() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * Base Infra Class
6
 * @category    Ticaje
7
 * @author      Max Demian <[email protected]>
8
 */
9
10
namespace Ticaje\AeSdk\Domain\Endpoint\Solution\Product;
11
12
/**
13
 * Trait Facade
14
 * @package Ticaje\AeSdk\Domain\Endpoint\Solution\Product
15
 */
16
trait Facade
17
{
18
    public function getRequest(): array
19
    {
20
        $sanitized = $this->sanitize();
21
        $result = $sanitized ? [$this->getParamsKey() => $sanitized] : [];
0 ignored issues
show
Bug introduced by
The method getParamsKey() does not exist on Ticaje\AeSdk\Domain\Endp...Solution\Product\Facade. Did you maybe mean getParamsWrapperKey()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

21
        $result = $sanitized ? [$this->/** @scrutinizer ignore-call */ getParamsKey() => $sanitized] : [];

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...
22
        return $result;
23
    }
24
25
    /**
26
     * @return array|null
27
     * We have allowed ourselves to comply with a small business constraint since normal product post demands it.
28
     * It would be fine to enforce that product post interface wrapping key is passed along properly. UT to the rescue...
29
     */
30
    private function sanitize()
31
    {
32
        $built = $this->build();
0 ignored issues
show
Bug introduced by
It seems like build() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

32
        /** @scrutinizer ignore-call */ 
33
        $built = $this->build();
Loading history...
33
        $clean = $built[static::PARAMS_WRAPPER_KEY] ?? null;
0 ignored issues
show
Bug introduced by
The constant Ticaje\AeSdk\Domain\Endp...ade::PARAMS_WRAPPER_KEY was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
34
        return $clean;
35
    }
36
37
    public function getParamsWrapperKey(): string
38
    {
39
        return static::PARAMS_WRAPPER_KEY;
0 ignored issues
show
Bug introduced by
The constant Ticaje\AeSdk\Domain\Endp...ade::PARAMS_WRAPPER_KEY was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
40
    }
41
}
42