1<?php
2
3namespace Illuminate\Validation;
4
5use Illuminate\Contracts\Support\Arrayable;
6use Illuminate\Support\Traits\Macroable;
7use Illuminate\Validation\Rules\Dimensions;
8use Illuminate\Validation\Rules\Exists;
9use Illuminate\Validation\Rules\In;
10use Illuminate\Validation\Rules\NotIn;
11use Illuminate\Validation\Rules\RequiredIf;
12use Illuminate\Validation\Rules\Unique;
13
14class Rule
15{
16    use Macroable;
17
18    /**
19     * Get a dimensions constraint builder instance.
20     *
21     * @param  array  $constraints
22     * @return \Illuminate\Validation\Rules\Dimensions
23     */
24    public static function dimensions(array $constraints = [])
25    {
26        return new Dimensions($constraints);
27    }
28
29    /**
30     * Get an exists constraint builder instance.
31     *
32     * @param  string  $table
33     * @param  string  $column
34     * @return \Illuminate\Validation\Rules\Exists
35     */
36    public static function exists($table, $column = 'NULL')
37    {
38        return new Exists($table, $column);
39    }
40
41    /**
42     * Get an in constraint builder instance.
43     *
44     * @param  \Illuminate\Contracts\Support\Arrayable|array|string  $values
45     * @return \Illuminate\Validation\Rules\In
46     */
47    public static function in($values)
48    {
49        if ($values instanceof Arrayable) {
50            $values = $values->toArray();
51        }
52
53        return new In(is_array($values) ? $values : func_get_args());
54    }
55
56    /**
57     * Get a not_in constraint builder instance.
58     *
59     * @param  \Illuminate\Contracts\Support\Arrayable|array|string  $values
60     * @return \Illuminate\Validation\Rules\NotIn
61     */
62    public static function notIn($values)
63    {
64        if ($values instanceof Arrayable) {
65            $values = $values->toArray();
66        }
67
68        return new NotIn(is_array($values) ? $values : func_get_args());
69    }
70
71    /**
72     * Get a required_if constraint builder instance.
73     *
74     * @param  callable|bool  $callback
75     * @return \Illuminate\Validation\Rules\RequiredIf
76     */
77    public static function requiredIf($callback)
78    {
79        return new RequiredIf($callback);
80    }
81
82    /**
83     * Get a unique constraint builder instance.
84     *
85     * @param  string  $table
86     * @param  string  $column
87     * @return \Illuminate\Validation\Rules\Unique
88     */
89    public static function unique($table, $column = 'NULL')
90    {
91        return new Unique($table, $column);
92    }
93}
94