Completed
Push — master ( 7d98f0...459b9c )
by Vladimir
02:50
created

PulseUser::getMembership()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
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 9
rs 9.6667
cc 2
eloc 4
nc 2
nop 0
1
<?php
2
3
/**
4
 * This file contains the PulseUser class
5
 *
6
 * @copyright 2015 Vladimir Jimenez
7
 * @license   https://github.com/allejo/PhpPulse/blob/master/LICENSE.md MIT
8
 */
9
10
namespace allejo\DaPulse;
11
12
use allejo\DaPulse\Exceptions\IllegalAccessException;
13
use allejo\DaPulse\Objects\ApiUser;
14
15
/**
16
 * The PulseUser class contains all of the functions related to accessing information about a user
17
 *
18
 * @package allejo\DaPulse
19
 * @since   0.1.0
20
 */
21
class PulseUser extends ApiUser
22
{
23
    /**
24
     * {@inheritdoc}
25
     */
26
    const API_PREFIX = "users";
27
28
    /**
29
     * The membership type of this user with respect to a specific Pulse or PulseBoard. This value will not be set if
30
     * a PulseUser object is created standalone and not by another object which supports subscribers or membership.
31
     *
32
     * @var mixed
33
     */
34
    protected $membership;
35
36
    /**
37
     * The URL pattern used for all calls
38
     *
39
     * @var string
40
     */
41
    private $urlSyntax = "%s/%s/%s.json";
42
43
    /**
44
     *
45
     */
46
    public function getMembership ()
47
    {
48
        if (isset($this->membership))
49
        {
50
            return $this->membership;
51
        }
52
53
        throw new IllegalAccessException("This value is not accessible which means this user was not created in regards to another object.");
54
    }
55
56
    /**
57
     * Get the user's newsfeed
58
     *
59
     * @param  array $params GET parameters that need to be passed in the URL
60
     *
61
     * @since  0.1.0
62
     *
63
     * @return PulseUpdate[] An array of PulseUpdates that make up the user's newsfeed
64
     */
65
    public function getNewsFeed ($params = array())
66
    {
67
        $url = sprintf($this->urlSyntax, parent::apiEndpoint(), $this->id, "newsfeed");
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (apiEndpoint() instead of getNewsFeed()). Are you sure this is correct? If so, you might want to change this to $this->apiEndpoint().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
68
69
        return parent::fetchJsonArrayToObjectArray($url, "PulseUpdate", $params);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (fetchJsonArrayToObjectArray() instead of getNewsFeed()). Are you sure this is correct? If so, you might want to change this to $this->fetchJsonArrayToObjectArray().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
70
    }
71
72
    /**
73
     * Get the user's posts
74
     *
75
     * @param  array $params GET parameters that need to be passed in the URL
76
     *
77
     * @since  0.1.0
78
     *
79
     * @return PulseUpdate[] An array of PulseUpdates for each of the posts
80
     */
81
    public function getPosts ($params = array())
82
    {
83
        $url = sprintf($this->urlSyntax, parent::apiEndpoint(), $this->id, "posts");
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (apiEndpoint() instead of getPosts()). Are you sure this is correct? If so, you might want to change this to $this->apiEndpoint().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
84
85
        return parent::fetchJsonArrayToObjectArray($url, "PulseUpdate", $params);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (fetchJsonArrayToObjectArray() instead of getPosts()). Are you sure this is correct? If so, you might want to change this to $this->fetchJsonArrayToObjectArray().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
86
    }
87
88
    /**
89
     * Get the user's unread posts
90
     *
91
     * @param  array $params GET parameters that need to be passed in the URL
92
     *
93
     * @since  0.1.0
94
     *
95
     * @return PulseUpdate[] An array of PulseUpdates for each of the posts
96
     */
97
    public function getUnreadFeed ($params = array())
98
    {
99
        $url = sprintf($this->urlSyntax, parent::apiEndpoint(), $this->id, "unread_feed");
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (apiEndpoint() instead of getUnreadFeed()). Are you sure this is correct? If so, you might want to change this to $this->apiEndpoint().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
100
101
        return parent::fetchJsonArrayToObjectArray($url, "PulseUpdate", $params);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (fetchJsonArrayToObjectArray() instead of getUnreadFeed()). Are you sure this is correct? If so, you might want to change this to $this->fetchJsonArrayToObjectArray().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
102
    }
103
104
    /**
105
     * Get all of the users
106
     *
107
     * @param  array $params GET parameters that need to be passed in the URL
108
     *
109
     * @since  0.1.0
110
     *
111
     * @return PulseUser[] An array of PulseUsers for each of the users
112
     */
113
    public static function getUsers ($params = array())
114
    {
115
        $url = sprintf("%s.json", parent::apiEndpoint());
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (apiEndpoint() instead of getUsers()). Are you sure this is correct? If so, you might want to change this to $this->apiEndpoint().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
116
117
        return parent::fetchJsonArrayToObjectArray($url, "PulseUser", $params);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (fetchJsonArrayToObjectArray() instead of getUsers()). Are you sure this is correct? If so, you might want to change this to $this->fetchJsonArrayToObjectArray().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
118
    }
119
}