Code Duplication    Length = 18-19 lines in 4 locations

src/Call.php 4 locations

@@ 89-106 (lines=18) @@
86
     *
87
     * @return self
88
     */
89
    public function willThrowException(\Throwable $exception): self
90
    {
91
        if ($this->hasReturnSelf) {
92
            throw new \InvalidArgumentException(sprintf('%s: There is already a return self', __METHOD__));
93
        }
94
95
        if ($this->hasReturn) {
96
            throw new \InvalidArgumentException(sprintf('%s: There is already a return', __METHOD__));
97
        }
98
99
        if ($this->hasReturnCallback) {
100
            throw new \InvalidArgumentException(sprintf('%s: There is already a return callback', __METHOD__));
101
        }
102
103
        $this->exception = $exception;
104
105
        return $this;
106
    }
107
108
    /**
109
     * @return self
@@ 111-128 (lines=18) @@
108
    /**
109
     * @return self
110
     */
111
    public function willReturnSelf(): self
112
    {
113
        if (null !== $this->exception) {
114
            throw new \InvalidArgumentException(sprintf('%s: There is already a exception', __METHOD__));
115
        }
116
117
        if ($this->hasReturn) {
118
            throw new \InvalidArgumentException(sprintf('%s: There is already a return', __METHOD__));
119
        }
120
121
        if ($this->hasReturnCallback) {
122
            throw new \InvalidArgumentException(sprintf('%s: There is already a return callback', __METHOD__));
123
        }
124
125
        $this->hasReturnSelf = true;
126
127
        return $this;
128
    }
129
130
    /**
131
     * @param mixed $return
@@ 135-153 (lines=19) @@
132
     *
133
     * @return self
134
     */
135
    public function willReturn($return): self
136
    {
137
        if (null !== $this->exception) {
138
            throw new \InvalidArgumentException(sprintf('%s: There is already a exception', __METHOD__));
139
        }
140
141
        if ($this->hasReturnSelf) {
142
            throw new \InvalidArgumentException(sprintf('%s: There is already a return self', __METHOD__));
143
        }
144
145
        if ($this->hasReturnCallback) {
146
            throw new \InvalidArgumentException(sprintf('%s: There is already a return callback', __METHOD__));
147
        }
148
149
        $this->hasReturn = true;
150
        $this->return = $return;
151
152
        return $this;
153
    }
154
155
    /**
156
     * @return self
@@ 158-176 (lines=19) @@
155
    /**
156
     * @return self
157
     */
158
    public function willReturnCallback(callable $returnCallback): self
159
    {
160
        if (null !== $this->exception) {
161
            throw new \InvalidArgumentException(sprintf('%s: There is already a exception', __METHOD__));
162
        }
163
164
        if ($this->hasReturnSelf) {
165
            throw new \InvalidArgumentException(sprintf('%s: There is already a return self', __METHOD__));
166
        }
167
168
        if ($this->hasReturn) {
169
            throw new \InvalidArgumentException(sprintf('%s: There is already a return', __METHOD__));
170
        }
171
172
        $this->hasReturnCallback = true;
173
        $this->returnCallback = $returnCallback;
174
175
        return $this;
176
    }
177
178
    /**
179
     * @return string