MiddlewareFactory::getSoapCall()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 8
ccs 6
cts 6
cp 1
crap 1
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace garethp\ews\API\ExchangeWebServices;
4
5
use garethp\ews\API\MiddlewareRequest;
6
use garethp\ews\API\MiddlewareResponse;
7
use garethp\ews\API\Type;
8
use garethp\ews\API\ExchangeWebServices;
9
use garethp\ews\API\Type\FindFolderParentType;
10
use garethp\ews\API\Type\FindItemParentType;
11
12
class MiddlewareFactory
13
{
14 30
    public function getSoapCall()
15
    {
16 1
        return function (MiddlewareRequest $request) {
17 30
            $client = $this->getClient();
0 ignored issues
show
Bug introduced by
The method getClient() does not exist on garethp\ews\API\Exchange...vices\MiddlewareFactory. ( Ignorable by Annotation )

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

17
            /** @scrutinizer ignore-call */ 
18
            $client = $this->getClient();

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...
18 30
            $response = $client->__call($request->getName(), $request->getArguments());
19 30
            $response = MiddlewareResponse::newResponse($response);
20
21 30
            return $response;
22 1
        };
23
    }
24
25 30
    public function getTypeToXMLObject()
26
    {
27 1
        return function (MiddlewareRequest $request, callable $next) {
28 30
            if ($request->getRequest() instanceof Type) {
29 2
                $request->setRequest($request->getRequest()->toXmlObject());
30
            }
31
32 30
            return $next($request);
33 1
        };
34
    }
35
36 30
    public function getStripSyncScopeForExchange2007()
37
    {
38 1
        return function (MiddlewareRequest $request, callable $next) {
39 30
            $requestObj = $request->getRequest();
40
41 30
            if ($request->getName() == "SyncFolderItems"
42 30
                && $request->getOptions()['version'] < ExchangeWebServices::VERSION_2010
43 30
                && isset($requestObj->SyncScope)) {
44
                unset($requestObj->SyncScope);
45
                $request->setRequest($requestObj);
46
            }
47
48 30
            return $next($request);
49 1
        };
50
    }
51
52 30
    public function getProcessResponse()
53
    {
54 1
        return function (MiddlewareRequest $request, callable $next) {
55 30
            $response = $next($request);
56
57 30
            $response->setResponse($this->processResponse($response->getResponse()));
0 ignored issues
show
Bug introduced by
The method processResponse() does not exist on garethp\ews\API\Exchange...vices\MiddlewareFactory. ( Ignorable by Annotation )

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

57
            $response->setResponse($this->/** @scrutinizer ignore-call */ processResponse($response->getResponse()));

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...
58
59 30
            return $response;
60 1
        };
61
    }
62
63 30
    public function getAddLastRequestToPagedResults()
64
    {
65 1
        return function (MiddlewareRequest $request, callable $next) {
66 30
            $response = $next($request);
67
68 30
            $responseObject = $response->getResponse();
69 30
            if (($responseObject instanceof FindItemParentType
70 30
                    || $responseObject instanceof FindFolderParentType)
71 30
                && !$responseObject->isIncludesLastItemInRange()) {
72 2
                $responseObject->setLastRequest($request->getRequest());
73 2
                $response->setResponse($responseObject);
74
            }
75
76 30
            return $response;
77 1
        };
78
    }
79
}
80