LinkedinIdentifier::onBeforeWrite()   B
last analyzed

Complexity

Conditions 5
Paths 6

Size

Total Lines 14
Code Lines 8

Duplication

Lines 14
Ratio 100 %

Importance

Changes 0
Metric Value
dl 14
loc 14
rs 8.8571
c 0
b 0
f 0
cc 5
eloc 8
nc 6
nop 0
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