LinkedinIdentifier   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 76
Duplicated Lines 18.42 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 11
lcom 1
cbo 3
dl 14
loc 76
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A extraStatics() 0 16 1
A getLinkedinButton() 0 4 1
A hasLinkedin() 0 4 1
A isConnectedToLinkedin() 0 4 1
A LinkedinLink() 0 7 2
B onBeforeWrite() 14 14 5

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
class LinkedinIdentifier extends DataObjectDecorator
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
{
5
    public function extraStatics()
6
    {
7
        return array(
8
            'db' => array(
9
                'LinkedinID' => 'Varchar',
10
                'LinkedinFirstName' => 'Varchar(255)',
11
                'LinkedinLastName' => 'Varchar(255)',
12
                'LinkedinPicture' => 'Text',
13
                'LinkedinEmail' => 'Varchar(255)'
14
            ),
15
            'indexes' => array(
16
                'LinkedinID' => true,
17
                'LinkedinEmail' => true
18
            )
19
        );
20
    }
21
22
23
    /**
24
     * connect and disconnect button
25
     * @return Object (IsConnected, Link, ConnectedName, ConnectedImageURL)
26
     */
27
    public function getLinkedinButton($backURL = "")
28
    {
29
        return LinkedinCallback::get_login_button($backURL, $this->owner);
30
    }
31
32
    /**
33
     *
34
     * user has logged in with facebook before?
35
     * @return Boolean
36
     */
37
    public function hasLinkedin()
38
    {
39
        return (bool)$this->owner->LinkedinID;
40
    }
41
42
    /**
43
     * user is currenctly connected to Faceboo
44
     *
45
     *
46
     */
47
    public function isConnectedToLinkedin()
48
    {
49
        return LinkedinCallback::get_current_user();
50
    }
51
52
    /**
53
     * link to profile
54
     * @return String
55
     */
56
    public function LinkedinLink()
57
    {
58
        if ($this->owner->LinkedinID) {
59
            return "http://www.linkedin.com/profile/view?id=".$this->owner->LinkedinID;
60
        }
61
        return "";
62
    }
63
64 View Code Duplication
    public function onBeforeWrite()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
65
    {
66
        if (!$this->owner->Email) {
67
            if ($this->owner->LinkedinEmail) {
68
                $id = $this->owner->ID;
69
                if (!$id) {
70
                    $id = 0;
71
                }
72
                if (!DataObject::get_one("Member", "\"Email\" = '".$this->owner->LinkedinEmail."' AND \"Member\".\"ID\" <> ".$id."")) {
73
                    $this->owner->Email = $this->owner->LinkedinEmail;
74
                }
75
            }
76
        }
77
    }
78
}
79