AbstractRequest::validate()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 3
nc 3
nop 1
1
<?php
2
/**
3
 * @link https://github.com/phpviet/omnipay-momo
4
 * @copyright (c) PHP Viet
5
 * @license [MIT](http://www.opensource.org/licenses/MIT)
6
 */
7
8
namespace Omnipay\MoMo\Message;
9
10
use Omnipay\MoMo\Support\Arr;
11
use Omnipay\MoMo\Concerns\Parameters;
12
use Omnipay\Common\Exception\InvalidRequestException;
13
use Omnipay\Common\Message\AbstractRequest as BaseAbstractRequest;
14
15
/**
16
 * @author Vuong Minh <[email protected]>
17
 * @since 1.0.0
18
 */
19
abstract class AbstractRequest extends BaseAbstractRequest
20
{
21
    use Parameters;
22
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function validate(...$parameters): void
27
    {
28
        $listParameters = $this->getParameters();
29
30
        foreach ($parameters as $parameter) {
31
            if (null === Arr::getValue($parameter, $listParameters)) {
32
                throw new InvalidRequestException(sprintf('The `%s` parameter is required', $parameter));
33
            }
34
        }
35
    }
36
}
37