Molecule::getObjectName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
1
<?php
2
/**
3
 * Something between Atom and Sand
4
 *
5
 * @author    Vitex <[email protected]>
6
 * @copyright 2009-2019 [email protected] (G)
7
 * 
8
 * PHP 7
9
 */
10
11
namespace Ease;
12
13
/**
14
 * Description of Molecule
15
 *
16
 * @author vitex
17
 */
18
class Molecule extends Atom
19
{
20
    /**
21
     * Udržuje v sobě jméno objektu.
22
     *
23
     * @var string
24
     */
25
    public $objectName = 'Molecule';
26
27
    /**
28
     * Nastaví jméno objektu.
29
     *
30
     * @param string $objectName
31
     *
32
     * @return string Jméno objektu
33
     */
34
    public function setObjectName($objectName = null)
35
    {
36
        if (empty($objectName)) {
37
            $this->objectName = get_class($this);
38
        } else {
39
            $this->objectName = $objectName;
40
        }
41
42
        return $this->objectName;
43
    }
44
45
    /**
46
     * Vrací jméno objektu.
47
     *
48
     * @return string
49
     */
50
    public function getObjectName()
51
    {
52
        return $this->objectName;
53
    }
54
55
    /**
56
     * Set up one of properties
57
     *
58
     * @param array  $options  array of given properties
59
     * @param string $name     name of property to process
60
     * @param string $constant load default property value from constant
61
     */
62
    public function setupProperty($options, $name, $constant = null)
63
    {
64
        if (isset($options[$name])) {
65
            $this->$name = $options[$name];
66
        } else {
67
            if (is_null($this->$name) && !empty($constant) && defined($constant)) {
68
                $this->$name = constant($constant);
69
            }
70
        }
71
    }
72
73
    /**
74
     * Zapíše zprávu do logu.
75
     *
76
     * @param string $message zpráva
77
     * @param string $type    typ zprávy (info|warning|success|error|*)
78
     *
79
     * @return bool byl report zapsán ?
80
     */
81
    public function addToLog($message, $type = 'message')
82
    {
83
        return Shared::logger()->addToLog(
84
            $this->getObjectName(), $message,
85
            $type
86
        );
87
    }
88
89
}
90