Passed
Push — feature/52 ( 2416fc )
by Max
03:02
created

SurveyEnvelope::value()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 3
rs 10
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
 * @template X subject type
13
 * @template Y result type
14
 * @implements Scalar<Y>
15
 */
16
abstract class SurveyEnvelope implements Scalar
17
{
18
19
    /**
20
     * Ctor.
21
     * 
22
     * @phpstan-param X                                $subject
23
     * @phpstan-param Closure(X): mixed                $context
24
     * @phpstan-param Closure(X, Closure(X): mixed): Y $usage
25
     * @param mixed   $subject element to be used in some context
26
     * @param Closure $context context for element
27
     * @param Closure $usage   way of combining element and context
28
     */
29
    public function __construct(
30
        /**
31
         * Element to be used in some context.
32
         * 
33
         * @var X
34
         */
35
        private mixed $subject,
36
37
        /**
38
         * Context for element.
39
         * 
40
         * @var Closure(X): mixed
41
         */
42
        private Closure $context,
43
44
        /**
45
         * way of combining element and context.
46
         * 
47
         * @var Closure(X, Closure(X): mixed): Y
48
         */
49
        private Closure $usage
50
    ) {
51
    }
52
53
    /**
54
     * Returns result of applying context to element.
55
     *
56
     * @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...
57
     */
58
    public final function value(): mixed
59
    {
60
        return ($this->usage)($this->subject, $this->context);
61
    }
62
}
63