1
<?php
2

3
namespace Nuwave\Lighthouse\Validation;
4

5
use Illuminate\Support\Arr;
6
use Nuwave\Lighthouse\Execution\Arguments\ArgumentSet;
7
use Nuwave\Lighthouse\Support\Contracts\ArgumentSetValidation;
8

9
abstract class Validator implements ArgumentSetValidation
10
{
11
    /**
12
     * The slice of incoming arguments to validate.
13
     *
14
     * @var \Nuwave\Lighthouse\Execution\Arguments\ArgumentSet
15
     */
16
    protected $args;
17

18 1
    public function messages(): array
19
    {
20 1
        return [];
21
    }
22

23 1
    public function attributes(): array
24
    {
25 1
        return [];
26
    }
27

28
    /**
29
     * Set the slice of args to validate.
30
     */
31 1
    public function setArgs(ArgumentSet $args): void
32
    {
33 1
        $this->args = $args;
34
    }
35

36
    /**
37
     * Retrieve the value of an argument.
38
     *
39
     * @param  string  $key  The key of the argument, may use dot notation to get nested values.
40
     * @param  mixed|null   $default  Returned in case the argument is not present.
41
     * @return mixed  The value of the argument or the default.
42
     */
43 0
    protected function arg(string $key, $default = null)
44
    {
45 0
        return Arr::get(
46 0
            $this->args->toArray(),
47 0
            $key,
48 0
            $default
49
        );
50
    }
51
}

Read our documentation on viewing source code .

Loading