Code Duplication    Length = 15-15 lines in 2 locations

src/Traits/PreparesCustomRulesForFormRequest.php 1 location

@@ 7-21 (lines=15) @@
4
5
use BrightComponents\Valid\CustomRule;
6
7
trait PreparesCustomRulesForFormRequest
8
{
9
    /**
10
     * Set the validator and request properties on Custom Rules.
11
     */
12
    public function prepareCustomRules()
13
    {
14
        collect($this->rules())->each(function ($rules, $attribute) {
15
            collect(array_wrap($rules))->whereInstanceOf(CustomRule::class)->each(function ($rule) {
16
                $rule::validator($this->getValidatorInstance());
17
                $rule::request($this);
18
            });
19
        });
20
    }
21
}
22

src/Traits/PreparesCustomRulesForServiceValidator.php 1 location

@@ 7-21 (lines=15) @@
4
5
use BrightComponents\Valid\CustomRule;
6
7
trait PreparesCustomRulesForServiceValidator
8
{
9
    /**
10
     * Set the validator and service validator properties on Custom Rules.
11
     */
12
    public function prepareCustomRules()
13
    {
14
        collect($this->rules())->each(function ($rules, $attribute) {
15
            collect(array_wrap($rules))->whereInstanceOf(CustomRule::class)->each(function ($rule) {
16
                $rule::validator($this->getValidator());
17
                $rule::service($this);
18
            });
19
        });
20
    }
21
}
22