Passed
Push — master ( 9218bf...b9966f )
by Nicolaas
03:54
created

ShareThisSimpleExtension   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 16
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A ShareThisSimpleProvider() 0 7 2
1
<?php
2
3
namespace Sunnysideup\ShareThisSimple\Model;
4
5
use Sunnysideup\ShareThisSimple\Api\ShareThisSimpleProvider;
6
use SilverStripe\ORM\DataExtension;
7
8
/**
9
  * ### @@@@ START REPLACEMENT @@@@ ###
10
  * WHY: upgrade to SS4
11
  * OLD:  extends DataExtension (ignore case)
12
  * NEW:  extends DataExtension (COMPLEX)
13
  * EXP: Check for use of $this->anyVar and replace with $this->anyVar[$this->owner->ID] or consider turning the class into a trait
14
  * ### @@@@ STOP REPLACEMENT @@@@ ###
15
  */
16
class ShareThisSimpleExtension extends DataExtension
17
{
18
    private static $_share_this_simple_provider = [];
0 ignored issues
show
introduced by
The private property $_share_this_simple_provider is not used, and could be removed.
Loading history...
19
    /**
20
     * use in your templates like this:
21
     *     $ShareThisSimpleProvider.FacebookLink
22
     *
23
     * @return ShareThisSimpleProvider
24
     */
25
    public function ShareThisSimpleProvider()
26
    {
27
        if (!isset($_share_this_simple_provider[$this->owner->ID])) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $_share_this_simple_provider seems to never exist and therefore isset should always be false.
Loading history...
28
            $_share_this_simple_provider[$this->owner->ID] = ShareThisSimpleProvider::create($this->owner);
0 ignored issues
show
Comprehensibility Best Practice introduced by
$_share_this_simple_provider was never initialized. Although not strictly required by PHP, it is generally a good practice to add $_share_this_simple_provider = array(); before regardless.
Loading history...
29
        }
30
31
        return $_share_this_simple_provider[$this->owner->ID];
32
    }
33
}
34