Completed
Push — master ( ec3686...b09171 )
by Jacob
06:23
created

MysqlIntroductionRepository   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 38
loc 38
wmc 2
lcom 0
cbo 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A findByType() 17 17 1

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
namespace Jacobemerick\Web\Domain\Blog;
4
5
use Aura\Sql\ConnectionLocator;
6
7 View Code Duplication
class MysqlIntroductionRepository implements IntroductionRepository
0 ignored issues
show
Duplication introduced by
This class 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...
8
{
9
10
    /** @var  Aura\Sql\ConnectionLocator */
11
    protected $connections;
12
13
    /**
14
     * @param Aura\Sql\ConnectionLocator
15
     */
16
    public function __construct(ConnectionLocator $connections)
17
    {
18
        $this->connections = $connections;
0 ignored issues
show
Documentation Bug introduced by
It seems like $connections of type object<Aura\Sql\ConnectionLocator> is incompatible with the declared type object<Jacobemerick\Web\...\Sql\ConnectionLocator> of property $connections.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
19
    }
20
21
    /**
22
     * @param string $type
23
     * @param string $value
24
     *
25
     * @return array|false
26
     */
27
    public function findByType($type, $value = '')
28
    {
29
        $query = "
30
            SELECT `title`, `content`, `image`
31
            FROM `jpemeric_blog`.`introduction`
32
            WHERE `type` = :type AND `value` = :value
33
            LIMIT 1";
34
        $bindings = [
35
            'type'  => $type,
36
            'value' => $value,
37
        ];
38
39
        return $this
0 ignored issues
show
Bug introduced by
The method connections() does not seem to exist on object<Jacobemerick\Web\...IntroductionRepository>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
40
            ->connections()
41
            ->getRead()
42
            ->fetchOne($query, $bindings);
43
    }
44
}
45