<commit_before><?php

namespace AfricasTalking;

class Voice extends Service
{
    private $xmlString;

    public function __call($method, $args)
    {
        // First check if method exists
        if (method_exists($this, 'build' . $method)) {
			if (!isset($args[0])) {
				$args = [ 0 => ''];
			}
            return $this->stringBuilder('build'. $method, $args[0]);
        } else if (method_exists($this, 'do' . $method)) {
			if (!isset($args[0])) {
				$args = [ 0 => ''];
			}
            return $this->apiCall('do' . $method, $args[0]);
        } else {
            return $this->error($method .' is an invalid Voice SDK Method');
        }
    }

    public function messageBuilder()
    {
        return $this;
    }

    private function stringBuilder($method, $args)
    {
        $result = $this->$method($args);

        if (empty($this->xmlString)) {
            $this->xmlString = '<?xml version="1.0" encoding="UTF-8"?><Response>'. $result;
        } else {
            $this->xmlString .= $result;
        }

        return $this;
    }

    private function apiCall($method, $args)
    {
        if (!isset($args[0])) {
            $args = [0 => ''];
        }
        return $this->$method($args[0]);
    } 

    /**
     * Builds XML string from chained voice actions
     *
     * @return string
     */
    public function build()
    {
        if (empty($this->xmlString)) {
            return null;
        }
        return $this->xmlString . '</Response>';
    }
    
    protected function doCall($options)
    {
		if (!isset($options['to']) || !isset($options['from'])) {
			return $this->error('The parameters to and from must be defined');
        }

        // Validate callTo
        $checkCallTo = strpos($options['to'], '+');
        if ($checkCallTo === false || $checkCallTo !== 0) {
            return $this->error('callTo must be in the format \'+2XXYYYYYYYYY\'');
        }
        
        // Validate callFrom
        $checkCallFrom = strpos($options['from'], '+');
        if ($checkCallFrom === false || $checkCallFrom !== 0) {
            return $this->error('callFrom must be in the format \'+2XXYYYYYYYYY\'');<commit_msg>[FIX] Voice constructor not passing options to method functions<commit_after><?php

namespace AfricasTalking;

class Voice extends Service
{
    private $xmlString;

    public function __call($method, $args)
    {
        // First check if method exists
        if (method_exists($this, 'build' . $method)) {
			if (!isset($args[0])) {
				$args = [ 0 => ''];
			}
            return $this->stringBuilder('build'. $method, $args[0]);
        } else if (method_exists($this, 'do' . $method)) {
			if (!isset($args[0])) {
				$args = [ 0 => ''];
			}
            return $this->apiCall('do' . $method, $args[0]);
        } else {
            return $this->error($method .' is an invalid Voice SDK Method');
        }
    }

    public function messageBuilder()
    {
        return $this;
    }

    private function stringBuilder($method, $args)
    {
        $result = $this->$method($args);

        if (empty($this->xmlString)) {
            $this->xmlString = '<?xml version="1.0" encoding="UTF-8"?><Response>'. $result;
        } else {
            $this->xmlString .= $result;
        }

        return $this;
    }

    private function apiCall($method, $args)
    {
        return $this->$method($args);
    } 

    /**
     * Builds XML string from chained voice actions
     *
     * @return string
     */
    public function build()
    {
        if (empty($this->xmlString)) {
            return null;
        }
        return $this->xmlString . '</Response>';
    }
    
    protected function doCall($options)
    {
		if (!isset($options['to']) || !isset($options['from'])) {
			return $this->error('The parameters to and from must be defined');
        }

        // Validate callTo
        $checkCallTo = strpos($options['to'], '+');
        if ($checkCallTo === false || $checkCallTo !== 0) {
            return $this->error('to must be in the format \'+2XXYYYYYYYYY\'');
        }
        
        // Validate callFrom
        $checkCallFrom = strpos($options['from'], '+');
        if ($checkCallFrom === false || $checkCallFrom !== 0) {
            return $this->error('from must be in the format \'+2XXYYYYYYYYY\'');
{'fraction_non_alphanumeric': 0.1692200557103064, 'fraction_numerical': 0.006731662024141133, 'mean_word_length': 2.073466476462197, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 2, '>': 40, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 14}, 'pii_count': 0, 'substrings_counts': 4, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5952930', 'n_tokens_mistral': 1335, 'n_tokens_neox': 1271, 'n_words': 309}