ConversationsMessage::_getMessageEmpty()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 9
Ratio 100 %

Importance

Changes 0
Metric Value
dl 9
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
namespace App\Model\Entity;
3
4
use Cake\Core\Configure;
5
use Cake\ORM\Entity;
6
use HTMLPurifier;
7
use HTMLPurifier_Config;
8
9 View Code Duplication
class ConversationsMessage extends Entity
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
10
{
11
12
    /**
13
     * Fields that can be mass assigned using newEntity() or patchEntity().
14
     *
15
     * @var array
16
     */
17
    protected $_accessible = [
18
        '*' => true,
19
        'id' => false,
20
    ];
21
22
    /**
23
     * Purify the message for display the message.
24
     *
25
     * @param string $content The message to be purified.
26
     *
27
     * @return string
28
     */
29
    protected function _getMessage($content)
30
    {
31
        $config = HTMLPurifier_Config::createDefault();
32
        $config->loadArray(Configure::read('HtmlPurifier.Conversations.message'));
33
34
        $HTMLPurifier = new HTMLPurifier($config);
35
36
        return $HTMLPurifier->purify($content);
37
    }
38
39
    /**
40
     * Purify the message for display the message.
41
     *
42
     * @return string
43
     */
44
    protected function _getMessageEmpty()
45
    {
46
        $config = HTMLPurifier_Config::createDefault();
47
        $config->loadArray(Configure::read('HtmlPurifier.Conversations.message_empty'));
48
49
        $HTMLPurifier = new HTMLPurifier($config);
50
51
        return $HTMLPurifier->purify($this->message);
0 ignored issues
show
Documentation introduced by
The property message does not exist on object<App\Model\Entity\ConversationsMessage>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
52
    }
53
}
54