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.

BoardGateway::findBoards()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 10
rs 9.4285
cc 2
eloc 5
nc 2
nop 2
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\Board;
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 BoardGateway extends BaseGateway implements GatewayInterface
33
{
34
    /**
35
     *
36
     * @access private
37
     * @var string $queryAlias
38
     */
39
    protected $queryAlias = 'b';
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 findBoard(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
        $qb->addOrderBy('b.listOrderPriority', 'ASC');
55
56
        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...
57
    }
58
59
    /**
60
     *
61
     * @access public
62
     * @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...
63
     * @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...
64
     * @return \Doctrine\Common\Collections\ArrayCollection
65
     */
66
    public function findBoards(QueryBuilder $qb = null, $parameters = null)
67
    {
68
        if (null == $qb) {
69
            $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...
70
        }
71
72
        $qb->addOrderBy('b.listOrderPriority', 'ASC');
73
74
        return $this->all($qb, $parameters);
0 ignored issues
show
Bug introduced by
It seems like $parameters defined by parameter $parameters on line 66 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...
75
    }
76
77
    /**
78
     *
79
     * @access public
80
     * @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...
81
     * @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...
82
     * @return int
83
     */
84
    public function countBoards(QueryBuilder $qb = null, $parameters = null)
85
    {
86
        if (null == $qb) {
87
            $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...
88
        }
89
90
        if (null == $parameters) {
91
            $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...
92
        }
93
94
        $qb->setParameters($parameters);
95
96
        try {
97
            return $qb->getQuery()->getSingleScalarResult();
98
        } catch (\Doctrine\ORM\NoResultException $e) {
99
            return 0;
100
        }
101
    }
102
103
    /**
104
     *
105
     * @access public
106
     * @param  \CCDNForum\ForumBundle\Entity\Board                             $board
107
     * @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 BoardGateway.

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...
108
     */
109
    public function saveBoard(Board $board)
110
    {
111
        $this->persist($board)->flush();
112
113
        return $this;
114
    }
115
116
    /**
117
     *
118
     * @access public
119
     * @param  \CCDNForum\ForumBundle\Entity\Board                             $board
120
     * @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 BoardGateway.

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...
121
     */
122
    public function updateBoard(Board $board)
123
    {
124
        $this->persist($board)->flush();
125
126
        return $this;
127
    }
128
129
    /**
130
     *
131
     * @access public
132
     * @param  \CCDNForum\ForumBundle\Entity\Board                             $board
133
     * @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 BoardGateway.

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...
134
     */
135
    public function deleteBoard(Board $board)
136
    {
137
        $this->remove($board)->flush();
138
139
        return $this;
140
    }
141
142
    /**
143
     *
144
     * @access public
145
     * @return \CCDNForum\ForumBundle\Entity\Board
146
     */
147
    public function createBoard()
148
    {
149
        return new $this->entityClass();
150
    }
151
}
152