DevTaskAdmin   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 2
dl 0
loc 17
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getEditForm() 0 10 1
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
}