GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

SubscriptionGateway   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 116
Duplicated Lines 0 %

Coupling/Cohesion

Components 3
Dependencies 3
Metric Value
wmc 12
lcom 3
cbo 3
dl 0
loc 116
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A findSubscription() 0 8 2
A findSubscriptions() 0 8 2
A countSubscriptions() 0 18 4
A saveSubscription() 0 6 1
A updateSubscription() 0 6 1
A deleteSubscription() 0 6 1
A createSubscription() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the CCDNForum ForumBundle
5
 *
6
 * (c) CCDN (c) CodeConsortium <http://www.codeconsortium.com/>
7
 *
8
 * Available on github <http://www.github.com/codeconsortium/>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace CCDNForum\ForumBundle\Model\Component\Gateway;
15
16
use Doctrine\ORM\QueryBuilder;
17
use CCDNForum\ForumBundle\Model\Component\Gateway\GatewayInterface;
18
use CCDNForum\ForumBundle\Model\Component\Gateway\BaseGateway;
19
use CCDNForum\ForumBundle\Entity\Subscription;
20
21
/**
22
 *
23
 * @category CCDNForum
24
 * @package  ForumBundle
25
 *
26
 * @author   Reece Fowell <[email protected]>
27
 * @license  http://opensource.org/licenses/MIT MIT
28
 * @version  Release: 2.0
29
 * @link     https://github.com/codeconsortium/CCDNForumForumBundle
30
 *
31
 */
32
class SubscriptionGateway extends BaseGateway implements GatewayInterface
33
{
34
    /**
35
     *
36
     * @access private
37
     * @var string $queryAlias
38
     */
39
    protected $queryAlias = 's';
40
41
    /**
42
     *
43
     * @access public
44
     * @param  \Doctrine\ORM\QueryBuilder                   $qb
0 ignored issues
show
Documentation introduced by
Should the type for parameter $qb not be null|QueryBuilder?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
45
     * @param  Array                                        $parameters
0 ignored issues
show
Documentation introduced by
Should the type for parameter $parameters not be array|null? Also, consider making the array more specific, something like array<String>, or String[].

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive. In addition it looks for parameters that have the generic type array and suggests a stricter type like array<String>.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
46
     * @return \Doctrine\Common\Collections\ArrayCollection
47
     */
48
    public function findSubscription(QueryBuilder $qb = null, $parameters = null)
49
    {
50
        if (null == $qb) {
51
            $qb = $this->createSelectQuery();
0 ignored issues
show
Coding Style introduced by
Consider using a different name than the parameter $qb. This often makes code more readable.
Loading history...
52
        }
53
54
        return $this->one($qb, $parameters);
0 ignored issues
show
Bug introduced by
It seems like $parameters defined by parameter $parameters on line 48 can also be of type null; however, CCDNForum\ForumBundle\Mo...eway\BaseGateway::one() does only seem to accept array, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
55
    }
56
57
    /**
58
     *
59
     * @access public
60
     * @param  \Doctrine\ORM\QueryBuilder                   $qb
0 ignored issues
show
Documentation introduced by
Should the type for parameter $qb not be null|QueryBuilder?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
61
     * @param  Array                                        $parameters
0 ignored issues
show
Documentation introduced by
Should the type for parameter $parameters not be array|null? Also, consider making the array more specific, something like array<String>, or String[].

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive. In addition it looks for parameters that have the generic type array and suggests a stricter type like array<String>.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
62
     * @return \Doctrine\Common\Collections\ArrayCollection
63
     */
64
    public function findSubscriptions(QueryBuilder $qb = null, $parameters = null)
65
    {
66
        if (null == $qb) {
67
            $qb = $this->createSelectQuery();
0 ignored issues
show
Coding Style introduced by
Consider using a different name than the parameter $qb. This often makes code more readable.
Loading history...
68
        }
69
70
        return $this->all($qb, $parameters);
0 ignored issues
show
Bug introduced by
It seems like $parameters defined by parameter $parameters on line 64 can also be of type null; however, CCDNForum\ForumBundle\Mo...eway\BaseGateway::all() does only seem to accept array, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
71
    }
72
73
    /**
74
     *
75
     * @access public
76
     * @param  \Doctrine\ORM\QueryBuilder $qb
0 ignored issues
show
Documentation introduced by
Should the type for parameter $qb not be null|QueryBuilder?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
77
     * @param  Array                      $parameters
0 ignored issues
show
Documentation introduced by
Should the type for parameter $parameters not be array|null? Also, consider making the array more specific, something like array<String>, or String[].

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive. In addition it looks for parameters that have the generic type array and suggests a stricter type like array<String>.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
78
     * @return int
79
     */
80
    public function countSubscriptions(QueryBuilder $qb = null, $parameters = null)
81
    {
82
        if (null == $qb) {
83
            $qb = $this->createCountQuery();
0 ignored issues
show
Coding Style introduced by
Consider using a different name than the parameter $qb. This often makes code more readable.
Loading history...
84
        }
85
86
        if (null == $parameters) {
87
            $parameters = array();
0 ignored issues
show
Coding Style introduced by
Consider using a different name than the parameter $parameters. This often makes code more readable.
Loading history...
88
        }
89
90
        $qb->setParameters($parameters);
91
92
        try {
93
            return $qb->getQuery()->getSingleScalarResult();
94
        } catch (\Doctrine\ORM\NoResultException $e) {
95
            return 0;
96
        }
97
    }
98
99
    /**
100
     *
101
     * @access public
102
     * @param  \CCDNForum\ForumBundle\Entity\Subscription                      $subscription
103
     * @return \CCDNForum\ForumBundle\Model\Component\Gateway\GatewayInterface
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use SubscriptionGateway.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
104
     */
105
    public function saveSubscription(Subscription $subscription)
106
    {
107
        $this->persist($subscription)->flush();
108
109
        return $this;
110
    }
111
112
    /**
113
     *
114
     * @access public
115
     * @param  \CCDNForum\ForumBundle\Entity\Subscription                      $subscription
116
     * @return \CCDNForum\ForumBundle\Model\Component\Gateway\GatewayInterface
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use SubscriptionGateway.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
117
     */
118
    public function updateSubscription(Subscription $subscription)
119
    {
120
        $this->persist($subscription)->flush();
121
122
        return $this;
123
    }
124
125
    /**
126
     *
127
     * @access public
128
     * @param  \CCDNForum\ForumBundle\Entity\Subscription                      $subscription
129
     * @return \CCDNForum\ForumBundle\Model\Component\Gateway\GatewayInterface
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use SubscriptionGateway.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
130
     */
131
    public function deleteSubscription(Subscription $subscription)
132
    {
133
        $this->remove($subscription)->flush();
134
135
        return $this;
136
    }
137
138
    /**
139
     *
140
     * @access public
141
     * @return \CCDNForum\ForumBundle\Entity\Subscription
142
     */
143
    public function createSubscription()
144
    {
145
        return new $this->entityClass();
146
    }
147
}
148