_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 83
13k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q255800 | IntuitBatchResponse.getResult | test | public function getResult(){
if(isset($this->entity)){
return $this->entity;
}else if(isset($this->entities)){
return $this->entities;
} else{
return null;
}
} | php | {
"resource": ""
} |
q255801 | Zend_Soap_AutoDiscover.setUri | test | public function setUri($uri)
{
if (!is_string($uri) && !($uri instanceof Zend_Uri)) {
require_once "Zend/Soap/AutoDiscover/Exception.php";
throw new Zend_Soap_AutoDiscover_Exception("No uri given to Zend_Soap_AutoDiscover::setUri as string or Zend_Uri instance.");
}
$this->_uri = $uri;
// change uri in WSDL file also if existant
if ($this->_wsdl instanceof Zend_Soap_Wsdl) {
$this->_wsdl->setUri($uri);
}
return $this;
} | php | {
"resource": ""
} |
q255802 | Zend_Soap_AutoDiscover.getUri | test | public function getUri()
{
if ($this->_uri !== null) {
$uri = $this->_uri;
} else {
$schema = $this->getSchema();
$host = $this->getHostName();
$scriptName = $this->getRequestUriWithoutParameters();
$uri = Zend_Uri::factory($schema . '://' . $host . $scriptName);
$this->setUri($uri);
}
return $uri;
} | php | {
"resource": ""
} |
q255803 | Zend_Soap_AutoDiscover.getRequestUriWithoutParameters | test | protected function getRequestUriWithoutParameters()
{
if (isset($_SERVER['HTTP_X_REWRITE_URL'])) { // check this first so IIS will catch
$requestUri = $_SERVER['HTTP_X_REWRITE_URL'];
} elseif (isset($_SERVER['REQUEST_URI'])) {
$requestUri = $_SERVER['REQUEST_URI'];
} elseif (isset($_SERVER['ORIG_PATH_INFO'])) { // IIS 5.0, PHP as CGI
$requestUri = $_SERVER['ORIG_PATH_INFO'];
} else {
$requestUri = $_SERVER['SCRIPT_NAME'];
}
if (($pos = strpos($requestUri, "?")) !== false) {
$requestUri = substr($requestUri, 0, $pos);
}
return $requestUri;
} | php | {
"resource": ""
} |
q255804 | Zend_Soap_AutoDiscover.setComplexTypeStrategy | test | public function setComplexTypeStrategy($strategy)
{
$this->_strategy = $strategy;
if ($this->_wsdl instanceof Zend_Soap_Wsdl) {
$this->_wsdl->setComplexTypeStrategy($strategy);
}
return $this;
} | php | {
"resource": ""
} |
q255805 | Zend_Soap_AutoDiscover.setClass | test | public function setClass($class, $namespace = '', $argv = null)
{
$uri = $this->getUri();
$wsdl = new Zend_Soap_Wsdl($class, $uri, $this->_strategy);
// The wsdl:types element must precede all other elements (WS-I Basic Profile 1.1 R2023)
$wsdl->addSchemaTypeSection();
$port = $wsdl->addPortType($class . 'Port');
$binding = $wsdl->addBinding($class . 'Binding', 'tns:' .$class. 'Port');
$wsdl->addSoapBinding($binding, $this->_bindingStyle['style'], $this->_bindingStyle['transport']);
$wsdl->addService($class . 'Service', $class . 'Port', 'tns:' . $class . 'Binding', $uri);
foreach ($this->_reflection->reflectClass($class)->getMethods() as $method) {
$this->_addFunctionToWsdl($method, $wsdl, $port, $binding);
}
$this->_wsdl = $wsdl;
return $this;
} | php | {
"resource": ""
} |
q255806 | Zend_Soap_AutoDiscover.addFunction | test | public function addFunction($function, $namespace = '')
{
static $port;
static $operation;
static $binding;
if (!is_array($function)) {
$function = (array) $function;
}
$uri = $this->getUri();
if (!($this->_wsdl instanceof Zend_Soap_Wsdl)) {
$parts = explode('.', basename($_SERVER['SCRIPT_NAME']));
$name = $parts[0];
$wsdl = new Zend_Soap_Wsdl($name, $uri, $this->_strategy);
// The wsdl:types element must precede all other elements (WS-I Basic Profile 1.1 R2023)
$wsdl->addSchemaTypeSection();
$port = $wsdl->addPortType($name . 'Port');
$binding = $wsdl->addBinding($name . 'Binding', 'tns:' .$name. 'Port');
$wsdl->addSoapBinding($binding, $this->_bindingStyle['style'], $this->_bindingStyle['transport']);
$wsdl->addService($name . 'Service', $name . 'Port', 'tns:' . $name . 'Binding', $uri);
} else {
$wsdl = $this->_wsdl;
}
foreach ($function as $func) {
$method = $this->_reflection->reflectFunction($func);
$this->_addFunctionToWsdl($method, $wsdl, $port, $binding);
}
$this->_wsdl = $wsdl;
} | php | {
"resource": ""
} |
q255807 | Zend_Soap_AutoDiscover.dump | test | public function dump($filename)
{
if ($this->_wsdl !== null) {
return $this->_wsdl->dump($filename);
} else {
/**
* @see Zend_Soap_AutoDiscover_Exception
*/
require_once "Zend/Soap/AutoDiscover/Exception.php";
throw new Zend_Soap_AutoDiscover_Exception("Cannot dump autodiscovered contents, WSDL file has not been generated yet.");
}
} | php | {
"resource": ""
} |
q255808 | SyncRestHandler.updateContext | test | public function updateContext($newServiceContext){
if(isset($newServiceContext) && $newServiceContext instanceof ServiceContext){
$this->context = $newServiceContext;
}else{
throw new SdkException("Cannot Update Service Context. The service context either is undefined or not an instance of ServiceContext.");
}
} | php | {
"resource": ""
} |
q255809 | SyncRestHandler.sendRequest | test | public function sendRequest($requestParameters, $requestBody, $specifiedRequestUri, $throwExceptionOnError = false)
{
// This step is required since the configuration settings might have been changed.
$this->resetCompressorAndSerializer();
//Get the OAuth Authorization Mode for the request, OAuth 1 or OAuth 2.
$oMode = $this->context->IppConfiguration->OAuthMode;
// Determine dest URI
$requestUri = $this->getDestinationURL($requestParameters, $oMode, $specifiedRequestUri);
//minorVersion support
$requestUri = $this->appendMinorVersionToRequestURI($requestUri);
//Check for the HTTP method
$HttpMethod = $this->checkHTTPMethod($requestParameters);
$queryParameters = $this->parseURL($requestUri);
$baseURL = $this->getBaseURL($requestUri);
if($oMode == CoreConstants::OAUTH1){
return $this->OAuth1APICall($baseURL, $queryParameters, $HttpMethod, $requestUri, $requestParameters, $requestBody, $throwExceptionOnError);
} else if ($oMode == CoreConstants::OAUTH2){
return $this->OAuth2APICall($baseURL, $queryParameters, $HttpMethod, $requestUri, $requestParameters, $requestBody, $throwExceptionOnError);
} else{
throw new SdkException("OAuth Mode not supported.");
}
} | php | {
"resource": ""
} |
q255810 | SyncRestHandler.OAuth1APICall | test | private function OAuth1APICall($baseURL, $queryParameters, $HttpMethod, $requestUri, $requestParameters, $requestBody, $throwExceptionOnError){
$AuthorizationHeader = $this->getOAuth1AuthorizationHeader($baseURL, $queryParameters, $HttpMethod);
$httpHeaders = $this->setCommonHeadersForPHPSDK($AuthorizationHeader, $requestUri, $requestParameters->ContentType, $requestBody);
// Log Request Body to a file
$this->LogAPIRequestToLog($requestBody, $requestUri, $httpHeaders);
$intuitResponse = $this->httpClientInterface->makeAPICall($requestUri, $HttpMethod, $httpHeaders, $requestBody, null, false);
$faultHandler = $intuitResponse->getFaultHandler();
$this->LogAPIResponseToLog($intuitResponse->getBody(), $requestUri, $intuitResponse->getHeaders());
//Based on the ducomentation, the fetch expected HTTP/1.1 20X or a redirect. If not, any 3xx, 4xx or 5xx will throw an OAuth Exception
//for 3xx without direct, it will throw a 503 code and error saying: Invalid protected resource url, unable to generate signature base string
if($faultHandler) {
if($throwExceptionOnError == true){
throw new ServiceException("Request is not made successful. Body: [" . $faultHandler->getResponseBody() . "].", $faultHandler->getHttpStatusCode());
}else{
$this->faultHandler = $faultHandler;
return null;
}
}else{
$this->faultHandler = false;
}
return array($intuitResponse->getStatusCode(),$intuitResponse->getBody());
} | php | {
"resource": ""
} |
q255811 | SyncRestHandler.getOAuth1AuthorizationHeader | test | private function getOAuth1AuthorizationHeader($baseURL, $queryParameters, $HttpMethod){
$oauth1 = new OAuth1(
$this->context->requestValidator->ConsumerKey,
$this->context->requestValidator->ConsumerSecret,
$this->context->requestValidator->AccessToken,
$this->context->requestValidator->AccessTokenSecret
);
$AuthorizationHeader = $oauth1->getOAuthHeader($baseURL, $queryParameters, $HttpMethod);
return $AuthorizationHeader;
} | php | {
"resource": ""
} |
q255812 | SyncRestHandler.OAuth2APICall | test | private function OAuth2APICall($baseURL, $queryParameters, $HttpMethod, $requestUri, $requestParameters, $requestBody, $throwExceptionOnError){
$AuthorizationHeader = $this->getOAuth2AuthorizationHeader($this->context->requestValidator);
//We only support QBO for PHP SDK. No QBD support, change
// from: if ('QBO'==$this->context->serviceType || 'QBD'==$this->context->serviceType)
if (CoreConstants::IntuitServicesTypeQBO ==$this->context->serviceType) {
// IDS call
$httpHeaders = $this->setCommonHeadersForPHPSDK($AuthorizationHeader, $requestUri, $requestParameters->ContentType, $requestBody);
// Log Request Body to a file
$this->LogAPIRequestToLog($requestBody, $requestUri, $httpHeaders);
} else {
throw new SdkException("IPP or other Call is not supported in OAuth2 Mode.");
}
$intuitResponse = $this->httpClientInterface->makeAPICall($requestUri, $HttpMethod, $httpHeaders, $requestBody, null, true);
$faultHandler = $intuitResponse->getFaultHandler();
$this->LogAPIResponseToLog($intuitResponse->getBody(), $requestUri, $intuitResponse->getHeaders());
//Based on the ducomentation, the fetch expected HTTP/1.1 20X or a redirect. If not, any 3xx, 4xx or 5xx will throw an OAuth Exception
//for 3xx without direct, it will throw a 503 code and error saying: Invalid protected resource url, unable to generate signature base string
if($faultHandler) {
if($throwExceptionOnError == true){
throw new ServiceException("Request is not made successful. Response Code:[" . $faultHandler->getHttpStatusCode() . "] with body: [" . $faultHandler->getResponseBody() . "].", $faultHandler->getHttpStatusCode());
}else{
$this->faultHandler = $faultHandler;
return null;
}
}else{
$this->faultHandler = false;
}
return array($intuitResponse->getStatusCode(),$intuitResponse->getBody());
} | php | {
"resource": ""
} |
q255813 | SyncRestHandler.getOAuth2AuthorizationHeader | test | private function getOAuth2AuthorizationHeader($OAuth2AccessToken){
if(!$OAuth2AccessToken instanceof OAuth2AccessToken){
throw new SdkException("Internal Error. The OAuth 2 configuration is not complete.");
}
$accessToken = $OAuth2AccessToken->getAccessToken();
$AuthorizationHeader = "Bearer " . $accessToken;
return $AuthorizationHeader;
} | php | {
"resource": ""
} |
q255814 | SyncRestHandler.LogAPIResponseToLog | test | public function LogAPIResponseToLog($body, $requestUri, $httpHeaders){
if(strcasecmp($httpHeaders[CoreConstants::CONTENT_TYPE], CoreConstants::CONTENTTYPE_APPLICATIONXML) == 0 ||
strcasecmp($httpHeaders[CoreConstants::CONTENT_TYPE], CoreConstants::CONTENTTYPE_APPLICATIONXML_WITH_CHARSET) == 0){
$body = $this->parseStringToDom($body);
}
$this->RequestLogging->LogPlatformRequests($body, $requestUri, $httpHeaders, false);
} | php | {
"resource": ""
} |
q255815 | SyncRestHandler.LogAPIRequestToLog | test | public function LogAPIRequestToLog($requestBody, $requestUri, $httpHeaders){
$this->RequestLogging->LogPlatformRequests($requestBody, $requestUri, $httpHeaders, true);
if ($requestBody && $this->RequestCompressor) {
$this->RequestCompressor->Compress($httpHeaders, $requestBody);
}
if ($this->ResponseCompressor) {
$this->ResponseCompressor->PrepareDecompress($httpHeaders);
}
} | php | {
"resource": ""
} |
q255816 | SyncRestHandler.parseStringToDom | test | private function parseStringToDom($string){
$dom = new \DOMDocument();
$dom->preserveWhiteSpace = FALSE;
$dom->loadXML($string);
$dom->formatOutput = TRUE;
return $dom->saveXml();
} | php | {
"resource": ""
} |
q255817 | SyncRestHandler.resetCompressorAndSerializer | test | private function resetCompressorAndSerializer(){
$this->RequestCompressor = CoreHelper::GetCompressor($this->context, true);
$this->ResponseCompressor = CoreHelper::GetCompressor($this->context, false);
$this->RequestSerializer = CoreHelper::GetSerializer($this->context, true);
$this->ResponseSerializer = CoreHelper::GetSerializer($this->context, false);
} | php | {
"resource": ""
} |
q255818 | SyncRestHandler.getDestinationURL | test | private function getDestinationURL($requestParameters, $oMode, $specifiedRequestUri){
// For Platform Discconect/Reconenct call, only for OAuth 1
if (isset($requestParameters->ApiName)) {
if(strcasecmp($oMode, CoreConstants::OAUTH1) == 0)
{
// Example: "https://appcenter.intuit.com/api/v1/Account/AppMenu"
$requestUri = $this->context->baseserviceURL . $requestParameters->ApiName;
}else{
throw new SdkException("Disconnect/Reconnect Platform Call is only available in OAuth 1.0.");
}
} elseif (isset($specifiedRequestUri)) {
// Prepare the request Uri from base Uri and resource Uri.
$requestUri = $specifiedRequestUri;
} elseif (isset($requestParameters->ResourceUri)) {
$requestUri = $this->context->baseserviceURL . $requestParameters->ResourceUri;
} else {
throw new SdkException("Internal Error. UnSpecified URI Type for sending request.");
}
return $requestUri;
} | php | {
"resource": ""
} |
q255819 | SyncRestHandler.appendMinorVersionToRequestURI | test | private function appendMinorVersionToRequestURI($requestUri){
$setMinorVersion = $this->context->minorVersion;
if (isset($setMinorVersion)) {
if ($this->queryToArray($requestUri) == false) { //if no query string params
$requestUri .= "?minorversion=" . $this->context->minorVersion;
} else {
$requestUri .= "&minorversion=" . $this->context->minorVersion;
}
}
return $requestUri;
} | php | {
"resource": ""
} |
q255820 | SyncRestHandler.checkHTTPMethod | test | private function checkHTTPMethod($requestParameters){
$verb = $requestParameters->HttpVerbType;
if(strcasecmp($verb, CoreConstants::HTTP_POST) == 0){
return CoreConstants::HTTP_POST;
} else if(strcasecmp($verb, CoreConstants::HTTP_GET) == 0){
return CoreConstants::HTTP_GET;
} else{
throw new SdkException("Internal Error. Unsupported HTTP Method:" . $verb);
}
} | php | {
"resource": ""
} |
q255821 | SyncRestHandler.parseURL | test | private function parseURL($url){
$query_str = parse_url($url, PHP_URL_QUERY);
parse_str($query_str, $parameters);
return $parameters;
} | php | {
"resource": ""
} |
q255822 | SyncRestHandler.getAcceptContentType | test | private function getAcceptContentType($value)
{
if (CoreConstants::CONTENTTYPE_APPLICATIONXML === $value) {
return $value;
}
if (CoreConstants::CONTENTTYPE_APPLICATIONJSON === $value) {
return $value;
}
if (CoreConstants::CONTENTTYPE_APPLICATIONPDF === $value) {
return $value;
}
if (CoreConstants::CONTENTTYPE_OCTETSTREAM === $value) {
if ($this->ResponseSerializer instanceof XmlObjectSerializer) {
return CoreConstants::CONTENTTYPE_APPLICATIONXML;
}
if ($this->ResponseSerializer instanceof JsonObjectSerializer) {
return CoreConstants::CONTENTTYPE_APPLICATIONJSON;
}
}
return "*/*";
} | php | {
"resource": ""
} |
q255823 | SyncRestHandler.queryToArray | test | private function queryToArray($qry)
{
$result = array();
//string must contain at least one = and cannot be in first position
if (strpos($qry, '=')) {
if (strpos($qry, '?')!==false) {
$q = parse_url($qry);
$qry = $q['query'];
}
} else {
return false;
}
foreach (explode('&', $qry) as $couple) {
list($key, $val) = explode('=', $couple);
$result[$key] = $val;
}
return empty($result) ? false : $result;
} | php | {
"resource": ""
} |
q255824 | TokenVerifier.verifyPayLoad | test | public function verifyPayLoad($payLoad, $sig, $algo = null)
{
$encryptedPayload = $this->encryptPayLoadBasedOnToken($payLoad, $algo);
if (strcmp($sig, $encryptedPayload) == 0) {
return true;
} else {
return false;
}
} | php | {
"resource": ""
} |
q255825 | TokenVerifier.encryptPayLoadBasedOnToken | test | private function encryptPayLoadBasedOnToken($payLoad, $hashAlgorithm = null)
{
if ($hashAlgorithm == null) {
$hashAlgorithm = TokenVerifier::HASH_ALGORITHM;
}
$hashedPayLoad = hash_hmac($hashAlgorithm, $payLoad, $this->verifierToken);
$encodedHashedPayLoad = base64_encode(hex2bin($hashedPayLoad));
return $encodedHashedPayLoad;
} | php | {
"resource": ""
} |
q255826 | Batch.IntuitBatchResponse | test | public function IntuitBatchResponse($id)
{
if(array_key_exists($id, $this->intuitBatchItemResponses)){
return $this->intuitBatchItemResponses[$id];
}else{
return null;
}
} | php | {
"resource": ""
} |
q255827 | Batch.Remove | test | public function Remove($id)
{
if (!$id) {
$exception = new IdsException('BatchItemIdNotFound: id');
IdsExceptionManager::HandleException($exception);
}
$revisedBatchRequests = array();
foreach ($this->batchRequests as $oneBatchRequest) {
if ($oneBatchRequest->bId == $id) {
// Exclude
} else {
$revisedBatchRequests[] = $oneBatchRequest;
}
}
$this->batchRequests = $revisedBatchRequests;
} | php | {
"resource": ""
} |
q255828 | Batch.arrayToMessageAndCode | test | private function arrayToMessageAndCode(array $array)
{
if (empty($array)) {
return array(null,null);
}
if (1 == count($array)) {
$item = array_pop($array);
return array($item->message,$item->code);
}
$message = "";
$code = "";
foreach ($array as $item) {
$message .= "Exception: ".$item->message . "\n";
if (empty($code) && !empty($item->code)) {
$code = $item->code;
}
}
return array($message,$code);
} | php | {
"resource": ""
} |
q255829 | Batch.IterateFaultAndPrepareException | test | public function IterateFaultAndPrepareException($fault)
{
if (!$this->verifyFault($fault)) {
return null;
}
// Collect information from XML entity
$type = (string)$fault->attributes()->type;
list($message, $code) = $this->arrayToMessageAndCode($this->collectErrors($fault));
if (is_null($message)) {
return new IdsException("Fault Exception of type: " . $type . " has been generated.");
}
$idsException = null;
// Fault types can be of Validation, Service, Authentication and Authorization. Run them through the switch case.
switch ($type) {
// If Validation errors iterate the Errors and add them to the list of exceptions.
case "Validation":
case "ValidationFault":
// Throw specific exception like ValidationException.
$idsException = new ValidationException($message, $code);
break;
// If Validation errors iterate the Errors and add them to the list of exceptions.
case "Service":
case "ServiceFault":
// Throw specific exception like ServiceException.
$idsException = new ServiceException($message, $code);
break;
// If Validation errors iterate the Errors and add them to the list of exceptions.
case "Authentication":
case "AuthenticationFault":
case "Authorization":
case "AuthorizationFault":
$idsException = new SecurityException($message, $code);
break;
// Use this as default if there was some other type of Fault
default:
$idsException = new IdsException($message, $code);
}
// Return idsException which will be of type Validation, Service or Security.
return $idsException;
} | php | {
"resource": ""
} |
q255830 | Zend_Soap_Client.getOptions | test | public function getOptions()
{
$options = array();
$options['classmap'] = $this->getClassmap();
$options['encoding'] = $this->getEncoding();
$options['soap_version'] = $this->getSoapVersion();
$options['wsdl'] = $this->getWsdl();
$options['uri'] = $this->getUri();
$options['location'] = $this->getLocation();
$options['style'] = $this->getStyle();
$options['use'] = $this->getEncodingMethod();
$options['login'] = $this->getHttpLogin();
$options['password'] = $this->getHttpPassword();
$options['proxy_host'] = $this->getProxyHost();
$options['proxy_port'] = $this->getProxyPort();
$options['proxy_login'] = $this->getProxyLogin();
$options['proxy_password'] = $this->getProxyPassword();
$options['local_cert'] = $this->getHttpsCertificate();
$options['passphrase'] = $this->getHttpsCertPassphrase();
$options['compression'] = $this->getCompressionOptions();
//$options['connection_timeout'] = $this->_connection_timeout;
$options['stream_context'] = $this->getStreamContext();
$options['cache_wsdl'] = $this->getWsdlCache();
$options['features'] = $this->getSoapFeatures();
$options['user_agent'] = $this->getUserAgent();
foreach ($options as $key => $value) {
/*
* ugly hack as I don't know if checking for '=== null'
* breaks some other option
*/
if ($key == 'user_agent') {
if ($value === null) {
unset($options[$key]);
}
} else {
if ($value == null) {
unset($options[$key]);
}
}
}
return $options;
} | php | {
"resource": ""
} |
q255831 | Zend_Soap_Client.setStyle | test | public function setStyle($style)
{
if (!in_array($style, array(SOAP_RPC, SOAP_DOCUMENT))) {
require_once 'Zend/Soap/Client/Exception.php';
throw new Zend_Soap_Client_Exception('Invalid request style specified. Use SOAP_RPC or SOAP_DOCUMENT constants.');
}
$this->_style = $style;
$this->_soapClient = null;
return $this;
} | php | {
"resource": ""
} |
q255832 | Zend_Soap_Client.setEncodingMethod | test | public function setEncodingMethod($use)
{
if (!in_array($use, array(SOAP_ENCODED, SOAP_LITERAL))) {
require_once 'Zend/Soap/Client/Exception.php';
throw new Zend_Soap_Client_Exception('Invalid message encoding method. Use SOAP_ENCODED or SOAP_LITERAL constants.');
}
$this->_use = $use;
$this->_soapClient = null;
return $this;
} | php | {
"resource": ""
} |
q255833 | Zend_Soap_Client.setProxyPort | test | public function setProxyPort($proxyPort)
{
$this->_proxy_port = (int)$proxyPort;
$this->_soapClient = null;
return $this;
} | php | {
"resource": ""
} |
q255834 | Zend_Soap_Client.setHttpsCertificate | test | public function setHttpsCertificate($localCert)
{
if (!is_readable($localCert)) {
require_once 'Zend/Soap/Client/Exception.php';
throw new Zend_Soap_Client_Exception('Invalid HTTPS client certificate path.');
}
$this->_local_cert = $localCert;
$this->_soapClient = null;
return $this;
} | php | {
"resource": ""
} |
q255835 | Zend_Soap_Client.setStreamContext | test | public function setStreamContext($context)
{
if (!is_resource($context) || get_resource_type($context) !== "stream-context") {
/**
* @see Zend_Soap_Client_Exception
*/
require_once "Zend/Soap/Client/Exception.php";
throw new Zend_Soap_Client_Exception(
"Invalid stream context resource given."
);
}
$this->_stream_context = $context;
return $this;
} | php | {
"resource": ""
} |
q255836 | Zend_Soap_Client.setUserAgent | test | public function setUserAgent($userAgent)
{
if ($userAgent === null) {
$this->_user_agent = null;
} else {
$this->_user_agent = (string)$userAgent;
}
return $this;
} | php | {
"resource": ""
} |
q255837 | Zend_Soap_Client._doRequest | test | public function _doRequest(Zend_Soap_Client_Common $client, $request, $location, $action, $version, $one_way = null)
{
// Perform request as is
if ($one_way == null) {
return call_user_func(array($client,'SoapClient::__doRequest'), $request, $location, $action, $version);
} else {
return call_user_func(array($client,'SoapClient::__doRequest'), $request, $location, $action, $version, $one_way);
}
} | php | {
"resource": ""
} |
q255838 | Zend_Soap_Client._initSoapClientObject | test | protected function _initSoapClientObject()
{
$wsdl = $this->getWsdl();
$options = array_merge($this->getOptions(), array('trace' => true));
if ($wsdl == null) {
if (!isset($options['location'])) {
require_once 'Zend/Soap/Client/Exception.php';
throw new Zend_Soap_Client_Exception('\'location\' parameter is required in non-WSDL mode.');
}
if (!isset($options['uri'])) {
require_once 'Zend/Soap/Client/Exception.php';
throw new Zend_Soap_Client_Exception('\'uri\' parameter is required in non-WSDL mode.');
}
} else {
if (isset($options['use'])) {
require_once 'Zend/Soap/Client/Exception.php';
throw new Zend_Soap_Client_Exception('\'use\' parameter only works in non-WSDL mode.');
}
if (isset($options['style'])) {
require_once 'Zend/Soap/Client/Exception.php';
throw new Zend_Soap_Client_Exception('\'style\' parameter only works in non-WSDL mode.');
}
}
unset($options['wsdl']);
$this->_soapClient = new Zend_Soap_Client_Common(array($this, '_doRequest'), $wsdl, $options);
} | php | {
"resource": ""
} |
q255839 | Zend_Soap_Client.addSoapInputHeader | test | public function addSoapInputHeader(SoapHeader $header, $permanent = false)
{
if ($permanent) {
$this->_permanentSoapInputHeaders[] = $header;
} else {
$this->_soapInputHeaders[] = $header;
}
return $this;
} | php | {
"resource": ""
} |
q255840 | Zend_Soap_Client.getFunctions | test | public function getFunctions()
{
if ($this->getWsdl() == null) {
require_once 'Zend/Soap/Client/Exception.php';
throw new Zend_Soap_Client_Exception('\'getFunctions\' method is available only in WSDL mode.');
}
$soapClient = $this->getSoapClient();
return $soapClient->__getFunctions();
} | php | {
"resource": ""
} |
q255841 | Zend_Soap_Client.getTypes | test | public function getTypes()
{
if ($this->getWsdl() == null) {
require_once 'Zend/Soap/Client/Exception.php';
throw new Zend_Soap_Client_Exception('\'getTypes\' method is available only in WSDL mode.');
}
$soapClient = $this->getSoapClient();
return $soapClient->__getTypes();
} | php | {
"resource": ""
} |
q255842 | Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence._getTypeNameBasedOnNestingLevel | test | protected function _getTypeNameBasedOnNestingLevel($singularType, $level)
{
if ($level == 0) {
// This is not an Array anymore, return the xsd simple type
return $singularType;
} else {
$prefix = str_repeat("ArrayOf", $level);
$xsdType = $this->_getStrippedXsdType($singularType);
$arrayType = $prefix.$xsdType;
return "tns:$arrayType";
}
} | php | {
"resource": ""
} |
q255843 | Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence._addElementFromWsdlAndChildTypes | test | protected function _addElementFromWsdlAndChildTypes($arrayType, $childTypeName)
{
if (!in_array($arrayType, $this->getContext()->getTypes())) {
$dom = $this->getContext()->toDomDocument();
$complexType = $dom->createElement('xsd:complexType');
$complexType->setAttribute('name', $arrayType);
$sequence = $dom->createElement('xsd:sequence');
$element = $dom->createElement('xsd:element');
$element->setAttribute('name', 'item');
$element->setAttribute('type', $childTypeName);
$element->setAttribute('minOccurs', 0);
$element->setAttribute('maxOccurs', 'unbounded');
$sequence->appendChild($element);
$complexType->appendChild($sequence);
$this->getContext()->getSchema()->appendChild($complexType);
$this->getContext()->addType($arrayType);
}
} | php | {
"resource": ""
} |
q255844 | Wsdl_1_1.prepare | test | public function prepare()
{
$this->dom->createAttributeNS($this->namespaces['soap'], 'soap:definitions');
$this->dom->createAttributeNS($this->namespaces[$this->xmlSchemaPreffix], $this->xmlSchemaPreffix.':definitions');
//@todo this only required when we have arrays
$this->dom->createAttributeNS($this->namespaces['soapenc'], 'soapenc:definitions');
$this->wsTypes = $this->dom->createElement('wsdl:types');
$this->wsDefinitions->appendChild($this->wsTypes);
$wsXmlSchema = $this->dom->createElement($this->xmlSchemaPreffix.':schema');
$wsXmlSchema->setAttribute('targetNamespace', $this->wsdlTargetNamespace);
$this->wsXmlSchema = $this->wsTypes->appendChild($wsXmlSchema);
$portType = $this->dom->createElement('wsdl:portType');
$portType->setAttribute('name', $this->wsdlName.$this->portNameSuffix);
$this->wsPortType = $this->wsDefinitions->appendChild($portType);
$binding = $this->dom->createElement('wsdl:binding');
$binding->setAttribute('name', $this->wsdlName.$this->bindingNameSuffix);
$binding->setAttribute('type', $this->targetNsPrefix.":".$this->wsdlName.$this->portNameSuffix);
$this->wsBinding = $this->wsDefinitions->appendChild($binding);
$soapBinding = $this->dom->createElement('soap:binding');
if ($this->soapBindingStyle === SOAP_DOCUMENT) {
$soapBinding->setAttribute('style', "document");
} elseif ($this->soapBindingStyle === SOAP_RPC) {
$soapBinding->setAttribute('style', "rpc");
}
$soapBinding->setAttribute('transport', $this->soapBindingTransport);
$this->wsBinding->appendChild($soapBinding);
$wsService = $this->dom->createElement('wsdl:service');
$wsService->setAttribute('name', $this->wsdlName.$this->serviceNameSuffix);
$this->wsService = $this->wsDefinitions->appendChild($wsService);
$port = $this->dom->createElement('wsdl:port');
$port->setAttribute('name', $this->wsdlName.$this->portNameSuffix);
$port->setAttribute('binding', $this->targetNsPrefix.":".$this->wsdlName.$this->bindingNameSuffix);
$soapAddress = $this->dom->createElement('soap:address');
$soapAddress->setAttribute('location', $this->getLocation());
$port->appendChild($soapAddress);
$this->wsService->appendChild($port);
$this->extractTypes();
} | php | {
"resource": ""
} |
q255845 | Wsdl_1_1.addBindingOperations | test | private function addBindingOperations($operation, $input = false, $output = false)
{
$el = $this->dom->createElement('wsdl:operation');
$el->setAttribute('name', $operation);
$soapOperation = $this->dom->createElement('soap:operation');
$soapOperation->setAttribute('soapAction', $this->wsdlTargetNamespace."/".$operation);
$el->appendChild($soapOperation);
if ($input === true) {
$inp = $this->dom->createElement('wsdl:input');
$body = $this->dom->createElement('soap:body');
$body->setAttribute('use', 'literal');
$inp->appendChild($body);
$el->appendChild($inp);
}
if ($output === true) {
$out = $this->dom->createElement('wsdl:output');
$body = $this->dom->createElement('soap:body');
$body->setAttribute('use', 'literal');
$out->appendChild($body);
$el->appendChild($out);
}
$this->wsBinding->appendChild($el);
} | php | {
"resource": ""
} |
q255846 | Wsdl_1_1.addPortOperations | test | private function addPortOperations($operation, $input = false, $output = false)
{
$el = $this->dom->createElement("wsdl:operation");
$el->setAttribute('name', $operation);
if ($input === true) {
$input = $this->dom->createElement('wsdl:input');
$input->setAttribute('message', $this->targetNsPrefix.":".$operation);
}
if ($output === true) {
$output = $this->dom->createElement('wsdl:output');
$output->setAttribute('message', $this->targetNsPrefix.":". $operation."Response");
}
$el->appendChild($input);
$el->appendChild($output);
$this->wsPortType->appendChild($el);
} | php | {
"resource": ""
} |
q255847 | Wsdl_1_1.createRefElement | test | private function createRefElement($ref)
{
$el = $this->dom->createElement($this->xmlSchemaPreffix.':element');
$el->setAttribute('ref', $ref);
return $el;
} | php | {
"resource": ""
} |
q255848 | Wsdl_1_1.createElementWithComplexType | test | private function createElementWithComplexType($name, $elements)
{
//print_r('Create complex type '.$name."\n");
$el = $this->dom->createElement($this->xmlSchemaPreffix.':element');
$el->setAttribute('name', $name);
$compType = $this->dom->createElement($this->xmlSchemaPreffix.':complexType');
$seqType = $this->dom->createElement($this->xmlSchemaPreffix.':sequence');
foreach ($elements as $element) {
$seqType->appendChild($element);
}
$compType->appendChild($seqType);
$el->appendChild($compType);
return $el;
} | php | {
"resource": ""
} |
q255849 | Wsdl_1_1.createSimpleElement | test | private function createSimpleElement($name, $type)
{
$el = $this->dom->createElement($this->xmlSchemaPreffix.':element');
$el->setAttribute('name', $name);
if (preg_match('/:/', $type)) {
$el->setAttribute('type', $type);
} else {
$el->setAttribute('type', $this->xmlSchemaPreffix.':'.$type);
}
return $el;
} | php | {
"resource": ""
} |
q255850 | Common.resolveNamespace | test | public function resolveNamespace($shortNs)
{
if (!($this->dom instanceof \DOMDocument)) {
throw new RuntimeException("DOM is not initialized");
}
if (!is_array($this->namespaces)) {
$this->namespaces = $this->getDocNamespaces($this->dom);
}
if (array_key_exists($shortNs, $this->namespaces)) {
return $this->namespaces[$shortNs];
} else {
return $shortNs;
}
} | php | {
"resource": ""
} |
q255851 | Common.parseDocComments | test | public function parseDocComments($comments)
{
$comments = explode("\n", $comments);
$commentsOut = array();
$params = array();
foreach ($comments as $com) {
if (preg_match('/@/', $com)) {
$com = preg_replace('/\* /', '', $com);
$com = preg_replace('/@([a-zA-Z]*)( *)(.*)/', '$1|$3', $com);
$com = explode('|', $com);
//$arr = array();
if (trim($com[0]) == 'param') {
$com[1] = $this->parseParamDocs(trim($com[1]));
array_push($params, $com[1]);
$com[1] = $params;
$com[0] = "params";
}
if (trim($com[0]) == 'return') {
$com[1] = $this->parseReturnDocs(trim($com[1]));
}
$commentsOut[trim($com[0])] = trim($com[1]);
//array_push($commentsOut, array($com[0] => $com[1]));
}
}
return $commentsOut;
} | php | {
"resource": ""
} |
q255852 | ArrayUtil.isAssociateArray | test | public static function isAssociateArray(array $arr)
{
if (!empty($arr)) {
foreach ($arr as $k => $v) {
if (is_int($k)) {
return false;
}
}
return true;
}
return false;
} | php | {
"resource": ""
} |
q255853 | WebhooksService.getWebhooksEvent | test | public static function getWebhooksEvent($payLoad)
{
JsonValidator::validate($payLoad);
$string_arry = json_decode($payLoad, true);
$obj = ReflectionUtil::constructObjectFromWebhooksArray($string_arry, WebhooksService::WEBHOOKSWRAPPERNAME);
return $obj;
} | php | {
"resource": ""
} |
q255854 | WebhooksService.verifyPayload | test | public static function verifyPayload($token, $payload, $intuitHeaderSignature)
{
$verifier = new TokenVerifier($token);
return $verifier->verifyPayLoad($payload, $intuitHeaderSignature);
} | php | {
"resource": ""
} |
q255855 | FacadeHelper.isKeyInComplexList | test | private static function isKeyInComplexList($key, $complexList = NULL){
if(isset($complexList)) {$ObjectMap = $complexList;}
else {$ObjectMap = FacadeClassMapper::classMethodToList();}
foreach($ObjectMap as $objectMethodName => $entityType)
{
if(in_array($key, $entityType)){
return $objectMethodName;
}
}
return false;
} | php | {
"resource": ""
} |
q255856 | FacadeHelper.getClassMethod | test | public static function getClassMethod($className, $methodName){
try
{
$helperRefelctionMethod = new \ReflectionMethod($className, $methodName);
return $helperRefelctionMethod;
} catch(\Exception $e){
return null;
}
} | php | {
"resource": ""
} |
q255857 | FacadeHelper.getIPPReferenceTypeBasedOnArray | test | public static function getIPPReferenceTypeBasedOnArray($data){
$trimedDataArray = FacadeHelper::trimSpacesForArrayKeys($data);
if(is_object($trimedDataArray)){
if($trimedDataArray instanceof IPPReferenceType){
return $trimedDataArray;
}else{
throw new \Exception("The assigned obj to IPPReferenceType is not matched with IPPReferenceType.");
}
}
//THe ReferenceDataType should only contain at most Two elements
if(is_array($trimedDataArray)){
if(sizeof($trimedDataArray) >= 3){
throw new \Exception("Trying to construct IPPReferenceType based on Array. The array should contain at most two fields. name and value");
}
$IPPReferenceType = new IPPReferenceType();
if(isset($trimedDataArray['value']) || isset($trimedDataArray['Value']) ) {
$val = isset($trimedDataArray['value']) ? $trimedDataArray['value'] : $trimedDataArray['Value'];
$IPPReferenceType->value = $val;
}else{
throw new \Exception("Passed array has no key for 'Value' when contructing an ReferenceType");
}
if(isset($trimedDataArray['name']) || isset($trimedDataArray['Name']) ){
$nam = isset($trimedDataArray['name']) ? $trimedDataArray['name'] : $trimedDataArray['Name'];
$IPPReferenceType->name = $nam;
}
return $IPPReferenceType;
}else if(is_numeric($trimedDataArray) || is_string($trimedDataArray)){
$IPPReferenceType = new IPPReferenceType();
$IPPReferenceType->value = $trimedDataArray;
return $IPPReferenceType;
}else{
throw new \Exception("Can't convert Passed Parameter to IPPReferenceType.");
}
} | php | {
"resource": ""
} |
q255858 | FacadeHelper.getIPPId | test | public static function getIPPId($data){
//Convert an IPPId based on the Data
if(!isset($data)) throw new \Exception("Passed param for IPPid can't be null");
if(is_object($data)){
if($data instanceof IPPid){
return $data;
}else{
throw new \Exception("The assigned obj to IPPid is not matched with IPPid.");
}
}
if(is_array($data)){
$firstElementValue = reset($data);
}else if(is_numeric($data)){
$firstElementValue = $data;
}else{
throw new \Exception("Passed param for Ippid has either be an array or numeric value.");
}
$_id = new IPPid();
$_id->value = $firstElementValue;
return $_id;
} | php | {
"resource": ""
} |
q255859 | FacadeHelper.mergeObj | test | public static function mergeObj($objA, $objB){
if(get_class($objA) != get_class($objB)) throw new \Exception("Can't assign object value to a different type.");
$property_fields = get_object_vars($objA);
foreach ($property_fields as $propertyName => $val){
$BsValue = $objB->$propertyName;
if(isset($BsValue)){
$objA->$propertyName = $BsValue;
}
}
return $objA;
} | php | {
"resource": ""
} |
q255860 | CurlHttpClient.getHeaders | test | private function getHeaders($headers){
if(!isset($headers) || empty($headers)){
throw new SdkException("Error. The headers set for cURL are either NULL or Empty");
}else{
$convertedHeaders = $this->convertHeaderArrayToHeaders($headers);
return $convertedHeaders;
}
} | php | {
"resource": ""
} |
q255861 | CurlHttpClient.setSSL | test | private function setSSL(&$curl_opt, $verifySSL){
$tlsVersion = $this->basecURL->versionOfTLS();
$versions = ['TLS 1.2', 'TLS 1.3'];
if(! in_array($tlsVersion, $versions)){
throw new SdkException("Error. Checking TLS 1.2/1.3 version failed. Please make sure your PHP cURL supports TSL 1.2/1.3");
}
if($verifySSL){
$curl_opt[CURLOPT_SSL_VERIFYPEER] = true;
$curl_opt[CURLOPT_SSL_VERIFYHOST] = 2;
//based on spec, if TSL 1.2 is supported, it will use the TLS 1.2 or latest version by default
//$curl_opt[CURLOPT_SSLVERSION] = 6;
$curl_opt[CURLOPT_CAINFO] = CoreConstants::getCertPath(); //Pem certification Key Path
}
} | php | {
"resource": ""
} |
q255862 | CurlHttpClient.convertHeaderArrayToHeaders | test | public function convertHeaderArrayToHeaders(array $headerArray){
$headers = array();
foreach($headerArray as $k => $v){
$headers[] = $k . ":" . $v;
}
return $headers;
} | php | {
"resource": ""
} |
q255863 | File.addWarning | test | public function addWarning($warning, $stackPtr, $code, $data = [], $severity = 0, $fixable = false): bool
{
if (! $this->isSniffClassWarningAllowed($this->activeSniffClass)) {
return false;
}
return $this->addError($warning, $stackPtr, $code, $data, $severity, $fixable);
} | php | {
"resource": ""
} |
q255864 | Configuration.resolveFromInput | test | public function resolveFromInput(InputInterface $input): void
{
/** @var string[] $sources */
$sources = $input->getArgument(Option::SOURCE);
$this->setSources($sources);
$this->isFixer = (bool) $input->getOption(Option::FIX);
$this->shouldClearCache = (bool) $input->getOption(Option::CLEAR_CACHE);
$this->showProgressBar = $this->canShowProgressBar($input);
$this->showErrorTable = ! (bool) $input->getOption(Option::NO_ERROR_TABLE);
} | php | {
"resource": ""
} |
q255865 | Tag.setNameAttribute | test | public function setNameAttribute($value)
{
$value = trim($value);
$this->attributes['name'] = $value;
$this->attributes['normalized'] = app(TagService::class)->normalize($value);
} | php | {
"resource": ""
} |
q255866 | Tag.scopeByName | test | public function scopeByName(Builder $query, string $value): Builder
{
$normalized = app(TagService::class)->normalize($value);
return $query->where('normalized', $normalized);
} | php | {
"resource": ""
} |
q255867 | Taggable.bootTaggable | test | protected static function bootTaggable(): void
{
static::deleting(function ($model) {
if (!method_exists($model, 'runSoftDelete') || $model->isForceDeleting()) {
$model->detag();
}
});
} | php | {
"resource": ""
} |
q255868 | Taggable.tag | test | public function tag($tags): self
{
$tags = app(TagService::class)->buildTagArray($tags);
foreach ($tags as $tagName) {
$this->addOneTag($tagName);
$this->load('tags');
}
event(new ModelTagged($this, $tags));
return $this;
} | php | {
"resource": ""
} |
q255869 | Taggable.untag | test | public function untag($tags): self
{
$tags = app(TagService::class)->buildTagArray($tags);
foreach ($tags as $tagName) {
$this->removeOneTag($tagName);
}
event(new ModelUntagged($this, $tags));
return $this->load('tags');
} | php | {
"resource": ""
} |
q255870 | Taggable.addOneTag | test | protected function addOneTag(string $tagName): void
{
/** @var Tag $tag */
$tag = app(TagService::class)->findOrCreate($tagName);
$tagKey = $tag->getKey();
if (!$this->getAttribute('tags')->contains($tagKey)) {
$this->tags()->attach($tagKey);
}
} | php | {
"resource": ""
} |
q255871 | Taggable.removeOneTag | test | protected function removeOneTag(string $tagName): void
{
$tag = app(TagService::class)->find($tagName);
if ($tag) {
$this->tags()->detach($tag);
}
} | php | {
"resource": ""
} |
q255872 | Taggable.hasTag | test | public function hasTag($tag): bool
{
if ($tag instanceof Tag) {
$normalized = $tag->getAttribute('normalized');
} else {
$normalized = app(TagService::class)->normalize($tag);
}
return in_array($normalized, $this->getTagArrayNormalizedAttribute(), true);
} | php | {
"resource": ""
} |
q255873 | Taggable.scopeWithAllTags | test | public function scopeWithAllTags(Builder $query, $tags): Builder
{
/** @var TagService $service */
$service = app(TagService::class);
$normalized = $service->buildTagArrayNormalized($tags);
// If there are no tags specified, then there
// can't be any results so short-circuit
if (count($normalized) === 0) {
if (config('taggable.throwEmptyExceptions')) {
throw new NoTagsSpecifiedException('Empty tag data passed to withAllTags scope.');
}
return $query->where(\DB::raw(1), 0);
}
$tagKeys = $service->getTagModelKeys($normalized);
// If some of the tags specified don't exist, then there can't
// be any models with all the tags, so so short-circuit
if (count($tagKeys) !== count($normalized)) {
return $query->where(\DB::raw(1), 0);
}
$alias = $this->taggableCreateNewAlias(__FUNCTION__);
$morphTagKeyName = $this->getQualifiedRelatedPivotKeyNameWithAlias($alias);
return $this->prepareTableJoin($query, 'inner', $alias)
->whereIn($morphTagKeyName, $tagKeys)
->havingRaw("COUNT(DISTINCT {$morphTagKeyName}) = ?", [count($tagKeys)]);
} | php | {
"resource": ""
} |
q255874 | Taggable.scopeIsTagged | test | public function scopeIsTagged(Builder $query): Builder
{
$alias = $this->taggableCreateNewAlias(__FUNCTION__);
return $this->prepareTableJoin($query, 'inner', $alias);
} | php | {
"resource": ""
} |
q255875 | Taggable.scopeWithoutAllTags | test | public function scopeWithoutAllTags(Builder $query, $tags, bool $includeUntagged = false): Builder
{
/** @var TagService $service */
$service = app(TagService::class);
$normalized = $service->buildTagArrayNormalized($tags);
$tagKeys = $service->getTagModelKeys($normalized);
$tagKeyList = implode(',', $tagKeys);
$alias = $this->taggableCreateNewAlias(__FUNCTION__);
$morphTagKeyName = $this->getQualifiedRelatedPivotKeyNameWithAlias($alias);
$query = $this->prepareTableJoin($query, 'left', $alias)
->havingRaw("COUNT(DISTINCT CASE WHEN ({$morphTagKeyName} IN ({$tagKeyList})) THEN {$morphTagKeyName} ELSE NULL END) < ?",
[count($tagKeys)]);
if (!$includeUntagged) {
$query->havingRaw("COUNT(DISTINCT {$morphTagKeyName}) > 0");
}
return $query;
} | php | {
"resource": ""
} |
q255876 | Taggable.scopeIsNotTagged | test | public function scopeIsNotTagged(Builder $query): Builder
{
$alias = $this->taggableCreateNewAlias(__FUNCTION__);
$morphForeignKeyName = $this->getQualifiedForeignPivotKeyNameWithAlias($alias);
return $this->prepareTableJoin($query, 'left', $alias)
->havingRaw("COUNT(DISTINCT {$morphForeignKeyName}) = 0");
} | php | {
"resource": ""
} |
q255877 | Taggable.renameTag | test | public static function renameTag(string $oldTag, string $newTag): int
{
return app(TagService::class)->renameTags($oldTag, $newTag, static::class);
} | php | {
"resource": ""
} |
q255878 | Taggable.popularTags | test | public static function popularTags(int $limit = null, int $minCount = 1): array
{
/** @var Collection $tags */
$tags = app(TagService::class)->getPopularTags($limit, static::class, $minCount);
return $tags->pluck('taggable_count', 'name')->all();
} | php | {
"resource": ""
} |
q255879 | Taggable.getQualifiedRelatedPivotKeyNameWithAlias | test | private function getQualifiedRelatedPivotKeyNameWithAlias(string $alias): string
{
$morph = $this->tags();
return $morph->getTable() . '_' . $alias .
'.' . $morph->getRelatedPivotKeyName();
} | php | {
"resource": ""
} |
q255880 | Taggable.getQualifiedForeignPivotKeyNameWithAlias | test | private function getQualifiedForeignPivotKeyNameWithAlias(string $alias): string
{
$morph = $this->tags();
return $morph->getTable() . '_' . $alias .
'.' . $morph->getForeignPivotKeyName();
} | php | {
"resource": ""
} |
q255881 | Taggable.taggableCreateNewAlias | test | private function taggableCreateNewAlias(string $scope): string
{
$this->taggableAliasSequence++;
$alias = strtolower($scope) . '_' . $this->taggableAliasSequence;
return $alias;
} | php | {
"resource": ""
} |
q255882 | TagService.buildTagArray | test | public function buildTagArray($tags): array
{
if (is_array($tags)) {
$array = $tags;
} elseif ($tags instanceof BaseCollection) {
$array = $this->buildTagArray($tags->all());
} elseif (is_string($tags)) {
$array = preg_split(
'#[' . preg_quote(config('taggable.delimiters'), '#') . ']#',
$tags,
null,
PREG_SPLIT_NO_EMPTY
);
} else {
throw new \ErrorException(
__CLASS__ . '::' . __METHOD__ . ' expects parameter 1 to be string, array or Collection; ' .
gettype($tags) . ' given'
);
}
return array_filter(
array_map('trim', $array)
);
} | php | {
"resource": ""
} |
q255883 | TagService.getTagModelKeys | test | public function getTagModelKeys(array $normalized = []): array
{
if (count($normalized) === 0) {
return [];
}
return $this->tagModel::whereIn('normalized', $normalized)
->pluck('tag_id')
->toArray();
} | php | {
"resource": ""
} |
q255884 | TagService.makeTagList | test | public function makeTagList(Model $model, string $field = 'name'): string
{
$tags = $this->makeTagArray($model, $field);
return $this->joinList($tags);
} | php | {
"resource": ""
} |
q255885 | TagService.makeTagArray | test | public function makeTagArray(Model $model, string $field = 'name'): array
{
/** @var Collection $tags */
$tags = $model->tags;
return $tags->pluck($field)->all();
} | php | {
"resource": ""
} |
q255886 | TagService.getAllTags | test | public function getAllTags($class = null): Collection
{
if ($class === null) {
return $this->tagModel::all();
}
if ($class instanceof Model) {
$class = get_class($class);
}
$tagTable = $this->getQualifiedTagTableName();
$pivotTable = $this->getQualifiedPivotTableName($class);
$sql = "SELECT DISTINCT t.*
FROM {$pivotTable} tt
LEFT JOIN {$tagTable} t ON tt.tag_id=t.tag_id
WHERE tt.taggable_type = ?";
return $this->tagModel::fromQuery($sql, [$class]);
} | php | {
"resource": ""
} |
q255887 | TagService.getAllUnusedTags | test | public function getAllUnusedTags(): Collection
{
$tagTable = $this->getQualifiedTagTableName();
$pivotTable = $this->getQualifiedPivotTableName();
$sql = "SELECT t.*
FROM {$tagTable} t
LEFT JOIN {$pivotTable} tt ON tt.tag_id=t.tag_id
WHERE tt.taggable_id IS NULL";
return $this->tagModel::fromQuery($sql);
} | php | {
"resource": ""
} |
q255888 | TagService.renameTags | test | public function renameTags(string $oldName, string $newName, $class = null): int
{
// If no class is specified, we can do the rename with a simple SQL update
if ($class === null) {
return $this->tagModel::where('normalized', $this->normalize($oldName))
->update([
'name' => $newName,
'normalized' => $this->normalize($newName),
]);
}
if (!($class instanceof Model)) {
$class = new $class;
}
// First find the old tag
$oldTag = $this->find($oldName);
// If the old tag doesn't exist, we can short-circuit the process
if (!$oldTag) {
return 0;
}
// Find or create the new tag
$newTag = $this->findOrCreate($newName);
/** @var MorphToMany $morph */
$morph = $class->tags();
$pivot = $morph->newPivot();
$relatedKeyName = $pivot->getRelatedKey();
$relatedMorphType = $morph->getMorphType();
return $pivot
->where($relatedKeyName, $oldTag->getKey())
->where($relatedMorphType, get_class($class))
->update([
$relatedKeyName => $newTag->getKey(),
]);
} | php | {
"resource": ""
} |
q255889 | TagService.getQualifiedTagTableName | test | private function getQualifiedTagTableName(): string
{
/** @var Tag $tag */
$tag = new $this->tagModel;
return $tag->getConnection()->getTablePrefix() .
$tag->getTable();
} | php | {
"resource": ""
} |
q255890 | TagService.getQualifiedPivotTableName | test | private function getQualifiedPivotTableName(string $class=null): string
{
/** @var \Cviebrock\EloquentTaggable\Taggable $instance */
$instance = $class ? new $class : new class extends Model { use Taggable; };
return $instance->tags()->getConnection()->getTablePrefix() .
$instance->tags()->getTable();
} | php | {
"resource": ""
} |
q255891 | CompoundParameter.saveCompoundParameterData | test | protected function saveCompoundParameterData(array $compoundData)
{
foreach ($compoundData as $name => $value) {
$matchExists = false;
foreach ($this->parameterNameMapper as $regex => $parameterName) {
if (preg_match($regex, $name, $matches) === 1) {
$parameterLastIndex = '';
if (isset($matches[1])) {
$parameterLastIndex = $matches[1];
}
$matchExists = true;
$this->parameters[$parameterName . $parameterLastIndex] = $value;
break;
}
}
if (!$matchExists) {
throw new \InvalidArgumentException("Unknown parameter $name for " . get_class($this) . ' data');
}
}
} | php | {
"resource": ""
} |
q255892 | PrepareUrl.build | test | public function build($url, array $singleParameters, array $compoundParameters)
{
$singlesPost = $this->getSingleParametersPayload($singleParameters);
$compoundsPost = $this->getCompoundParametersPayload($compoundParameters);
$this->payloadParameters = array_merge($singlesPost, $compoundsPost);
if (!empty($this->cacheBuster)) {
$this->payloadParameters['z'] = $this->cacheBuster;
}
$query = http_build_query($this->payloadParameters, null, ini_get('arg_separator.output'), PHP_QUERY_RFC3986);
return $url . '?' . $query;
} | php | {
"resource": ""
} |
q255893 | PrepareUrl.getSingleParametersPayload | test | private function getSingleParametersPayload(array $singleParameters)
{
$postData = [];
$cacheBuster = new CacheBuster();
foreach ($singleParameters as $parameterObj) {
if ($parameterObj->getName() === $cacheBuster->getName()) {
$this->cacheBuster = $parameterObj->getValue();
continue;
}
$postData[$parameterObj->getName()] = $parameterObj->getValue();
}
return $postData;
} | php | {
"resource": ""
} |
q255894 | PrepareUrl.getCompoundParametersPayload | test | private function getCompoundParametersPayload(array $compoundParameters)
{
$postData = [];
foreach ($compoundParameters as $compoundCollection) {
$parameterArray = $compoundCollection->getParametersArray();
$postData = array_merge($postData, $parameterArray);
}
return $postData;
} | php | {
"resource": ""
} |
q255895 | Indexable.addIndex | test | protected function addIndex($string, $index)
{
if (empty($string)) {
throw new InvalidNameException('Name attribute not defined for class ' . get_class($this));
}
if (strpos($string, $this->indexPlaceholder) !== false) {
if (!is_numeric($index) || $index < $this->minIndex() || $index > $this->maxIndex()) {
throw new InvalidIndexException(
'When setting parameter ' . get_class($this)
. ' a numeric index between 1 - 200 must be passed for the second argument'
);
}
}
return str_replace($this->indexPlaceholder, $index, $string);
} | php | {
"resource": ""
} |
q255896 | AnalyticsResponse.getDebugResponse | test | public function getDebugResponse()
{
$debugResponse = [];
if (!empty($this->responseBody)) {
$debugResponse = json_decode($this->responseBody, true);
$debugResponse = (is_array($debugResponse)) ? $debugResponse : [];
}
return $debugResponse;
} | php | {
"resource": ""
} |
q255897 | Analytics.getEndpoint | test | protected function getEndpoint()
{
return ($this->isDebug) ? $this->uriScheme . $this->debugEndpoint : $this->uriScheme . $this->endpoint;
} | php | {
"resource": ""
} |
q255898 | Analytics.sendHit | test | protected function sendHit($methodName)
{
$hitType = strtoupper(substr($methodName, 4));
$hitConstant = $this->getParameterClassConstant(
'TheIconic\Tracking\GoogleAnalytics\Parameters\Hit\HitType::HIT_TYPE_' . $hitType,
'Hit type ' . $hitType . ' is not defined, check spelling'
);
$this->setHitType($hitConstant);
if (!$this->hasMinimumRequiredParameters()) {
throw new InvalidPayloadDataException();
}
if ($this->isDisabled) {
return new NullAnalyticsResponse();
}
return $this->getHttpClient()->post($this->getUrl(), $this->getHttpClientOptions());
} | php | {
"resource": ""
} |
q255899 | Analytics.getHttpClientOptions | test | protected function getHttpClientOptions()
{
$options = ['async' => $this->isAsyncRequest];
if (isset($this->options['timeout'])) {
$options['timeout'] = $this->options['timeout'];
}
return $options;
} | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.