DevTaskAdmin::getEditForm()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
namespace Webtorque\DevTaskRunner\Admin;
4
5
use SilverStripe\Admin\ModelAdmin;
6
use Webtorque\DevTaskRunner\Model\DevTaskRun;
7
use Webtorque\DevTaskRunner\DevTaskRunnerCronTask;
8
use Cron\CronExpression;
9
use SilverStripe\Forms\LiteralField;
10
11
class DevTaskAdmin extends ModelAdmin
12
{
13
    private static $managed_models = array(DevTaskRun::class);
0 ignored issues
show
Unused Code introduced by
The property $managed_models is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
14
    private static $menu_title = 'Dev Tasks';
0 ignored issues
show
Unused Code introduced by
The property $menu_title is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
15
    private static $url_segment = 'dev-tasks';
0 ignored issues
show
Unused Code introduced by
The property $url_segment is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
16
17
    public function getEditForm($id = null, $fields = null)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
18
    {
19
        $form = parent::getEditForm($id, $fields);
20
        $task = new DevTaskRunnerCronTask();
21
        $cron = CronExpression::factory($task->getSchedule());
22
        $nextRun = $cron->getNextRunDate()->format('Y-m-d H:i:s');
23
        $form->Fields()->unshift(LiteralField::create('NextRunMessage', '<p class="message">Next run at ' . $nextRun . '</p>'));
24
25
        return $form;
26
    }
27
}