ActiveRecordModelExtender   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 38
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A gravatar() 0 4 1
A getMD() 0 6 1
1
<?php
2
3
namespace Nicklas\Comment\Modules;
4
5
use \Anax\Database\ActiveRecordModel;
6
use \Anax\TextFilter\TextFilter;
7
8
/**
9
 * A database driven model.
10
 */
11
class ActiveRecordModelExtender extends ActiveRecordModel
12
{
13
14
    public $db;
15
    /**
16
     * Constructor injects with database
17
     *
18
     */
19 27
    public function __construct($db = null)
20
    {
21 27
         $this->db = $db;
22 27
    }
23
    /**
24
     * Returns gravatar link
25
     *
26
     * @param string $email
27
     *
28
     * @return string as gravatar link
29
     */
30 11
    public function gravatar($email)
31
    {
32 11
        return "https://www.gravatar.com/avatar/" . md5(strtolower(trim($email))) . "&s=" . 40;
33
    }
34
35
    /**
36
     * Return markdown based on string
37
     *
38
     * @param string $content unparsed markdown
39
     *
40
     * @return string as parsed markdown
41
     */
42 9
    public function getMD($content)
43
    {
44 9
        $funcArr = ["yamlfrontmatter", "shortcode", "markdown", "titlefromheader"];
45 9
        $textFilter = new textFilter();
46 9
        return $textFilter->parse($content, $funcArr)->text;
47
    }
48
}
49