ActiveRecordModelExtender::getMD()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
crap 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