Completed
Branch master (e6292e)
by Bobby
01:52
created

Transformer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 3
c 3
b 0
f 1
lcom 0
cbo 0
dl 0
loc 31
ccs 6
cts 6
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A stripHtml() 0 4 1
A get() 0 4 1
A __toString() 0 4 1
1
<?php
2
3
namespace Ballen\Linguist\Transformers;
4
5
/**
6
 * Linguist
7
 *
8
 * Linguist is a PHP library for parsing strings, it can extract and manipulate
9
 *  prefixed words in content ideal for working with @mentions, #topics and
10
 *  even custom action tags!
11
 *
12
 * @author Bobby Allen <[email protected]>
13
 * @license http://www.gnu.org/licenses/gpl-3.0.html
14
 * @link https://github.com/bobsta63/linguist
15
 * @link http://www.bobbyallen.me
16
 *
17
 */
18
abstract class Transformer
19
{
20
21
    /**
22
     * Strips HTML tags from the given string.
23
     * @param string $message The string that does/may contain HTML tags.
24
     * @return string
25
     */
26 18
    protected function stripHtml($message)
27
    {
28 18
        return strip_tags($message);
29
    }
30
31
    /**
32
     * Retrieves the formatted text.
33
     * @return string
34
     */
35 18
    public function get()
36
    {
37 18
        return $this->formatted;
0 ignored issues
show
Bug introduced by
The property formatted does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
38
    }
39
40
    /**
41
     * Default __toString() method to return the formatted text.
42
     * @return string
43
     */
44 18
    public function __toString()
45
    {
46 18
        return $this->get();
47
    }
48
}
49