Completed
Push — master ( e03be1...f7a75b )
by Stephen
02:48
created

ExtensionExample::isRedditor()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 8
rs 9.4286
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
3
namespace StarCitizen\Examples;
4
5
use StarCitizen\Models\Profile;
6
7
/**
8
 * Class ExtensionExample
9
 *
10
 * Extends the profile and adds a check to see if the user has a link to their reddit account in
11
 * their bio.
12
 *
13
 * This could be used to show that the owner of this account is also on reddit.
14
 *
15
 * @package StarCitizen\Examples
16
 */
17
class ExtensionExample extends Profile
18
{
19
    /**
20
     * Matches the username
21
     *
22
     * @param $redditUsername
23
     *
24
     * @return bool
25
     */
26
    public function isRedditor($redditUsername)
27
    {
28
        if (preg_match("%^((https?://)|reddit.com/u(ser)?/" . $redditUsername . "/?\s*(<br />)?\\n%i",$this->bio) == 1) {
29
            return true;
30
        }
31
32
        return false;
33
    }
34
}