Build Audio Subdef object depending the SimpleXMLElement

@param  SimpleXMLElement $sd
@return Audio
766673
protected function buildAudioSubdef(SimpleXMLElement $sd)
    {
        $audio = new Audio($this->translator);
        if ($sd->acodec) {
            $audio->setOptionValue(Audio::OPTION_ACODEC, (string) $sd->acodec);
        }
        if ($sd->audiobitrate) {
            $audio->setOptionValue(Audio::OPTION_AUDIOBITRATE, (int) $sd->audiobitrate);
        }
        if ($sd->audiosamplerate) {
            $audio->setOptionValue(Audio::OPTION_AUDIOSAMPLERATE, (int) $sd->audiosamplerate);
        }
        if ($sd->audiochannel) {
            $audio->setOptionValue(Audio::OPTION_AUDIOCHANNEL, (string) $sd->audiochannel);
        }

        return $audio;
    }
531730
protected function _getMinkDriver($sDriver)
    {
        $browserName = $this->getTestConfig()->getBrowserName();
        switch ($sDriver) {
            case 'selenium':
                $client = $this->_getClient();
                $oDriver = new \Behat\Mink\Driver\SeleniumDriver($browserName, shopURL, $client);
                break;
            default:
                throw new Exception('Driver ' . $sDriver . ' not supported any more!');
                break;
        }

        return $oDriver;
    }
646664
public function buildMimeIds($id = null, $rfc822 = false)
    {
        $this->_status &= ~self::STATUS_REINDEX;

        if (is_null($id)) {
            $rfc822 = true;
            $id = '';
        }

        if ($rfc822) {
            if (empty($this->_parts) &&
                ($this->getPrimaryType() != 'multipart')) {
                $this->setMimeId($id . '1');
            } else {
                if (empty($id) && ($this->getType() == 'message/rfc822')) {
                    $this->setMimeId('1.0');
                } else {
                    $this->setMimeId($id . '0');
                }
                $i = 1;
                foreach ($this as $val) {
                    $val->buildMimeIds($id . ($i++));
                }
            }
        } else {
            $this->setMimeId($id);
            $id = $id
                ? ((substr($id, -2) === '.0') ? substr($id, 0, -1) : ($id . '.'))
                : '';

            if (count($this)) {
                if ($this->getType() == 'message/rfc822') {
                    $this->rewind();
                    $this->current()->buildMimeIds($id, true);
                } else {
                    $i = 1;
                    foreach ($this as $val) {
                        $val->buildMimeIds($id . ($i++));
                    }
                }
            }
        }
    }
1032699
protected function buildDomDocumentFromXml($xml)
    {
        // see the following URL for this trick:
        // http://stackoverflow.com/questions/15223224/how-to-remove-all-namespaces-from-xml-in-php-tags-and-attributes

        $sxe     = new \SimpleXMLElement($xml);
        $dom_sxe = dom_import_simplexml($sxe);

        $dom     = new DOMDocument('1.0');
        $dom_sxe = $dom->importNode($dom_sxe, true);
        $dom->appendChild($dom_sxe);

        /** @var DOMElement $element */
        $element = $dom->childNodes->item(0);


        foreach ($sxe->getDocNamespaces(true) as $name => $uri) {

            $element->removeAttributeNS($uri, $name);
        }

        return $dom;
    }
664887
public function ls($subdir = '', &$raw = NULL)
    {

        $teststr  = str_replace('\\', '-', $subdir);
        $nub =  (preg_match('/[-?|\/?]*([\w \-]+\.\w{1,4})/', $teststr))?'':'\*';

        $this->execute("ls $subdir".$nub, $raw_ls);

        $raw = $raw_ls;
        $ret = ($raw_ls)? $this->processLS($raw_ls, $subdir):0;
        return $ret;
    }
1316113
public static function buildResponseRule( SimpleXMLElement $data)
    {
        $returnValue = null;

	    switch ($data->getName()) {
			case 'exitResponse' : $returnValue = new ExitResponse();
				break;
			case 'setOutcomeValue' :
				$identifier = (string)$data['identifier'];
				$children = array();
				foreach ($data->children() as $child){
					$children[] = $child;
				}
				$expression = ExpressionParserFactory::build(array_shift($children));
				$returnValue = new SetOutcomeVariable($identifier, $expression);
				break;
			case 'responseCondition' :
				$returnValue = self::buildResponseCondition($data);
				break;
			default :
				throw new ParsingException('unknwown element '.$data->getName().' in ResponseProcessing');
		}

        return $returnValue;
    }
349988
public static function audioHtml($sources)
    {
        $code = '<audio controls>';

        foreach ((array) $sources as $source) {
            $code .= self::element('source', ['src' => $source]);
        }

        return $code.'</audio>';
    }
449155
public function loadAndResolveFile(): \SimpleXMLElement
    {
        $content = \file_get_contents($this->path);
        $strpos = \strpos($content, '?>')+2;
        if (!\file_exists(__DIR__.'/../doc/entities/generated.ent')) {
            self::buildEntities();
        }
        $path = \realpath(__DIR__.'/../doc/entities/generated.ent');


        $content = \substr($content, 0, $strpos)
            .'<!DOCTYPE refentry SYSTEM "'.$path.'">'
            .\substr($content, $strpos+1);

        echo 'Loading '.$this->path."\n";
        $elem = \simplexml_load_string($content, \SimpleXMLElement::class, LIBXML_DTDLOAD | LIBXML_NOENT);
        if ($elem === false) {
            throw new \RuntimeException('Invalid XML file for '.$this->path);
        }
        $elem->registerXPathNamespace('docbook', 'http://docbook.org/ns/docbook');

        return $elem;
    }
