Text::isEmpty()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 3
nc 2
nop 0
1
<?php
2
/**
3
 * Webino (http://webino.sk)
4
 *
5
 * @link        https://github.com/webino/WebinoDraw for the canonical source repository
6
 * @copyright   Copyright (c) 2012-2017 Webino, s. r. o. (http://webino.sk)
7
 * @author      Peter Bačinský <[email protected]>
8
 * @license     BSD-3-Clause
9
 */
10
11
namespace WebinoDraw\Dom;
12
13
use WebinoDraw\Exception;
14
15
/**
16
 * Extended DOMText
17
 */
18
class Text extends \DOMText implements NodeInterface
19
{
20
    use NodeTrait;
21
22
    /**
23
     * Returns the node text value and attributes in the array
24
     *
25
     * @param string $prefix
26
     * @return array
27
     */
28
    public function getProperties($prefix = null)
29
    {
30
        $properties = [$prefix . self::NODE_VALUE_PROPERTY => ''];
31
32
        empty($this->nodeValue)
33
            or $properties[$prefix . self::NODE_VALUE_PROPERTY] = $this->nodeValue;
34
35
        return $properties;
36
    }
37
38
    /**
39
     * @return bool
40
     */
41
    public function isEmpty()
42
    {
43
        $nodeValue = trim($this->nodeValue);
44
        if (!empty($nodeValue) || is_numeric($nodeValue)) {
45
            return false;
46
        }
47
        return true;
48
    }
49
}
50