Code Duplication    Length = 39-42 lines in 2 locations

Ui/Component/Column/Code/Options.php 1 location

@@ 11-49 (lines=39) @@
8
 * Class Options
9
 * @package LizardMedia\CronScheduler\Ui\Component\Column\Code
10
 */
11
class Options implements OptionSourceInterface
12
{
13
    /**
14
     * @var array
15
     */
16
    protected $options = [];
17
18
    /**
19
     * @var ConfigInterface
20
     */
21
    private $cronConfig;
22
23
    /**
24
     * Options constructor.
25
     * @param ConfigInterface $cronConfig
26
     */
27
    public function __construct(
28
        ConfigInterface $cronConfig
29
    ) {
30
        $this->cronConfig = $cronConfig;
31
    }
32
33
    /**
34
     * Get all options available
35
     * @return array
36
     */
37
    public function toOptionArray()
38
    {
39
        if (empty($this->options)) {
40
            $cronConfigJobs = $this->cronConfig->getJobs();
41
            foreach (array_values($cronConfigJobs) as $jobs) {
42
                foreach (array_keys($jobs) as $code) {
43
                    array_push($this->options, ['label' => $code, 'value' => $code]);
44
                }
45
            }
46
        }
47
        return $this->options;
48
    }
49
}
50

Ui/Component/Column/Group/Options.php 1 location

@@ 12-53 (lines=42) @@
9
 * Class Options
10
 * @package LizardMedia\CronScheduler\Ui\Component\Column\Group
11
 */
12
class Options implements OptionSourceInterface
13
{
14
    /**
15
     * @var array
16
     */
17
    protected $options = [];
18
19
    /**
20
     * @var ConfigInterface
21
     */
22
    public $cronConfig;
23
24
    /**
25
     * Options constructor.
26
     * @param ConfigInterface $cronConfig
27
     */
28
    public function __construct(
29
        ConfigInterface $cronConfig
30
    ) {
31
        $this->cronConfig = $cronConfig;
32
    }
33
34
    /**
35
     * @return array
36
     */
37
    public function toOptionArray()
38
    {
39
        if (empty($this->options)) {
40
            $configCronJobs = $this->cronConfig->getJobs();
41
            foreach (array_keys($configCronJobs) as $group) {
42
                array_push(
43
                    $this->options,
44
                    [
45
                        'label' => $group,
46
                        'value' => $group
47
                    ]
48
                );
49
            }
50
        }
51
        return $this->options;
52
    }
53
}
54