Passed
Push — feature/52 ( 26e983...2a77ff )
by Max
03:01 queued 02:33
created

SurveyEnvelope   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 22 1
A value() 0 3 1
1
<?php
2
3
namespace MaxGoryunov\SavingIterator\Fakes;
4
5
use Closure;
6
use MaxGoryunov\SavingIterator\Src\Scalar;
7
8
/**
9
 * Class for wrapping divergent program flows. It allows to structure a program
10
 * in such a way that there will be no need for a variable if it exists only in
11
 * order to be used in two places.
12
 * @todo #52:20min Create test file for this class and maybe change tests for
13
 *  `Let` and `The`.
14
 * @template X subject type
15
 * @template Y result type
16
 * @implements \MaxGoryunov\SavingIterator\Src\Scalar<Y>
17
 */
18
abstract class SurveyEnvelope implements Scalar
19
{
20
21
    /**
22
     * Ctor.
23
     * 
24
     * @phpstan-param X                                $subject
25
     * @phpstan-param Closure(X): mixed                $context
26
     * @phpstan-param Closure(X, Closure(X): mixed): Y $usage
27
     * @param mixed   $subject element to be used in some context
28
     * @param Closure $context context for element
29
     * @param Closure $usage   way of combining element and context
30
     */
31
    public function __construct(
32
        /**
33
         * Element to be used in some context.
34
         * 
35
         * @var X
36
         */
37
        private mixed $subject,
38
39
        /**
40
         * Context for element.
41
         * 
42
         * @var Closure(X): mixed
43
         */
44
        private Closure $context,
45
46
        /**
47
         * way of combining element and context.
48
         * 
49
         * @var Closure(X, Closure(X): mixed): Y
50
         */
51
        private Closure $usage
52
    ) {
53
    }
54
55
    /**
56
     * Returns result of applying context to element.
57
     *
58
     * @return Y
0 ignored issues
show
Bug introduced by
The type MaxGoryunov\SavingIterator\Fakes\Y 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...
59
     */
60
    public final function value(): mixed
61
    {
62
        return ($this->usage)($this->subject, $this->context);
63
    }
64
}
65