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

mlocati / PayWay / 5213927880

pending completion
5213927880

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

80.95
/src/Service/SerializerTrait.php
1
<?php
2

3
namespace MLocati\PayWay\Service;
4

5
use DateTime;
6
use DateTimeInterface;
7
use DOMDocument;
8
use DOMElement;
9

10
trait SerializerTrait
11
{
12
    /**
13
     * @return \DOMElement
14
     */
15
    protected function createSoapEnvelope($service)
16
    {
17
        $doc = new DOMDocument('1.0', 'UTF-8');
5✔
18
        $doc->appendChild($envelope = $doc->createElementNS(static::NS_SOAPENVELOPE, 'soapenv:Envelope'));
5✔
19
        $envelope->appendChild($body = $doc->createElementNS(static::NS_SOAPENVELOPE, 'soapenv:Body'));
5✔
20
        $body->appendChild($container = $doc->createElementNS(static::NS_IGFS, 'ser:' . $service));
5✔
21

22
        return $container;
5✔
23
    }
24

25
    /**
26
     * @param string $name
27
     * @param string $value
28
     * @param bool $evenIfEmpty
29
     *
30
     * @return \DOMElement|null
31
     */
32
    protected function appendNode(DOMElement $parent, $name, $value, $evenIfEmpty = false)
33
    {
34
        if ($value === '' && !$evenIfEmpty) {
5✔
35
            return null;
5✔
36
        }
37
        $doc = $parent->ownerDocument;
5✔
38
        $parent->appendChild($child = $doc->createElement($name));
5✔
39
        if ($value !== '') {
5✔
40
            $child->appendChild($doc->createTextNode($value));
5✔
41
        }
42

43
        return $child;
5✔
44
    }
45

46
    /**
47
     * @param bool|null $value
48
     *
49
     * @return string
50
     */
51
    protected function serializeBoolean($value)
52
    {
53
        if ($value === null) {
4✔
54
            return '';
4✔
55
        }
56

57
        return $value ? 'true' : 'false';
×
58
    }
59

60
    /**
61
     * @return string
62
     */
63
    protected function serializeDateTime(DateTimeInterface $value = null)
64
    {
65
        if ($value === null) {
5✔
66
            return '';
5✔
67
        }
68
        if (defined('DateTime::RFC3339_EXTENDED')) {
×
69
            return $value->format(DateTime::RFC3339_EXTENDED);
×
70
        }
71

72
        return $value->format('Y\\-m\\-d\\TH\\:i\\:s\\.\\0\\0\\0P');
×
73
    }
74

75
    /**
76
     * @param int|null $value
77
     *
78
     * @return string
79
     */
80
    protected function serializeInteger($value)
81
    {
82
        return (string) $value;
5✔
83
    }
84
}
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