ShareThisSimpleProvider()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 3
b 0
f 0
nc 2
nop 0
dl 0
loc 8
rs 10
1
<?php
2
3
namespace Sunnysideup\ShareThisSimple\Model;
4
5
use SilverStripe\Core\Extension;
6
use Sunnysideup\ShareThisSimple\Api\ShareThisSimpleProvider;
7
8
/**
9
 * Class \Sunnysideup\ShareThisSimple\Model\ShareThisSimpleExtension
10
 *
11
 * @property SiteTree|ShareThisSimpleExtension $owner
12
 */
13
class ShareThisSimpleExtension extends Extension
14
{
15
    private static $_share_this_simple_provider = [];
16
17
    /**
18
     * use in your templates like this:
19
     *     $ShareThisSimpleProvider.FacebookLink.
20
     *
21
     * @return ShareThisSimpleProvider
22
     */
23
    public function ShareThisSimpleProvider()
24
    {
25
        $owner = $this->getOwner();
26
        if (! isset(self::$_share_this_simple_provider[$owner->ID])) {
27
            self::$_share_this_simple_provider[$owner->ID] = ShareThisSimpleProvider::create($this->owner);
28
        }
29
30
        return self::$_share_this_simple_provider[$owner->ID];
31
    }
32
}
33