SmsBulk::buildAndSendXmlSms()   B
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 35
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 21
nc 2
nop 1
dl 0
loc 35
ccs 0
cts 24
cp 0
crap 6
rs 8.8571
c 0
b 0
f 0
1
<?php
2
namespace Sender\Sms;
3
4
use DOMDocument;
5
use Sender\Deliver;
6
use Sender\Validation;
7
use Sender\MobileNumber;
8
use Sender\SmsOtpCommonclass;
0 ignored issues
show
Bug introduced by
The type Sender\SmsOtpCommonclass was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use Sender\Config\Config as ConfigClass;
10
use Sender\ExceptionClass\ParameterException;
11
12
/**
13
 * This Class for send Bulk SMS
14
 *
15
 * @package    Msg91 SMS&OTP package
16
 * @author     VenkatS <[email protected]>
17
 * @link       https://github.com/tesark/msg91-php
18
 * @license    MIT
19
 */
20
21
class SmsBulk extends SmsBuildClass
22
{
23
    protected $inputData;
24
    /**
25
     * This function Used to send the SMS XML formated data to Deliver Class
26
     * @param array $xmlData
27
     *
28
     * @throws ParameterException missing parameters or type error
29
     * @return string MSG91
30
     */
31
    public function buildAndSendXmlSms($xmlData)
32
    {
33
        $this->inputData = $xmlData;
34
        if ($this->hasData()) {
35
            //create the xml document
36
            $xmlDoc = new \DOMDocument();
37
            //create the root element
38
            $root = $this->createElement($xmlDoc, "MESSAGE");
39
            //check Auth
40
            $root = $this->addAuth($root, 2, $xmlDoc);
41
            //Check Sender
42
            $root = $this->addSender($root, 2, $xmlDoc);
43
            //Check schtime
44
            $root = $this->addSchtime($root, 2, $xmlDoc);
45
            //Check campaign
46
            $root = $this->addCampaign($root, 2, $xmlDoc);
47
            //Check country
48
            $root = $this->addCountry($root, 2, $xmlDoc);
49
            //Check flash
50
            $root = $this->addFlash($root, 2, $xmlDoc);
51
            //Check unicode
52
            $root = $this->addUnicode($root, 2, $xmlDoc);
53
            //Check unicode
54
            $this->addContent($root, 2, $xmlDoc);
55
        } else {
56
            $message = "parameters Missing";
57
            throw ParameterException::missinglogic($message);
58
        }
59
        //make the output pretty
60
        $xmlDoc->formatOutput = true;
61
        $xmlData  = $xmlDoc->saveXML();
62
        $uri      = "postsms.php";
63
        $delivery = new Deliver();
64
        $response = $delivery->sendSmsPost($uri, $xmlData);
65
        return $response;
66
    }
67
}
68