ProfilerProvider   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 7
c 1
b 0
f 0
dl 0
loc 16
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A get() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Ray\AuraSqlModule;
6
7
use Aura\Sql\Profiler\Profiler;
8
use Psr\Log\LoggerInterface;
9
use Ray\Di\Provider;
10
11
class ProfilerProvider implements Provider
0 ignored issues
show
Deprecated Code introduced by
The interface Ray\Di\Provider has been deprecated: User ProviderInterface instead ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

11
class ProfilerProvider implements /** @scrutinizer ignore-deprecated */ Provider

This interface has been deprecated. The supplier of the interface has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the interface will be removed and what other interface to use instead.

Loading history...
12
{
13
    private LoggerInterface $logger;
14
15
    public function __construct(LoggerInterface $logger)
16
    {
17
        $this->logger = $logger;
18
    }
19
20
    public function get(): Profiler
21
    {
22
        $profiler = new Profiler($this->logger);
23
        $profiler->setLogFormat('{duration}: {function} {statement}:{values}');
24
        $profiler->setActive(true);
25
26
        return $profiler;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $profiler returns the type Aura\Sql\Profiler\Profiler which is incompatible with the return type mandated by Ray\Di\ProviderInterface::get() of Ray\Di\T.

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
27
    }
28
}
29