389275
public function CreateElement($pw){
		PhpWsdl::Debug('Create WSDL definition for element '.$this->Name);
		$res='<s:element minOccurs="'.$this->MinOccurs.'" maxOccurs="'.$this->MaxOccurs.'" nillable="'.(($this->NillAble)?'true':'false').'" name="'.$this->Name.'" type="';
		$res.=PhpWsdl::TranslateType($this->Type).'"';
		if($pw->IncludeDocs&&!$pw->Optimize&&!is_null($this->Docs)){
			$res.='>'."\n";
			$res.='<s:annotation>'."\n";
			$res.='<s:documentation><![CDATA['.$this->Docs.']]></s:documentation>'."\n";
			$res.='</s:annotation>'."\n";
			$res.='</s:element>';
		}else{
			$res.=' />';
		}
		return $res;
	}
185172
public static function sDecode($string = '', $skey = 'wenzi' , $mix = array('#b1'=>'+' , '#b2'=>'/' , '@A' => ' ')) {
        $string = base64_decode( $string , TRUE  );
        if($mix){
            $arrayKey = array_keys($mix);
            $arrayValue = array_values($mix);
            $string = str_replace($arrayKey,$arrayValue , $string);
        }
        $strlen = strlen($string);
        $skLen = strlen($skey);
        $str = '';
        for($i=0; $i < $strlen ; $i++){
            $sI =  $i % $skLen;
            $str .= $string[$i] ^ $skey[$sI];
        }

        return base64_decode($str , true);
    }
439856
public function _build_xml ($k, $v) {
		if (is_object ($v) && strtolower (get_class ($v)) == 'simplexmlelement') {
			return preg_replace ('/<\?xml(.*?)\?>\n*/', '', $v->asXML ());
		}
		$res = '';
		$attrs = '';
		if (! is_numeric ($k)) {
			$res = '<' . $k . '{{attributes}}>';
		}
		if (is_object ($v)) {
			$v = (array) $v;
		}
		if (is_array ($v)) {
			foreach ($v as $key => $value) {
				// handle attributes of repeating tags
				if (is_numeric ($key) && is_array ($value)) {
					foreach ($value as $sub_key => $sub_value) {
						if (strpos ($sub_key, '@') === 0) {
							$attrs .= ' ' . substr ($sub_key, 1) . '="' . $this->_xml_entities ($sub_value) . '"';
							unset ($value[$sub_key]);
							continue;
						}
					}
				}

				if (strpos ($key, '@') === 0) {
					$attrs .= ' ' . substr ($key, 1) . '="' . $this->_xml_entities ($value) . '"';
					continue;
				}
				$res .= $this->_build_xml ($key, $value);
				$keys = array_keys ($v);
				if (is_numeric ($key) && $key !== array_pop ($keys)) {
					// reset attributes on repeating tags
					if (is_array ($value)) {
						$res = str_replace ('<' . $k . '{{attributes}}>', '<' . $k . $attrs . '>', $res);
						$attrs = '';
					}
					$res .= '</' . $k . ">\n<" . $k . '{{attributes}}>';
				}
			}
		} else {
			$res .= $this->_xml_entities ($v);
		}
		if (! is_numeric ($k)) {
			$res .= '</' . $k . ">\n";
		}
		$res = str_replace ('<' . $k . '{{attributes}}>', '<' . $k . $attrs . '>', $res);
		return $res;
	}
841495
public function build(): GetEventListenersRequest
	{
		$instance = new GetEventListenersRequest();
		if ($this->objectId === null) {
			throw new BuilderException('Property [objectId] is required.');
		}
		$instance->objectId = $this->objectId;
		$instance->depth = $this->depth;
		$instance->pierce = $this->pierce;
		return $instance;
	}
1244291
function toMusicXML() {
        $out  = '';
        $out .= '<accent';
        if (!empty($this->placement)) {
	        $out .= ' placement="'.$this->placement.'"';
	    }
        if (!empty($this->type)) {
	        $out .= ' type="'.$this->type.'"';
	    }
        if (!empty($this->defaultX)) {
	        $out .= ' default-x="'.$this->defaultX.'"';
	    }
        if (!empty($this->defaultY)) {
	        $out .= ' default-y="'.$this->defaultY.'"';
	    }

        $out .= '/>';
        return $out;
    }
72238
public function element(String $element, String $str = NULL, Array $attributes = []) : String
    {
        return $this->_multiElement($element, $str, $attributes);
    }
1164081
private function getAudio()
    {
        $audioUrl = 'http://file.api.wechat.com/cgi-bin/media/get?access_token='.$this->getAccessToken().'&media_id='.$this->event->get('MediaId');

        return [new Audio($audioUrl, $this->event)];
    }
114688
function toMusicXML() {
        $out  = '';
        $out .= '<tuplet';
        $out .= ' bracket="'.$this->bracket.'"';
        $out .= ' number="'.$this->number.'"';
        $out .= ' placement="'.$this->placement.'"';
        $out .= ' type="'.$this->type.'"';
        $out .= '/>';
        return $out;
    }
670774
static function simpleXmlToStdClass(SimpleXMLElement &$source)
  {
    $res = new StdClass;
    $children = false;
    foreach ($source as $key => $value) {
      if (isset($res->$key)) {
        if (!is_array($res->$key)) {
          $res->$key = array($res->$key);
        }
        $ref = &$res->$key;
        $ref[] = CPS_Response::simpleXmlToStdClass($value);
      } else {
        $res->$key = CPS_Response::simpleXmlToStdClass($value);
      }
      $children = true;
    }
    if (!$children)
      return (string)$source;
    return $res;
  }