DateTime   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
1
<?php
2
3
namespace app\models\types;
4
5
use Yii;
6
use app\models\ContentType;
7
8
/**
9
 * This is the model class for DateTime content type.
10
 */
11
class DateTime extends ContentType
12
{
13
    public $selfUpdate = true;
14
    public $html = '<span class="datetime"></span>';
15
    public $css = '%field% { text-align: center; vertical-align: middle; }';
16
    public $input = 'none';
17
    public $output = 'raw';
18
    public $usable = true;
19
    public $js = <<<'EOT'
20
{
21
  var $f = $('%field%');
22
  if (!$f.length) { return; }
23
  var $d = $f.find('.date');
24
  var $t = $f.find('.time');
25
  var $dt = $f.find('.datetime');
26
  var dF = '';
27
  function setDateTime() {
28
    var m = moment();
29
    $d.html(m.format('DD/MM/YYYY'));
30
    $t.html(m.format('HH:mm:ss'));
31
    $dt.html(m.format('DD/MM/YYYY<br />HH:mm:ss'));
32
  }
33
  setInterval(setDateTime, 1000);
34
  setDateTime();
35
  $f.show();
36
  $f.textfill({maxFontPixels: 0});
37
}
38
EOT;
39
40
    /**
41
     * {@inheritdoc}
42
     */
43
    public function __construct($config = [])
44
    {
45
        parent::__construct($config);
46
        $this->name = Yii::t('app', 'Date&Time');
47
    }
48
}
49