Ajde_Layout::getFormat()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
class Ajde_Layout extends Ajde_Template
4
{
5
    public function __construct($name, $style = 'default', $format = null)
6
    {
7
        $this->setName($name);
8
        $this->setStyle($style);
9
10
        $base = LAYOUT_DIR.$this->getName().DIRECTORY_SEPARATOR;
11
        $action = $this->getStyle();
12
        if (!$format) {
13
            if ((Ajde_Http_Request::isAjax() && $this->exist($base, $action, 'ajax'))
14
                || Ajde::app()->getDocument()->getFormat() === 'ajax'
0 ignored issues
show
Documentation Bug introduced by
The method getFormat does not exist on object<Ajde_Document>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
15
            ) {
16
                $format = 'ajax';
17
            } else {
18
                if (Ajde::app()->getDocument()->getFormat() === 'crud') {
0 ignored issues
show
Documentation Bug introduced by
The method getFormat does not exist on object<Ajde_Document>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
19
                    $format = 'crud';
20
                } else {
21
                    $format = 'html';
22
                }
23
            }
24
        }
25
        parent::__construct($base, $action, $format);
26
    }
27
28
    public function setName($name)
29
    {
30
        $this->set('name', $name);
31
    }
32
33
    public function setStyle($style)
34
    {
35
        $this->set('style', $style);
36
    }
37
38
    public function getName()
39
    {
40
        return $this->get('name');
41
    }
42
43
    public function getStyle()
44
    {
45
        return $this->get('style');
46
    }
47
48
    public function getFormat()
49
    {
50
        return $this->get('format');
51
    }
52
53
    public function getDocument()
54
    {
55
        return $this->get('document');
56
    }
57
58
    public function setDocument(Ajde_Document $document)
59
    {
60
        return $this->set('document', $document);
61
    }
62
63
    public function getDefaultResourcePosition()
64
    {
65
        return Ajde_Document_Format_Html::RESOURCE_POSITION_FIRST;
66
    }
67
68
    public function requireTimeoutWarning()
69
    {
70
        $this->requireJs('core.timeout', 'html', LAYOUT_DIR.'admin/');
0 ignored issues
show
Documentation Bug introduced by
The method requireJs does not exist on object<Ajde_Layout>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
71
    }
72
}
73