Test   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 28
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A prependAt() 0 4 1
A prependAtSecond() 0 4 1
1
<?php
2
namespace Sandbox\Demos;
3
4
use Redbox\Hooks\Filters;
5
6
/*
7
 * Please note: This use statement is actualy required.
8
 * Without this use statement Filters::registerFilterObject
9
 * will not work.
10
 */
11
use Redbox\Hooks\Annotations\Filter;
12
13
require 'autoload.php';
14
15
class Test
16
{
17
    /**
18
     * This function is going to be called second
19
     * It has priority 1.
20
     *
21
     * @Filter("prepend_at", priority=1)
22
     * @param string $text
23
     * @return string
24
     */
25
    public function prependAt($text = '')
26
    {
27
        return '@' . $text;
28
    }
29
30
    /**
31
     * This is the first function going to be called.
32
     * It has priority 0.
33
     *
34
     * @Filter("prepend_at", priority=0)
35
     * @param string $text
36
     * @return string
37
     */
38
    public function prependAtSecond($text = '')
39
    {
40
        return '!!' . $text;
41
    }
42
}
43
Filters::registerFilterObject(new Test());
44
45
/**
46
 * The result should be:
47
 *
48
 * Result: @!!Hello world
49
 */
50
echo "Result: ".Filters::applyFilter('prepend_at', 'Hello world');
51
52
/**
53
 * This is not required in your code. I have to add this to reset my unit tests.
54
 */
55
Filters::removeAllFilters('prepend_at');
56