BlogCommentExtension::getExtraClass()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
cc 3
nc 3
nop 0
1
<?php
2
3
namespace SilverStripe\Blog\Model;
4
5
use SilverStripe\ORM\DataExtension;
6
7
/**
8
 * Adds Blog specific behaviour to Comment.
9
 */
10
class BlogCommentExtension extends DataExtension
11
{
12
    /**
13
     * Extra CSS classes for styling different comment types.
14
     *
15
     * @return string
16
     */
17
    public function getExtraClass()
18
    {
19
        $blogPost = $this->owner->getParent();
20
21
        if ($blogPost instanceof BlogPost) {
22
            if ($blogPost->isAuthor($this->owner->Author())) {
23
                return 'author-comment';
24
            }
25
        }
26
27
        return '';
28
    }
29
}
30