Code Duplication    Length = 13-13 lines in 2 locations

src/Elements/Select.php 2 locations

@@ 55-67 (lines=13) @@
52
     *
53
     * @return static
54
     */
55
    public function options($options)
56
    {
57
        return $this->addChildren($options, function ($text, $value) {
58
            if (is_array($text)) {
59
                return $this->optgroup($value, $text);
60
            }
61
62
            return Option::create()
63
                ->value($value)
64
                ->text($text)
65
                ->selectedIf($value === $this->value);
66
        });
67
    }
68
69
    /**
70
     * @param string $label
@@ 75-87 (lines=13) @@
72
     *
73
     * @return static
74
     */
75
    public function optgroup($label, $options)
76
    {
77
        return Optgroup::create()
78
            ->label($label)
79
            ->addChildren($options, function ($text, $value) {
80
                return Option::create()
81
                    ->value($value)
82
                    ->text($text)
83
                    ->selectedIf($value === $this->value);
84
            });
85
86
        return $this->addChild($optgroup);
87
    }
88
89
    /**
90
     * @param string|null $text