<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Class
 *
 * @author svam
 */
class xmlHandler {

//put your code here

    public $activity;

    public function __construct($svalog) {

        $this->activity = $svalog;
    }

    public function getLiveSMSC($inputXml) {

        $smscs = array();

        $xml = new SimpleXMLElement($inputXml);

        $totalInTheList = count($xml->smscs->smsc);

        for ($i = 0; $i < $totalInTheList; $i++) {

            $smscs[$i]['smscid'] = $xml->smscs->smsc[$i]->id;
            $smscs[$i]['status'] = $xml->smscs->smsc[$i]->status;
            $smscs[$i]['failed'] = $xml->smscs->smsc[$i]->failed;
            $smscs[$i]['queued'] = $xml->smscs->smsc[$i]->queued;
        }





        return $smscs;
    }

    public function getLiveSMSCById($inputXml, $smscid) {

        $smscs = $this->getLiveSMSC($inputXml);
        $smsc = array();

        $total = count($smscs);

        for ($i = 0; $i < $total; $i++) {


            if ($smscs[$i]['smscid'] == $smscid) {

                $smsc['smscid'] = $smscs[$i]['smscid'];
                $smsc['status'] = $smscs[$i]['status'];
                $smsc['failed'] = $smscs[$i]['failed'];
                $smsc['queued'] = $smscs[$i]['queued'];

                continue;
            }
        }




        return $smsc;
    }

    public function getOutputXmlErrorCode($outputXml) {
        $errorCode = 5516;
        $xml = new SimpleXMLElement($outputXml);
        $errorCode = $xml->event->errorCode["value"];
        return $errorCode;
    }

}
