Completed
Push — develop ( bfc0af...88d3fd )
by
unknown
08:28
created

EmptySummaryAwareTrait::getEmptySummaryNotice()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 8
rs 9.4285
cc 2
eloc 4
nc 2
nop 0
1
<?php
2
/**
3
 * YAWIK
4
 *
5
 * @filesource
6
 * @copyright (c) 2013 - 2016 Cross Solution (http://cross-solution.de)
7
 * @license   MIT
8
 */
9
namespace Core\Form;
10
11
/**
12
 *
13
 * @author fedys
14
 * @since 0.26
15
 */
16
trait EmptySummaryAwareTrait
17
{
18
19
    /**
20
     * The empty summary notice.
21
     *
22
     * @var string
23
     */
24
    protected $emptySummaryNotice;
25
26
    /**
27
     * @see \Core\Form\EmptySummaryAwareInterface::isSummaryEmpty()
28
     */
29
    public function isSummaryEmpty()
30
    {
31
        foreach ($this as $element) { /* @var $element \Zend\Form\ElementInterface */
0 ignored issues
show
Bug introduced by
The expression $this of type this<Core\Form\EmptySummaryAwareTrait> is not traversable.
Loading history...
32
            if ($element->getValue()) {
33
                return false;
34
            }
35
        }
36
        return true;
37
    }
38
39
    /**
40
     * @see \Core\Form\EmptySummaryAwareInterface::setEmptySummaryNotice()
41
     */
42
    public function setEmptySummaryNotice($message)
43
    {
44
        $this->emptySummaryNotice = $message;
45
        return $this;
46
    }
47
48
    /**
49
     * @see \Core\Form\EmptySummaryAwareInterface::getEmptySummaryNotice()
50
     */
51
    public function getEmptySummaryNotice()
52
    {
53
        if (! isset($this->emptySummaryNotice)) {
54
            $this->emptySummaryNotice = $this->getDefaultEmptySummaryNotice();
55
        }
56
        
57
        return $this->emptySummaryNotice;
58
    }
59
60
    /**
61
     * @return string
62
     */
63
    protected function getDefaultEmptySummaryNotice()
64
    {
65
        return '';
66
    }
67
}
68