Passed
Push — master ( 120832...1dab8b )
by Dmitry
02:12
created

Request::get_http_raw_post_data()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 6
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 11
rs 9.4285
1
<?php
2
3
/**
4
 *      Class Static Factory  to build a specific class of request
5
 *
6
 *      @package php_EasyPay
7
 *      @version 1.1
8
 *      @author Dmitry Shovchko <[email protected]>
9
 *
10
 */
11
12
namespace EasyPay\Provider31;
13
14
use EasyPay\Log as Log;
15
16
final class Request
17
{
18
    /**
19
     *      static method to create a specific class of request
20
     *
21
     *      @return Request\General Request class of the appropriate type
22
     *      @throws \EasyPay\Exception\Structure
23
     */
24
    public static function get()
25
    {
26
        //$raw = self::get_http_raw_post_data();
27
        $raw = new Request\RAW();
28
29
        $r = new Request\General($raw);
30
31
        switch ($r->Operation())
32
        {
33
            case 'Check':
34
                return new Request\Check($raw);
0 ignored issues
show
Bug introduced by
$raw of type EasyPay\Provider31\Request\RAW is incompatible with the type string expected by parameter $raw of EasyPay\Provider31\Request\Check::__construct(). ( Ignorable by Annotation )

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

34
                return new Request\Check(/** @scrutinizer ignore-type */ $raw);
Loading history...
35
36
            case 'Payment':
37
                return new Request\Payment($raw);
0 ignored issues
show
Bug introduced by
$raw of type EasyPay\Provider31\Request\RAW is incompatible with the type string expected by parameter $raw of EasyPay\Provider31\Request\Payment::__construct(). ( Ignorable by Annotation )

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

37
                return new Request\Payment(/** @scrutinizer ignore-type */ $raw);
Loading history...
38
39
            case 'Confirm':
40
                return new Request\Confirm($raw);
0 ignored issues
show
Bug introduced by
$raw of type EasyPay\Provider31\Request\RAW is incompatible with the type string expected by parameter $raw of EasyPay\Provider31\Request\Confirm::__construct(). ( Ignorable by Annotation )

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

40
                return new Request\Confirm(/** @scrutinizer ignore-type */ $raw);
Loading history...
41
42
            case 'Cancel';
43
                return new Request\Cancel($raw);
0 ignored issues
show
Bug introduced by
$raw of type EasyPay\Provider31\Request\RAW is incompatible with the type string expected by parameter $raw of EasyPay\Provider31\Request\Cancel::__construct(). ( Ignorable by Annotation )

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

43
                return new Request\Cancel(/** @scrutinizer ignore-type */ $raw);
Loading history...
44
45
            default:
46
                throw new \EasyPay\Exception\Structure('There is not supported value of Operation in xml-request!', -99);
47
        }
48
    }
49
50
    /**
51
     *      Get data from the body of the http request
52
     *
53
     *      - with the appropriate configuration of php.ini they can be found
54
     *        in the global variable $HTTP_RAW_POST_DATA
55
     *
56
     *      - but it's easier just to read the data from the php://input stream,
57
     *        which does not depend on the php.ini directives and allows you to read
58
     *        raw data from the request body
59
     *
60
     *      @return string Http raw post data
61
     *
62
     */
63
    /*private static function get_http_raw_post_data()
64
    {
65
        Log::instance()->add('request from ' . $_SERVER['REMOTE_ADDR']);
66
67
        $raw_request = file_get_contents('php://input');
68
69
        Log::instance()->debug('request received: ');
70
        Log::instance()->debug($raw_request);
71
        Log::instance()->debug(' ');
72
73
        return $raw_request;
74
    }*/
75
}
76