Test Failed
Push — master ( d53e87...2aa0fd )
by Julien
04:55
created

ServiceProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 2
eloc 9
c 2
b 0
f 1
dl 0
loc 28
ccs 0
cts 8
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 13 2
1
<?php
2
/**
3
 * This file is part of the Zemit Framework.
4
 *
5
 * (c) Zemit Team <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE.txt
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Zemit\Provider\OpenAi;
12
13
use Orhanerday\OpenAi\OpenAi;
14
use Phalcon\Di\DiInterface;
15
use Zemit\Bootstrap\Config;
16
use Zemit\Provider\AbstractServiceProvider;
17
18
/**
19
 * Zemit\Provider\OpenAi\ServiceProvider
20
 *
21
 * @package Zemit\Provider\OpenAi
22
 */
23
class ServiceProvider extends AbstractServiceProvider
24
{
25
    /**
26
     * The Service name.
27
     * @var string
28
     */
29
    protected $serviceName = 'openai';
30
31
    /**
32
     * {@inheritdoc}
33
     *
34
     * Register the Flash Service with the Twitter Bootstrap classes.
35
     *
36
     * @return void
37
     */
38
    public function register(DiInterface $di): void
39
    {
40
        $di->setShared($this->getName(), function() use ($di) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
41
            /** @var Config $config */
42
            $config = $di->get('config');
43
            $openAiConfig = $config->path('openai');
44
45
            $openAi = new OpenAi($openAiConfig['secretKey']);
46
            if (!empty($openAiConfig['organizationId'])) {
47
                $openAi->setORG($openAiConfig['organizationId']);
0 ignored issues
show
Bug introduced by
The method setORG() does not exist on Orhanerday\OpenAi\OpenAi. ( Ignorable by Annotation )

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

47
                $openAi->/** @scrutinizer ignore-call */ 
48
                         setORG($openAiConfig['organizationId']);

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...
48
            }
49
            
50
            return $openAi;
51
        });
52
    }
53
}
54