KycDocumentPageQuery::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 9
nc 1
nop 6
1
<?php
2
/**
3
 * Created by Carl Owens ([email protected])
4
 * Company: PartFire Ltd (www.partfire.co.uk)
5
 * Copyright © 2016 PartFire Ltd. All rights reserved.
6
 *
7
 * User:    Carl Owens
8
 * Date:    06/12/2016
9
 * Time:    21:30
10
 * File:    KycDocumentPageQuery.php
11
 **/
12
13
namespace PartFire\MangoPayBundle\Models\Adapters;
14
15
use MangoPay\MangoPayApi;
16
use Monolog\Logger;
17
use PartFire\MangoPayBundle\Models\DTOs\KycDocumentPage;
18
use PartFire\MangoPayBundle\Models\DTOs\Translators\KycDocumentPageTranslator;
19
use PartFire\MangoPayBundle\Models\KycDocumentPageQueryInterface;
20
use MangoPay\Libraries\ResponseException;
21
use MangoPay\Libraries\Exception;
22
use PartFire\MangoPayBundle\Models\Exception as PartFireException;
23
24
class KycDocumentPageQuery extends AbstractQuery implements KycDocumentPageQueryInterface
25
{
26
    /**
27
     * @var KycDocumentPageTranslator
28
     */
29
    protected $kycDocumentPageTranslator;
30
31
    /**
32
     * KycDocumentPageQuery constructor.
33
     * @param $clientId
34
     * @param $clientPassword
35
     * @param $baseUrl
36
     * @param MangoPayApi $mangoPayApi
37
     * @param Logger $logger
38
     * @param KycDocumentPageTranslator $kycDocumentPageTranslator
39
     */
40
    public function __construct(
41
        $clientId,
42
        $clientPassword,
43
        $baseUrl,
44
        MangoPayApi $mangoPayApi,
45
        Logger $logger,
46
        KycDocumentPageTranslator $kycDocumentPageTranslator
47
    ) {
48
        $this->kycDocumentPageTranslator = $kycDocumentPageTranslator;
49
        parent::__construct($clientId, $clientPassword, $baseUrl,$mangoPayApi, $logger);
50
    }
51
52
    /**
53
     * @param KycDocumentPage $kycDocumentPage
54
     * @return KycDocumentPage|PartFireException
55
     */
56
    public function create(KycDocumentPage $kycDocumentPage)
57
    {
58
        try {
59
            $kycDocumentPage = $this->mangoPayApi->Users->CreateKycPageFromFile($kycDocumentPage->getOwnerId(), $kycDocumentPage->getKycDocumentId(), $kycDocumentPage->getFilePath());
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $kycDocumentPage is correct as $this->mangoPayApi->User...entPage->getFilePath()) (which targets MangoPay\ApiUsers::CreateKycPageFromFile()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

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

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

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

Loading history...
60
61
        } catch(ResponseException $e) {
62
            $this->logger->addCritical($e->getMessage(), ['code' => $e->getCode(), 'details' => $e->GetErrorDetails()]);
63
            throw new PartFireException($e->getMessage(), $e->getCode(), $e);
64
        } catch(Exception $e) {
65
            $this->logger->addError($e->getMessage());
66
            throw new PartFireException($e->getMessage(), $e->getCode(), $e);
67
        }
68
        return $kycDocumentPage;
69
    }
70
}
71