Passed
Pull Request — master (#8)
by Carlos C
01:37
created

StampService   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 81.25%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 15
dl 0
loc 32
ccs 13
cts 16
cp 0.8125
rs 10
c 3
b 0
f 0
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A stamp() 0 17 4
A settings() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpCfdi\Finkok\Services\Stamping;
6
7
use PhpCfdi\Finkok\Definitions\Services;
8
use PhpCfdi\Finkok\FinkokSettings;
9
10
class StampService
11
{
12
    /** @var FinkokSettings */
13
    private $settings;
14
15 3
    public function __construct(FinkokSettings $settings)
16
    {
17 3
        $this->settings = $settings;
18 3
    }
19
20 1
    public function settings(): FinkokSettings
21
    {
22 1
        return $this->settings;
23
    }
24
25 1
    public function stamp(StampingCommand $command): StampingResult
26
    {
27 1
        $soapCaller = $this->settings()->createCallerForService(Services::stamping());
28
        // Finkok, repeat to fix bad webservice behavior of remote stamp method
29
        // This will not be fixed according to Finkok
30
        do {
31 1
            $rawResponse = $soapCaller->call('stamp', [
32 1
                'xml' => $command->xml(),
33
            ]);
34 1
            $result = new StampingResult('stampResult', $rawResponse);
35 1
            if (null !== $result->alerts()->findByErrorCode('307') && '' === $result->uuid()) {
0 ignored issues
show
Bug introduced by
Are you sure the usage of $result->alerts()->findByErrorCode('307') targeting PhpCfdi\Finkok\Services\...erts::findByErrorCode() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
36
                usleep(200000); // 0.2 seconds
37
                continue;
38
            }
39 1
            break;
40
        } while (true);
41 1
        return $result;
42
    }
43
}
44