• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mlocati / PayWay / 5212705470

pending completion
5212705470

push

github

mlocati
Initial version

1803 of 1803 new or added lines in 47 files covered. (100.0%)

1313 of 1803 relevant lines covered (72.82%)

1.53 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

72.41
/src/Server2Server/Request.php
1
<?php
2

3
namespace MLocati\PayWay\Server2Server;
4

5
use JsonSerializable;
6
use MLocati\PayWay\Service\JsonCleanupTrait;
7

8
class Request implements JsonSerializable
9
{
10
    use JsonCleanupTrait;
11

12
    /**
13
     * @var string
14
     */
15
    private $tid;
16

17
    /**
18
     * @var string
19
     */
20
    private $paymentID;
21

22
    /**
23
     * @var string
24
     */
25
    private $shopID;
26

27
    /**
28
     * @var string
29
     */
30
    private $tranID;
31

32
    /**
33
     * @var string
34
     */
35
    private $trType;
36

37
    /**
38
     * @var string
39
     */
40
    private $signature;
41

42
    /**
43
     * @var array
44
     */
45
    private $unrecognizedData;
46

47
    /**
48
     * @var string
49
     */
50
    public function __construct(array $data)
51
    {
52
        $this->tid = static::popString($data, 'tid');
4✔
53
        $this->paymentID = static::popString($data, 'paymentID');
4✔
54
        $this->shopID = static::popString($data, 'shopID');
4✔
55
        $this->tranID = static::popString($data, 'tranID');
4✔
56
        $this->trType = static::popString($data, 'trType');
4✔
57
        $this->signature = static::popString($data, 'signature');
4✔
58
        $this->unrecognizedData = $data;
4✔
59
    }
60

61
    /**
62
     * @return static
63
     */
64
    public static function createFromGlobals()
65
    {
66
        return new static(isset($_POST) ? $_POST : []);
×
67
    }
68

69
    /**
70
     * @return string
71
     */
72
    public function getTid()
73
    {
74
        return $this->tid;
×
75
    }
76

77
    /**
78
     * @return string
79
     */
80
    public function getPaymentID()
81
    {
82
        return $this->paymentID;
×
83
    }
84

85
    /**
86
     * @return string
87
     */
88
    public function getShopID()
89
    {
90
        return $this->shopID;
×
91
    }
92

93
    /**
94
     * @return string
95
     */
96
    public function getTranID()
97
    {
98
        return $this->tranID;
×
99
    }
100

101
    /**
102
     * @return string
103
     */
104
    public function getTrType()
105
    {
106
        return $this->trType;
×
107
    }
108

109
    /**
110
     * @return string
111
     */
112
    public function getSignature()
113
    {
114
        return $this->signature;
×
115
    }
116

117
    /**
118
     * @return array
119
     */
120
    public function getUnrecognizedData()
121
    {
122
        return $this->unrecognizedData;
×
123
    }
124

125
    /**
126
     * {@inheritdoc}
127
     *
128
     * @see \JsonSerializable::jsonSerialize()
129
     */
130
    #[\ReturnTypeWillChange]
131
    public function jsonSerialize()
132
    {
133
        return $this->cleanupJson([
4✔
134
            'tid' => $this->tid,
4✔
135
            'paymentID' => $this->paymentID,
4✔
136
            'shopID' => $this->shopID,
4✔
137
            'tranID' => $this->tranID,
4✔
138
            'trType' => $this->trType,
4✔
139
            'signature' => $this->signature,
4✔
140
            '_unrecognizedData' => $this->unrecognizedData,
4✔
141
        ]);
4✔
142
    }
143

144
    /**
145
     * @param string $key
146
     *
147
     * @return string
148
     */
149
    private static function popString(array &$data, $key)
150
    {
151
        if (!isset($data[$key]) || !is_string($data[$key])) {
4✔
152
            return '';
3✔
153
        }
154
        $result = $data[$key];
3✔
155
        unset($data[$key]);
3✔
156

157
        return $result;
3✔
158
    }
159
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc