How to use CallInfo class

Best Phake code snippet using CallInfo

ComplexTypeStrategy.php

Source:ComplexTypeStrategy.php Github

copy

Full Screen

...50 /**51 * Add complex type.52 *53 * @param string $type54 * @param array $parentCallInfo array of callInfo from parent complex type55 * @return string56 * @throws \InvalidArgumentException57 */58 public function addComplexType($type, $parentCallInfo = [])59 {60 if (($soapType = $this->scanRegisteredTypes($type)) !== null) {61 return $soapType;62 }63 $soapType = Wsdl::TYPES_NS . ':' . $type;64 // Register type here to avoid recursion65 $this->getContext()->addType($type, $soapType);66 $complexType = $this->_getDom()->createElement(Wsdl::XSD_NS . ':complexType');67 $complexType->setAttribute('name', $type);68 $typeData = $this->_typeProcessor->getTypeData($type);69 if (isset($typeData['documentation'])) {70 $this->addAnnotation($complexType, $typeData['documentation']);71 }72 if (isset($typeData['parameters']) && is_array($typeData['parameters'])) {73 $callInfo = isset($typeData['callInfo']) ? $typeData['callInfo'] : $parentCallInfo;74 $sequence = $this->_processParameters($typeData['parameters'], $callInfo);75 $complexType->appendChild($sequence);76 }77 $this->getContext()->getSchema()->appendChild($complexType);78 return $soapType;79 }80 /**81 * Process type parameters and create complex type sequence.82 *83 * @param array $parameters84 * @param array $callInfo85 * @return \DOMElement86 */87 protected function _processParameters($parameters, $callInfo)88 {89 $sequence = $this->_getDom()->createElement(Wsdl::XSD_NS . ':sequence');90 foreach ($parameters as $parameterName => $parameterData) {91 $parameterType = $parameterData['type'];92 $element = $this->_getDom()->createElement(Wsdl::XSD_NS . ':element');93 $element->setAttribute('name', $parameterName);94 $isRequired = isset($parameterData['required']) && $parameterData['required'];95 $default = isset($parameterData['default']) ? $parameterData['default'] : null;96 $this->_revertRequiredCallInfo($isRequired, $callInfo);97 if ($this->_typeProcessor->isArrayType($parameterType)) {98 $this->_processArrayParameter($parameterType, $callInfo);99 $element->setAttribute(100 'type',101 Wsdl::TYPES_NS . ':' . $this->_typeProcessor->translateArrayTypeName($parameterType)102 );103 if (!$isRequired) {104 $element->setAttribute('minOccurs', 0);105 }106 } else {107 $this->_processParameter($element, $isRequired, $parameterData, $parameterType, $callInfo);108 }109 $this->addAnnotation($element, $parameterData['documentation'], $default, $callInfo);110 $sequence->appendChild($element);111 }112 return $sequence;113 }114 /**115 * Process parameter and declare complex type if necessary.116 *117 * @param \DOMElement $element118 * @param boolean $isRequired119 * @param array $parameterData120 * @param string $parameterType121 * @param array $callInfo122 * @return void123 */124 protected function _processParameter(\DOMElement $element, $isRequired, $parameterData, $parameterType, $callInfo)125 {126 $element->setAttribute('minOccurs', $isRequired ? 1 : 0);127 $maxOccurs = isset($parameterData['isArray']) && $parameterData['isArray'] ? 'unbounded' : 1;128 $element->setAttribute('maxOccurs', $maxOccurs);129 if ($this->_typeProcessor->isTypeSimple($parameterType) || $this->_typeProcessor->isTypeAny($parameterType)) {130 $typeNs = Wsdl::XSD_NS;131 } else {132 $typeNs = Wsdl::TYPES_NS;133 $this->addComplexType($parameterType, $callInfo);134 }135 $element->setAttribute('type', $typeNs . ':' . $parameterType);136 }137 /**138 * Process array of types.139 *140 * @param string $type141 * @param array $callInfo142 * @return void143 */144 protected function _processArrayParameter($type, $callInfo = [])145 {146 $arrayItemType = $this->_typeProcessor->getArrayItemType($type);147 $arrayTypeName = $this->_typeProcessor->translateArrayTypeName($type);148 if (!$this->_typeProcessor->isTypeSimple($arrayItemType) && !$this->_typeProcessor->isTypeAny($arrayItemType)) {149 $this->addComplexType($arrayItemType, $callInfo);150 }151 $arrayTypeParameters = [152 self::ARRAY_ITEM_KEY_NAME => [153 'type' => $arrayItemType,154 'required' => false,155 'isArray' => true,156 'documentation' => sprintf('An item of %s.', $arrayTypeName),157 ],158 ];159 $arrayTypeData = [160 'documentation' => sprintf('An array of %s items.', $arrayItemType),161 'parameters' => $arrayTypeParameters,162 ];163 $this->_typeProcessor->setTypeData($arrayTypeName, $arrayTypeData);164 $this->addComplexType($arrayTypeName, $callInfo);165 }166 /**167 * Revert required call info data if needed.168 *169 * @param bool $isRequired170 * @param array &$callInfo171 * @return void172 */173 protected function _revertRequiredCallInfo($isRequired, &$callInfo)174 {175 if (!$isRequired) {176 if (isset($callInfo['requiredInput']['yes'])) {177 $callInfo['requiredInput']['no']['calls'] = $callInfo['requiredInput']['yes']['calls'];178 unset($callInfo['requiredInput']['yes']);179 }180 if (isset($callInfo['returned']['always'])) {181 $callInfo['returned']['conditionally']['calls'] = $callInfo['returned']['always']['calls'];182 unset($callInfo['returned']['always']);183 }184 }185 }186 /**187 * Generate annotation data for WSDL.188 *189 * Convert all {key:value} from documentation into appinfo nodes.190 * Override default callInfo values if defined in parameter documentation.191 *192 * @param \DOMElement $element193 * @param string $documentation parameter documentation string194 * @param string|null $default195 * @param array $callInfo196 * @return void197 */198 public function addAnnotation(\DOMElement $element, $documentation, $default = null, $callInfo = [])199 {200 $annotationNode = $this->_getDom()->createElement(Wsdl::XSD_NS . ':annotation');201 $elementType = $this->_getElementType($element);202 $appInfoNode = $this->_getDom()->createElement(Wsdl::XSD_NS . ':appinfo');203 $appInfoNode->setAttributeNS(204 Wsdl::XML_NS_URI,205 Wsdl::XML_NS . ':' . self::APP_INF_NS,206 $this->getContext()->getTargetNamespace()207 );208 $this->_processDefaultValueAnnotation($elementType, $default, $appInfoNode);209 $this->_processElementType($elementType, $documentation, $appInfoNode);210 if (preg_match_all('/{([a-z]+):(.+)}/Ui', $documentation, $matches)) {211 $count = count($matches[0]);212 for ($i = 0; $i < $count; $i++) {213 $appinfoTag = $matches[0][$i];214 $tagName = $matches[1][$i];215 $tagValue = $matches[2][$i];216 switch ($tagName) {217 case 'callInfo':218 $callInfoRegExp = '/([a-z].+):(returned|requiredInput):(yes|no|always|conditionally)/i';219 if (preg_match($callInfoRegExp, $tagValue)) {220 list($callName, $direction, $condition) = explode(':', $tagValue);221 $condition = strtolower($condition);222 if (preg_match('/allCallsExcept\(([a-zA-Z].+)\)/', $callName, $calls)) {223 $callInfo[$direction][$condition] = [224 'allCallsExcept' => $calls[1],225 ];226 } elseif (!isset($callInfo[$direction][$condition]['allCallsExcept'])) {227 $this->_overrideCallInfoName($callInfo, $callName);228 $callInfo[$direction][$condition]['calls'][] = $callName;229 }230 }231 break;232 case 'seeLink':233 $this->_processSeeLink($appInfoNode, $tagValue);234 break;235 case 'docInstructions':236 $this->_processDocInstructions($appInfoNode, $tagValue);237 break;238 default:239 $nodeValue = trim($tagValue);240 $simpleTextNode = $this->_getDom()->createElement(self::APP_INF_NS . ':' . $tagName);241 $simpleTextNode->appendChild($this->_getDom()->createTextNode($nodeValue));242 $appInfoNode->appendChild($simpleTextNode);243 break;244 }245 $documentation = str_replace($appinfoTag, '', $documentation);246 }247 }248 $this->_processCallInfo($appInfoNode, $callInfo);249 $documentationNode = $this->_getDom()->createElement(Wsdl::XSD_NS . ':documentation');250 $documentationText = trim($documentation);251 $documentationNode->appendChild($this->_getDom()->createTextNode($documentationText));252 $annotationNode->appendChild($documentationNode);253 $annotationNode->appendChild($appInfoNode);254 $element->appendChild($annotationNode);255 }256 /**257 * Process different element types.258 *259 * @param string $elementType260 * @param string $documentation261 * @param \DOMElement $appInfoNode262 * @return void263 */264 protected function _processElementType($elementType, $documentation, \DOMElement $appInfoNode)265 {266 if ($elementType == 'int') {267 $this->_processRequiredAnnotation('min', $documentation, $appInfoNode);268 $this->_processRequiredAnnotation('max', $documentation, $appInfoNode);269 }270 if ($elementType == 'string') {271 $this->_processRequiredAnnotation('maxLength', $documentation, $appInfoNode);272 }273 if ($this->_typeProcessor->isArrayType($elementType)) {274 $natureOfTypeNode = $this->_getDom()->createElement(self::APP_INF_NS . ':natureOfType');275 $natureOfTypeNode->appendChild($this->_getDom()->createTextNode('array'));276 $appInfoNode->appendChild($natureOfTypeNode);277 }278 }279 /**280 * Process default value annotation.281 *282 * @param string $elementType283 * @param string $default284 * @param \DOMElement $appInfoNode285 * @return void286 */287 protected function _processDefaultValueAnnotation($elementType, $default, \DOMElement $appInfoNode)288 {289 if ($elementType == 'boolean') {290 $default = (bool)$default ? 'true' : 'false';291 }292 if ($default) {293 $defaultNode = $this->_getDom()->createElement(self::APP_INF_NS . ':default');294 $defaultNode->appendChild($this->_getDom()->createTextNode($default));295 $appInfoNode->appendChild($defaultNode);296 }297 }298 /**299 * Retrieve element type.300 *301 * @param \DOMElement $element302 * @return string|null303 * @SuppressWarnings(PHPMD.UnusedLocalVariable)304 */305 protected function _getElementType(\DOMElement $element)306 {307 $elementType = null;308 if ($element->hasAttribute('type')) {309 list($typeNs, $elementType) = explode(':', $element->getAttribute('type'));310 }311 return $elementType;312 }313 /**314 * Check if there is given annotation in documentation, and if not - create an empty one.315 *316 * @param string $annotation317 * @param string $documentation318 * @param \DOMElement $appInfoNode319 * @return void320 */321 protected function _processRequiredAnnotation($annotation, $documentation, \DOMElement $appInfoNode)322 {323 if (!preg_match("/{{$annotation}:.+}/Ui", $documentation)) {324 $annotationNode = $this->_getDom()->createElement(self::APP_INF_NS . ':' . $annotation);325 $appInfoNode->appendChild($annotationNode);326 }327 }328 /**329 * Process 'callInfo' appinfo tag.330 *331 * @param \DOMElement $appInfoNode332 * @param array $callInfo333 * @return void334 */335 protected function _processCallInfo(\DOMElement $appInfoNode, $callInfo)336 {337 if (!empty($callInfo)) {338 foreach ($callInfo as $direction => $conditions) {339 foreach ($conditions as $condition => $info) {340 $callInfoNode = $this->_getDom()->createElement(self::APP_INF_NS . ':callInfo');341 if (isset($info['allCallsExcept'])) {342 $allExceptNode = $this->_getDom()->createElement(self::APP_INF_NS . ':allCallsExcept');343 $allExceptNode->appendChild($this->_getDom()->createTextNode($info['allCallsExcept']));344 $callInfoNode->appendChild($allExceptNode);345 } elseif (isset($info['calls'])) {346 foreach ($info['calls'] as $callName) {347 $callNode = $this->_getDom()->createElement(self::APP_INF_NS . ':callName');348 $callNode->appendChild($this->_getDom()->createTextNode($callName));349 $callInfoNode->appendChild($callNode);350 }351 }352 $directionNode = $this->_getDom()->createElement(self::APP_INF_NS . ':' . $direction);353 $directionNode->appendChild($this->_getDom()->createTextNode(ucfirst($condition)));354 $callInfoNode->appendChild($directionNode);355 $appInfoNode->appendChild($callInfoNode);356 }357 }358 }359 }360 /**361 * Process 'docInstructions' appinfo tag.362 *363 * @param \DOMElement $appInfoNode364 * @param string $tagValue365 * @return void366 */367 protected function _processDocInstructions(\DOMElement $appInfoNode, $tagValue)368 {369 if (preg_match('/(input|output):(.+)/', $tagValue, $docMatches)) {370 $docInstructionsNode = $this->_getDom()->createElement(self::APP_INF_NS . ':docInstructions');371 $directionNode = $this->_getDom()->createElement(self::APP_INF_NS . ':' . $docMatches[1]);372 $directionValueNode = $this->_getDom()->createElement(self::APP_INF_NS . ':' . $docMatches[2]);373 $directionNode->appendChild($directionValueNode);374 $docInstructionsNode->appendChild($directionNode);375 $appInfoNode->appendChild($docInstructionsNode);376 }377 }378 /**379 * Process 'seeLink' appinfo tag.380 *381 * @param \DOMElement $appInfoNode382 * @param string $tagValue383 * @return void384 */385 protected function _processSeeLink(\DOMElement $appInfoNode, $tagValue)386 {387 if (preg_match('|([http://]?.+):(.+):(.+)|i', $tagValue, $matches)) {388 $seeLink = ['url' => $matches[1], 'title' => $matches[2], 'for' => $matches[3]];389 $seeLinkNode = $this->_getDom()->createElement(self::APP_INF_NS . ':seeLink');390 foreach (['url', 'title', 'for'] as $subNodeName) {391 if (isset($seeLink[$subNodeName])) {392 $seeLinkSubNode = $this->_getDom()->createElement(self::APP_INF_NS . ':' . $subNodeName);393 $seeLinkSubNode->appendChild($this->_getDom()->createTextNode($seeLink[$subNodeName]));394 $seeLinkNode->appendChild($seeLinkSubNode);395 }396 }397 $appInfoNode->appendChild($seeLinkNode);398 }399 }400 /**401 * Delete callName if it's already defined in some direction group.402 *403 * @param array &$callInfo404 * @param string $callName405 * @return void406 */407 protected function _overrideCallInfoName(&$callInfo, $callName)408 {409 foreach ($callInfo as $direction => &$callInfoData) {410 foreach ($callInfoData as $condition => &$data) {411 if (isset($data['calls'])) {412 $foundCallNameIndex = array_search($callName, $data['calls']);413 if ($foundCallNameIndex !== false) {414 unset($data['calls'][$foundCallNameIndex]);415 if (empty($data['calls'])) {416 unset($callInfo[$direction][$condition]);417 }418 break;419 }420 }421 }...

Full Screen

Full Screen

CallInfo

Using AI Code Generation

copy

Full Screen

1require_once('callinfo.php');2$callinfo = new CallInfo();3$country_code = $callinfo->getCountryCode();4$country_name = $callinfo->getCountryName();5$state_name = $callinfo->getStateName();6$city_name = $callinfo->getCityName();7$latitude = $callinfo->getLatitude();8$longitude = $callinfo->getLongitude();9$carrier_name = $callinfo->getCarrierName();10$carrier_code = $callinfo->getCarrierCode();11$carrier_type = $callinfo->getCarrierType();12$carrier_network = $callinfo->getCarrierNetwork();13$calling_code = $callinfo->getCallingCode();14$zip_code = $callinfo->getZipCode();15$time_zone = $callinfo->getTimeZone();16$area_code = $callinfo->getAreaCode();17$isp_name = $callinfo->getIspName();18$isp_code = $callinfo->getIspCode();19$isp_type = $callinfo->getIspType();20$connection_type = $callinfo->getConnectionType();21$connection_name = $callinfo->getConnectionName();22$connection_code = $callinfo->getConnectionCode();23$connection_speed = $callinfo->getConnectionSpeed();24$connection_speed_type = $callinfo->getConnectionSpeedType();25$connection_speed_unit = $callinfo->getConnectionSpeedUnit();26$connection_status = $callinfo->getConnectionStatus();27$connection_status_code = $callinfo->getConnectionStatusCode();28$connection_status_name = $callinfo->getConnectionStatusName();

Full Screen

Full Screen

CallInfo

Using AI Code Generation

copy

Full Screen

1require_once('PhakeCallInfo.php');2$callInfo = new CallInfo();3$callInfo->setCallId(1);4$callInfo->setCallType('voice');5$callInfo->setCallDate('2013-06-24');6$callInfo->setCallTime('15:30:00');7$callInfo->setCallDuration(120);8$callInfo->setCallStatus('busy');9$callInfo->setCallSource('1234567890');10$callInfo->setCallDestination('0987654321');11$callInfo->setCallDirection('outgoing');12require_once('PhakeCallInfo.php');13$callInfo = new CallInfo();14$callInfo->setCallId(1);15$callInfo->setCallType('voice');16$callInfo->setCallDate('2013-06-24');17$callInfo->setCallTime('15:30:00');18$callInfo->setCallDuration(120);19$callInfo->setCallStatus('busy');20$callInfo->setCallSource('1234567890');21$callInfo->setCallDestination('0987654321');22$callInfo->setCallDirection('outgoing');23$callInfo->setCallId(1);24$callInfo->setCallType('voice');25$callInfo->setCallDate('2013-06-24');26$callInfo->setCallTime('15:30:00');27$callInfo->setCallDuration(120);28$callInfo->setCallStatus('busy');29$callInfo->setCallSource('1234567890');30$callInfo->setCallDestination('0987654321');31$callInfo->setCallDirection('outgoing');32$callInfo->setCallId(1);33$callInfo->setCallType('voice');34$callInfo->setCallDate('2013-06-24');35$callInfo->setCallTime('15:30:00');36$callInfo->setCallDuration(120);37$callInfo->setCallStatus('busy');38$callInfo->setCallSource('1234567890');39$callInfo->setCallDestination('0987654321');40$callInfo->setCallDirection('outgoing');41$callInfo->setCallId(1);42$callInfo->setCallType('voice');

Full Screen

Full Screen

CallInfo

Using AI Code Generation

copy

Full Screen

1require_once('phakecall.php');2$callinfo = new CallInfo();3$callinfo->GetCallInfo();4$callerid = $callinfo->CallerId;5$callednumber = $callinfo->CalledNumber;6$calltype = $callinfo->CallType;7$callstatus = $callinfo->CallStatus;8$callduration = $callinfo->CallDuration;9$calltime = $callinfo->CallTime;10$calldate = $callinfo->CallDate;11$calldatetime = $callinfo->CallDateTime;12$calldirection = $callinfo->CallDirection;13$callcost = $callinfo->CallCost;14$callcurrency = $callinfo->CallCurrency;15$callrate = $callinfo->CallRate;16$callrateunit = $callinfo->CallRateUnit;17$callrateunit = $callinfo->CallRateUnit;

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Phake automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used methods in CallInfo

Run Selenium Automation Tests on LambdaTest Cloud Grid

Trigger Selenium automation tests on a cloud-based Grid of 3000+ real browsers and operating systems.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful