_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3 values | text stringlengths 33 8k | language stringclasses 1 value | meta_information dict |
|---|---|---|---|---|---|
q600 | Grammar.getRulesFor | train | public function getRulesFor(Symbol $subject): array
{
$rules = [];
if (!$subject->isTerminal()) {
foreach ($this->rules as $rule) {
| php | {
"resource": ""
} |
q601 | Document.getAttachment | train | public function getAttachment($attachmentName)
{
if ($attachmentName == '')
throw new Exception('Attachment Name not specified');
//build URI
$strURI = Product::$baseProductUri . '/email/' . $this->getFileName() . '/attachments/' . $attachmentName;
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
| php | {
"resource": ""
} |
q602 | LineChart.addItem | train | public function addItem($item)
{
if (!is_numeric($item)) {
throw new \InvalidArgumentException(sprintf("Value '%s' must be a | php | {
"resource": ""
} |
q603 | LineChart.setColour | train | public function setColour($colour)
{
if (!preg_match('/^[a-f0-9]{6}$/i', $colour)) {
throw new \InvalidArgumentException(sprintf('Value %s must be a valid hex colour', | php | {
"resource": ""
} |
q604 | LineChart.getColour | train | public function getColour()
{
if (null === $this->colour) { | php | {
"resource": ""
} |
q605 | LineChart.setAxis | train | public function setAxis($dimension, $labels)
{
foreach ($labels as | php | {
"resource": ""
} |
q606 | LineChart.addLabel | train | protected function addLabel($dimension, $label)
{
if (!in_array($dimension, array(self::DIMENSION_X, self::DIMENSION_Y))) {
throw new \InvalidArgumentException(sprintf("Value '%s' is | php | {
"resource": ""
} |
q607 | LineChart.getAxis | train | public function getAxis()
{
if (null === $this->axis) {
$this->axis[self::DIMENSION_X] = array();
| php | {
"resource": ""
} |
q608 | DocumentBuilder.removeWatermark | train | public function removeWatermark($fileName)
{
//check whether files are set or not
if ($fileName == '')
throw new Exception('File not specified');
//build URI to insert watermark image
$strURI = Product::$baseProductUri . '/words/' . $fileName .
'/watermark';
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'DELETE', '', '');
$v_output = Utils::validateOutput($responseStream);
if ($v_output === '') {
//Save doc on server
$folder = | php | {
"resource": ""
} |
q609 | DocumentBuilder.insertWatermarkText | train | public function insertWatermarkText($fileName, $text, $rotationAngle)
{
//check whether files are set or not
if ($fileName == '')
throw new Exception('File not specified');
//Build JSON to post
$fieldsArray = array('Text' => $text, 'RotationAngle' => $rotationAngle);
$json = json_encode($fieldsArray);
//build URI to insert watermark text
$strURI = Product::$baseProductUri . '/words/' . $fileName . '/watermark/insertText';
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'POST', 'json', $json);
$v_output = Utils::validateOutput($responseStream);
if ($v_output === '') {
| php | {
"resource": ""
} |
q610 | DocumentBuilder.replaceText | train | public function replaceText($fileName, $oldValue, $newValue, $isMatchCase, $isMatchWholeWord)
{
//check whether files are set or not
if ($fileName == '')
throw new Exception('File not specified');
//Build JSON to post
$fieldsArray = array('OldValue' => $oldValue, 'NewValue' => $newValue,
'IsMatchCase' => $isMatchCase, 'IsMatchWholeWord' => $isMatchWholeWord);
$json = json_encode($fieldsArray);
//build URI to replace text
$strURI = Product::$baseProductUri . '/words/' . $fileName . '/replaceText';
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'POST', 'json', $json);
| php | {
"resource": ""
} |
q611 | DestroyAttributeValue.handle | train | public function handle(AttributeValueRepository $attributeValueRepository, Dispatcher $event)
{
$attributeValue = $attributeValueRepository->find($this->id);
$attributeValueRepository->destroy($attributeValue);
| php | {
"resource": ""
} |
q612 | Validator.cleanUp | train | static function cleanUp( $string ) {
if ( NORMALIZE_INTL ) {
$string = self::replaceForNativeNormalize( $string );
$norm = normalizer_normalize( $string, Normalizer::FORM_C );
if ( $norm === null || $norm === false ) {
# normalizer_normalize will either return false or null
# (depending on which doc you read) if invalid utf8 string.
| php | {
"resource": ""
} |
q613 | Validator.toNFC | train | static function toNFC( $string ) {
if ( NORMALIZE_INTL ) {
return normalizer_normalize( $string, Normalizer::FORM_C );
} elseif ( self::quickIsNFC( $string | php | {
"resource": ""
} |
q614 | Validator.toNFD | train | static function toNFD( $string ) {
if ( NORMALIZE_INTL ) {
return normalizer_normalize( $string, Normalizer::FORM_D );
} elseif ( preg_match( '/[\x80-\xff]/', | php | {
"resource": ""
} |
q615 | Validator.toNFKC | train | static function toNFKC( $string ) {
if ( NORMALIZE_INTL ) {
return normalizer_normalize( $string, Normalizer::FORM_KC );
} elseif ( preg_match( '/[\x80-\xff]/', | php | {
"resource": ""
} |
q616 | Validator.toNFKD | train | static function toNFKD( $string ) {
if ( NORMALIZE_INTL ) {
return normalizer_normalize( $string, Normalizer::FORM_KD );
} elseif ( preg_match( '/[\x80-\xff]/', | php | {
"resource": ""
} |
q617 | Validator.fastCombiningSort | train | static function fastCombiningSort( $string ) {
self::loadData();
$len = strlen( $string );
$out = '';
$combiners = [];
$lastClass = -1;
for ( $i = 0; $i < $len; $i++ ) {
$c = $string[$i];
$n = ord( $c );
if ( $n >= 0x80 ) {
if ( $n >= 0xf0 ) {
$c = substr( $string, $i, 4 );
$i += 3;
} elseif ( $n >= 0xe0 ) {
$c = substr( $string, $i, 3 );
$i += 2;
} elseif ( $n >= 0xc0 ) {
$c = substr( $string, $i, 2 );
$i++;
}
if ( isset( self::$utfCombiningClass[$c] ) ) {
$lastClass = self::$utfCombiningClass[$c];
if ( isset( $combiners[$lastClass] ) ) {
$combiners[$lastClass] .= $c; | php | {
"resource": ""
} |
q618 | Validator.placebo | train | static function placebo( $string ) {
$len = strlen( $string );
| php | {
"resource": ""
} |
q619 | Validator.replaceForNativeNormalize | train | private static function replaceForNativeNormalize( $string ) {
$string = preg_replace(
'/[\x00-\x08\x0b\x0c\x0e-\x1f]/',
Constants::UTF8_REPLACEMENT,
$string );
$string = | php | {
"resource": ""
} |
q620 | Redirects.seeRedirectBetween | train | public function seeRedirectBetween($oldUrl, $newUrl, $statusCode)
{
// We must not follow all redirects, so save current situation,
// force disable follow redirects, and revert at the end.
$followsRedirects = $this->isFollowingRedirects();
$this->followRedirects(false);
$response = $this->sendHeadAndGetResponse($oldUrl);
if (null !== $response) {
$responseCode = $response->getStatus();
$locationHeader = $response->getHeader('Location', true);
// Check for correct response code.
| php | {
"resource": ""
} |
q621 | Redirects.urlDoesNotRedirect | train | public function urlDoesNotRedirect($url)
{
if ('/' === $url) {
$url = '';
}
// We must not follow all redirects, so save current situation,
// force disable follow redirects, and revert at the end.
$followsRedirects = $this->isFollowingRedirects();
$this->followRedirects(false);
$response = $this->sendHeadAndGetResponse($url);
if (null !== $response) {
$responseCode = $response->getStatus();
$locationHeader = $response->getHeader('Location', true);
// Check for 200 response code.
| php | {
"resource": ""
} |
q622 | Redirects.sendHeadAndGetResponse | train | protected function sendHeadAndGetResponse($url)
{
/** @var REST $rest */
| php | {
"resource": ""
} |
q623 | FormFieldExtension.setCalendarConfig | train | public function setCalendarConfig($arg1, $arg2 = null)
{
if (is_array($arg1)) {
$this->calendarConfig = $arg1;
} else { | php | {
"resource": ""
} |
q624 | FormFieldExtension.getCalendarConfig | train | public function getCalendarConfig($name = null)
{
if (!is_null($name)) {
| php | {
"resource": ""
} |
q625 | FormFieldExtension.updateAttributes | train | public function updateAttributes(&$attributes)
{
$attributes['data-calendar-config'] = $this->owner->getCalendarConfigJSON();
| php | {
"resource": ""
} |
q626 | FormFieldExtension.getCalendarEnabled | train | public function getCalendarEnabled()
{
if ($this->owner->isReadonly() || $this->owner->isDisabled()) {
return 'false';
}
| php | {
"resource": ""
} |
q627 | Extractor.getImageCount | train | public function getImageCount($pageNumber)
{
$strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/pages/' . $pageNumber . '/images';
$signedURI = Utils::sign($strURI);
| php | {
"resource": ""
} |
q628 | Item.compare | train | public static function compare(Item $a, Item $b): int
{
return Symbol::compare($a->subject, $b->subject)
| php | {
"resource": ""
} |
q629 | Item.createFromRule | train | public static function createFromRule(Rule $rule): self
{
return new static(
$rule->getSubject(),
[],
| php | {
"resource": ""
} |
q630 | Item.shift | train | public function shift(): ?self
{
$further = $this->further;
if (!$further) {
return null;
| php | {
"resource": ""
} |
q631 | Item.getAsRule | train | public function getAsRule(): Rule
{
return new Rule(
$this->subject,
| php | {
"resource": ""
} |
q632 | WeChatAudioDriver.getAudio | train | private function getAudio()
{
$audioUrl = 'http://file.api.wechat.com/cgi-bin/media/get? | php | {
"resource": ""
} |
q633 | File.getFile | train | public function getFile($fileName, $storageName = '')
{
//check whether file is set or not
if ($fileName == '') {
AsposeApp::getLogger()->error(Exception::MSG_NO_FILENAME);
throw new Exception(Exception::MSG_NO_FILENAME);
}
//build URI
$strURI = $this->strURIFile . $fileName;
if ($storageName != '') {
$strURI .= '?storage=' . $storageName;
}
//sign URI
$signedURI = Utils::sign($strURI);
| php | {
"resource": ""
} |
q634 | File.copyFile | train | public function copyFile($fileName, $storageName = '', $newDest)
{
//check whether file is set or not
if ($fileName == '' || $newDest == '') {
AsposeApp::getLogger()->error(Exception::MSG_NO_FILENAME);
throw new Exception(Exception::MSG_NO_FILENAME);
}
//build URI
$strURI = $this->strURIFile . $fileName . '?newdest=' . $newDest;
if ($storageName != '') {
$strURI .= '&storage=' . $storageName;
}
//sign URI
| php | {
"resource": ""
} |
q635 | TextEditor.findText | train | public function findText()
{
$parameters = func_get_args();
//set parameter values
if (count($parameters) == 1) {
$text = $parameters[0];
} else if (count($parameters) == 2) {
$WorkSheetName = $parameters[0];
$text = $parameters[1];
} else {
throw new Exception('Invalid number of arguments');
}
| php | {
"resource": ""
} |
q636 | TextEditor.getTextItems | train | public function getTextItems()
{
$parameters = func_get_args();
//set parameter values
if (count($parameters) > 0) {
$worksheetName = $parameters[0];
}
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . ((isset($parameters[0])) ? '/worksheets/' . $worksheetName . '/textItems' : '/textItems');
| php | {
"resource": ""
} |
q637 | Product.getMaximumInstallmentQuantity | train | public function getMaximumInstallmentQuantity()
{
$product = $this->getProduct() ? $this->getProduct() : $this->getParentBlock()->getProduct();
$maximumInstallment | php | {
"resource": ""
} |
q638 | Parser.parse | train | public function parse(string $input, $actions = []): TreeNodeInterface
{
if ($actions instanceof ActionsMap) {
$actions_map = $actions;
} elseif ($actions) {
$actions_map = new ActionsMap($actions);
} else {
$actions_map = null;
}
$stack = new Stack($this->table, $actions_map);
$pos = 0;
$token = null;
try {
while (true) {
while ($stack->getStateRow()->isReduceOnly()) {
$stack->reduce();
}
$expected_terms = array_keys($stack->getStateRow()->terminalActions);
$match = $this->grammar->parseOne($input, $pos, $expected_terms);
if ($match) {
/** @var Token $token */
$token = $match->token;
$pos = $match->nextOffset;
$symbol_name = $token->getType();
} else {
$token = null;
$symbol_name = null;
}
while (true) {
if ($token) {
$terminal_actions = $stack->getStateRow()->terminalActions;
if (isset($terminal_actions[$symbol_name])) {
$stack->shift($token, $terminal_actions[$symbol_name]);
goto NEXT_SYMBOL;
}
}
if ($stack->getStateRow()->eofAction) {
if ($token) {
throw new UnexpectedInputAfterEndException(
$this->dumpTokenForError($token),
$token->getOffset()
| php | {
"resource": ""
} |
q639 | ChartEditor.addChart | train | public function addChart($chartType, $upperLeftRow, $upperLeftColumn, $lowerRightRow, $lowerRightColumn)
{
//check whether workshett name is set or not
if ($this->worksheetName == '')
throw new Exception('Worksheet name not specified');
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '/worksheets/' . $this->worksheetName . '/charts?chartType=' . $chartType . '&upperLeftRow=' . $upperLeftRow . '&upperLeftColumn=' . $upperLeftColumn | php | {
"resource": ""
} |
q640 | ChartEditor.deleteCharts | train | public function deleteCharts()
{
//check whether workshett name is set or not
if ($this->worksheetName == '')
throw new Exception('Worksheet name not specified');
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '/worksheets/' . $this->worksheetName . '/charts/';
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'DELETE', '', '');
$v_output = Utils::validateOutput($responseStream);
if ($v_output === '') {
//Save doc on server
$folder = new Folder();
| php | {
"resource": ""
} |
q641 | ChartEditor.readChartLegend | train | public function readChartLegend($chartIndex)
{
//check whether workshett name is set or not
if ($this->worksheetName == '')
throw new Exception('Worksheet name not specified');
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '/worksheets/' . $this->worksheetName . '/charts/' . $chartIndex . '/legend';
| php | {
"resource": ""
} |
q642 | ChartEditor.getChartArea | train | public function getChartArea($chartIndex)
{
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '/worksheets/' . $this->worksheetName . '/charts/' . $chartIndex . '/chartArea';
$signedURI = Utils::sign($strURI);
| php | {
"resource": ""
} |
q643 | ChartEditor.getFillFormat | train | public function getFillFormat($chartIndex)
{
//check whether workshett name is set or not
if ($this->worksheetName == '')
throw new Exception('Worksheet name not specified');
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '/worksheets/' . $this->worksheetName . '/charts/' . $chartIndex . '/chartArea/fillFormat';
| php | {
"resource": ""
} |
q644 | ChartEditor.getBorder | train | public function getBorder($chartIndex)
{
//check whether workshett name is set or not
if ($this->worksheetName == '')
throw new Exception('Worksheet name not specified');
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '/worksheets/' . $this->worksheetName . '/charts/' . $chartIndex . '/chartArea/border';
| php | {
"resource": ""
} |
q645 | ChartEditor.setChartTitle | train | public function setChartTitle($chartIndex, $strXML)
{
//check whether workshett name is set or not
if ($this->worksheetName == '')
throw new Exception('Worksheet name not specified');
if (!isset($chartIndex))
throw new Exception('Chart Index not specified');
if ($strXML == '')
| php | {
"resource": ""
} |
q646 | ChartEditor.deleteChartTitle | train | public function deleteChartTitle($chartIndex)
{
//check whether workshett name is set or not
if ($this->worksheetName == '')
throw new Exception('Worksheet name not specified');
if (!isset($chartIndex))
throw new Exception('Chart Index not specified');
| php | {
"resource": ""
} |
q647 | ConnectionPool.close | train | public function close()
{
$this->closed = true;
foreach ($this->connections as $connection) {
$connection->close();
}
$this->idle = new \SplQueue;
if ($this->deferred instanceof Deferred) {
$deferred = $this->deferred;
| php | {
"resource": ""
} |
q648 | ConnectionPool.prepareStatement | train | private function prepareStatement(string $sql): \Generator
{
$connection = yield from $this->pop();
\assert($connection instanceof Link);
try {
$statement = yield $connection->prepare($sql);
\assert($statement instanceof Statement);
} catch (\Throwable $exception) {
| php | {
"resource": ""
} |
q649 | Table.prepareStates | train | protected function prepareStates(Grammar $grammar): void
{
/** @var TableRow[] $rows */
$rows = [];
/** @var ItemSet[] $states */
$states = [];
$item = Item::createFromRule($grammar->getMainRule());
$item_set = ItemSet::createFromItems([$item], $grammar);
/** @var ItemSet[][] $add_states_map */
$add_states_map = [0 => ['' => $item_set]];
while ($add_states_map) {
$next_states_map = [];
foreach ($add_states_map as $from_state_index => $to_states_list) {
foreach ($to_states_list as $from_symbol_name => $new_state) {
$from_symbol_term = false;
$from_symbol_non_term = false;
if ('' !== $from_symbol_name) {
$from_symbol = $grammar->getSymbol($from_symbol_name);
if ($from_symbol->isTerminal()) {
$from_symbol_term = true;
} else {
$from_symbol_non_term = true;
}
}
foreach ($states as $i => $state) {
if ($new_state->isSame($state)) {
$row = $rows[$from_state_index];
if ($from_symbol_term) {
$row->terminalActions[$from_symbol_name] = $i;
} elseif ($from_symbol_non_term) {
$row->gotoSwitches[$from_symbol_name] = $i;
}
goto NEXT_NEW_STATE;
| php | {
"resource": ""
} |
q650 | DestroyProductType.handle | train | public function handle(ProductTypeRepository $productTypeRepository, Dispatcher $event)
{
$productType = $productTypeRepository->find($this->id);
// TODO : Check if the product type is | php | {
"resource": ""
} |
q651 | UserHasAccount.checkFlag | train | public function checkFlag(array $context): bool
{
if (!isset($context['user'])) {
throw new \InvalidArgumentException(sprintf('The context parameter must contain | php | {
"resource": ""
} |
q652 | RouteServiceProvider.loadCachedRoutes | train | protected function loadCachedRoutes()
{
$this->app['events']->fire('routes.loading');
| php | {
"resource": ""
} |
q653 | CasAuthenticator.start | train | public function start(Request $request, AuthenticationException $authException = null)
{
//The URL have to be completed by the current request uri,
// because Cas Server need | php | {
"resource": ""
} |
q654 | CasAuthenticator.onLogoutSuccess | train | public function onLogoutSuccess(Request $request)
{
phpCAS::setDebug($this->cas->getDebug());
phpCAS::setVerbose($this->cas->isVerbose());
if (!phpCAS::isInitialized()) {
phpCAS::client(
$this->cas->getVersion(),
$this->cas->getHostname(),
$this->cas->getPort(),
$this->cas->getUrl()
);
}
phpCAS::setLang($this->cas->getLanguage());
if ($this->cas->isRedirectingAfterLogout()) {
$uri | php | {
"resource": ""
} |
q655 | Converter.convert | train | public function convert($folder = null)
{
//build URI
$strURI = Product::$baseProductUri . '/words/' . $this->getFileName() . '?format=' . $this->saveFormat;
if ($folder) {
$strURI = $strURI . "&folder=" . urlencode($folder);
}
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$v_output = Utils::validateOutput($responseStream);
if ($v_output === '') {
if ($this->saveFormat == 'html') {
$save_format = 'zip';
| php | {
"resource": ""
} |
q656 | Converter.convertLocalFile | train | public function convertLocalFile($inputPath, $outputPath, $outputFormat)
{
$str_uri = Product::$baseProductUri . '/words/convert?format=' . $outputFormat;
$signed_uri = Utils::sign($str_uri);
$responseStream = Utils::uploadFileBinary($signed_uri, $inputPath, 'xml');
$v_output = Utils::validateOutput($responseStream);
| php | {
"resource": ""
} |
q657 | Converter.convertWebPages | train | public function convertWebPages($strXML)
{
if ($strXML == '')
throw new Exception('XML not specified');
//build URI
$strURI = Product::$baseProductUri . '/words/loadWebDocument';
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'POST', 'XML', $strXML);
$xml = simplexml_load_string($responseStream);
if ($xml->Status == 'OK') {
$fileName = $xml->SaveResult->Dest['href'];
$strURI = Product::$baseProductUri . '/storage/file/' . $fileName; | php | {
"resource": ""
} |
q658 | UpdateProduct.handle | train | public function handle(ProductRepository $productRepository, Dispatcher $event)
{
$product = $productRepository->find($this->id)->fill(array_except(get_object_vars($this), ['attributes']));
| php | {
"resource": ""
} |
q659 | Logger.log | train | public function log($level, $message, array $context = array())
{
if | php | {
"resource": ""
} |
q660 | Logger.formatFileLine | train | private function formatFileLine($string)
{
$format = $this->getOption('dateFormat') | php | {
"resource": ""
} |
q661 | Logger.dispatch | train | private function dispatch($message, $context)
{
$output = $this->interpolate($message, $context) . PHP_EOL;
if ($this->getOption('outputToFile') === true) {
$file = $this->getOption('logFile');
if (!is_writable($file)) {
throw new AsposeCloudException('The file | php | {
"resource": ""
} |
q662 | MessageDefaults.allKeys | train | public static function allKeys()
{
static $allKeys = null;
if (is_null($allKeys)) { | php | {
"resource": ""
} |
q663 | WebHookHandler.setLogger | train | public function setLogger($logger) {
if(!in_array('Psr\Log\LoggerInterface', class_implements($logger, true))) {
throw new \InvalidArgumentException('Logger object | php | {
"resource": ""
} |
q664 | WebHookHandler.setInput | train | public function setInput($input, $isDecoded = false) {
if(!$isDecoded)
$input = json_decode($input, true);
if(!$input) {
if($this->logger) $this->logger->error('Could not decode input', array('input' => $input));
throw new WebHookHandlerException('Could not decode input', WebHookHandlerException::INPUT_DECODE_FAILED);
}
if(empty($input['payload'])) {
if($this->logger)
$this->logger->error('No payload in input data');
throw new WebHookHandlerException('No payload in input data', WebHookHandlerException::NO_PAYLOAD);
}
if(empty($input['payloadEncrypted']))
$input['payloadEncrypted'] = false;
if($input['payloadEncrypted']) {
if(empty($this->privateKey)) {
if($this->logger)
$this->logger->error('No private | php | {
"resource": ""
} |
q665 | WebHookHandler.getInputFromHTTP | train | private function getInputFromHTTP() {
if($this->logger) $this->logger->debug('Getting and decoding HTTP request body');
$input = | php | {
"resource": ""
} |
q666 | WebHookHandler.ensureInput | train | private function ensureInput() {
if(!$this->input) {
$this->getInputFromHTTP();
if(!$this->input) throw new | php | {
"resource": ""
} |
q667 | WebHookHandler.getTimestamp | train | public function getTimestamp($format = self::TIMESTAMP_FORMAT_RFC1123) {
$this->ensureInput();
if(!isset($this->input['timestamp'])) return null; | php | {
"resource": ""
} |
q668 | WebHookHandler.getPayload | train | public function getPayload() {
if($this->payload) return $this->payload;
$this->ensureInput();
if(empty($this->input['payload'])) {
if($this->logger)
$this->logger->error('No payload in input data');
throw new WebHookHandlerException('No payload in input data', WebHookHandlerException::NO_PAYLOAD);
}
if($this->input['payloadEncrypted']) {
$privKey = openssl_pkey_get_private($this->privateKey, $this->passphrase);
$envKey = base64_decode($this->input['envKey']);
$encryptedPayload = base64_decode($this->input['payload']);
$payloadJSON = '';
if(openssl_open($encryptedPayload, $payloadJSON, $envKey, $privKey)) {
if($this->logger)
$this->logger->debug('Decrypted JSON string', array('json' => $payloadJSON));
$decrypted = json_decode($payloadJSON, true);
if($decrypted) {
$this->payload = $decrypted;
$this->payloadJSONString = $payloadJSON;
} else {
if($this->logger)
$this->logger->error('Invalid decrypted json');
| php | {
"resource": ""
} |
q669 | WebHookHandler.verifyHash | train | public function verifyHash() {
$this->ensureInput();
if(empty($this->input['hash']))
throw new WebHookHandlerException('No hash provided in input payload', WebHookHandlerException::NO_INPUT_HASH);
if($this->input['payloadEncrypted']) {
if(!$this->payloadJSONString && !$this->getPayload()) return false;
} else {
if(!$this->payloadJSONString) $this->payloadJSONString = json_encode($this->input['payload']);
| php | {
"resource": ""
} |
q670 | WebHookHandler.sendExceptionResponse | train | public function sendExceptionResponse(WebHookHandlerException $e) {
$httpCode = '400 Bad Request';
switch($e->getCode()) {
case WebHookHandlerException::NO_PRIVATE_KEY:
$httpCode = '500 Internal Server Error';
break;
case WebHookHandlerException::INVALID_DECRYPTED_JSON:
case WebHookHandlerException::DECRYPTION_FAILED:
case WebHookHandlerException::INPUT_FETCH_FAILED:
case WebHookHandlerException::INPUT_DECODE_FAILED:
case WebHookHandlerException::NO_ENVELOPE_KEY:
| php | {
"resource": ""
} |
q671 | QuoteToOrder.execute | train | public function execute(Observer $observer)
{
$quote = $observer->getQuote();
$order = $observer->getOrder();
$order
->setGabrielqsInstallmentsQty($quote->getGabrielqsInstallmentsQty())
->setGabrielqsInstallmentsInterestRate($quote->getGabrielqsInstallmentsInterestRate())
| php | {
"resource": ""
} |
q672 | ItemSet.createFromItems | train | public static function createFromItems(array $items, Grammar $grammar): self
{
$final_items = [];
$new_items = $items;
/** @var Symbol $known_next_symbols */
$known_next_symbols = [];
while ($new_items) {
/** @var Symbol $next_symbols */
$next_symbols = [];
foreach ($new_items as $new_item) {
foreach ($final_items as $item) {
if (0 === Item::compare($item, $new_item)) {
goto NEXT_NEW_ITEM;
}
}
$final_items[] = $new_item;
$next_symbol = $new_item->getExpected();
if (!$next_symbol || $next_symbol->isTerminal()) {
continue;
}
$name = $next_symbol->getName();
if (isset($known_next_symbols[$name])) {
| php | {
"resource": ""
} |
q673 | ItemSet.getNextSets | train | public function getNextSets(Grammar $grammar): array
{
$next_map = [];
foreach ($this->items as $item) {
$symbol = $item->getExpected();
if (!$symbol) {
continue;
}
$name = $symbol->getName();
$next_item = $item->shift();
if (isset($next_map[$name])) {
| php | {
"resource": ""
} |
q674 | ItemSet.hasItem | train | public function hasItem(Item $item, bool $initialOnly = true): bool
{
$list = ($initialOnly) ? $this->initialItems : $this->items;
foreach ($list as $my_item) {
| php | {
"resource": ""
} |
q675 | ItemSet.hasFinalItem | train | public function hasFinalItem(): bool
{
foreach ($this->items as $item) {
if ($item->hasEofMark() && !$item->hasFurther()) {
| php | {
"resource": ""
} |
q676 | ItemSet.getReduceRule | train | public function getReduceRule(): ?Rule
{
foreach ($this->items as $item) {
if (!$item->hasFurther()) {
| php | {
"resource": ""
} |
q677 | ItemSet.isSame | train | public function isSame(ItemSet $that): bool
{
if (count($this->items) !== count($that->items)) {
return false;
}
foreach ($this->items as $i => $item) {
| php | {
"resource": ""
} |
q678 | ItemSet.validateDeterministic | train | private function validateDeterministic(Grammar $grammar): void
{
/** @var Item[] */
$finite = [];
$terminals = [];
$non_terminals = [];
foreach ($this->items as $item) {
$next_symbol = $item->getExpected();
if (!$next_symbol) {
$finite[] = $item;
} elseif ($next_symbol->isTerminal()) {
$terminals[] = $item;
} else {
| php | {
"resource": ""
} |
q679 | ItemSet.validateDeterministicShiftReduce | train | private function validateDeterministicShiftReduce(
array $finite,
array $terminals,
array $nonTerminals,
Grammar $grammar
): void {
if ($finite && $terminals) {
$left_terminals = $grammar->getTerminals();
foreach ($terminals as $item) {
unset($left_terminals[$item->getExpected()->getName()]);
| php | {
"resource": ""
} |
q680 | Worksheet.getCellsList | train | public function getCellsList($offset, $count)
{
//check whether workshett name is set or not
if ($this->worksheetName == '')
throw new Exception('Worksheet name not specified');
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() .
'/worksheets/' . $this->worksheetName . '/cells?offset=' .
$offset . '&count=' . $count;
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
$listCells = array();
foreach ($json->Cells->CellList as $cell) {
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() .
| php | {
"resource": ""
} |
q681 | Worksheet.getRowsList | train | public function getRowsList()
{
//check whether workshett name is set or not
if ($this->worksheetName == '')
throw new Exception('Worksheet name not specified');
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() .
'/worksheets/' . $this->worksheetName . '/cells/rows';
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
$listRows = array();
foreach ($json->Rows->RowsList as $row) {
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() .
| php | {
"resource": ""
} |
q682 | Worksheet.getColumnsList | train | public function getColumnsList()
{
//check whether workshett name is set or not
if ($this->worksheetName == '')
throw new Exception('Worksheet name not specified');
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() .
'/worksheets/' . $this->worksheetName . '/cells/columns';
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
$listColumns = array();
foreach ($json->Columns->ColumnsList as $column) {
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() .
| php | {
"resource": ""
} |
q683 | Worksheet.getMaxColumn | train | public function getMaxColumn($offset, $count)
{
//check whether workshett name is set or not
if ($this->worksheetName == '')
throw new Exception('Worksheet name not specified');
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() .
'/worksheets/' . $this->worksheetName . '/cells?offset=' .
$offset | php | {
"resource": ""
} |
q684 | Worksheet.getAutoShapesCount | train | public function getAutoShapesCount()
{
//check whether workshett name is set or not
if ($this->worksheetName == '')
throw new Exception('Worksheet name not specified');
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() .
'/worksheets/' . $this->worksheetName . '/autoshapes';
$signedURI = Utils::sign($strURI);
| php | {
"resource": ""
} |
q685 | Worksheet.getAutoShapeByIndex | train | public function getAutoShapeByIndex($index)
{
//check whether workshett name is set or not
if ($this->worksheetName == '')
throw new Exception('Worksheet name not specified');
$strURI = Product::$baseProductUri . '/cells/' | php | {
"resource": ""
} |
q686 | Worksheet.getChartsCount | train | public function getChartsCount()
{
//check whether workshett name is set or not
if ($this->worksheetName == '')
throw new Exception('Worksheet name not specified');
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() .
'/worksheets/' . $this->worksheetName . '/charts';
$signedURI = Utils::sign($strURI);
| php | {
"resource": ""
} |
q687 | Worksheet.getChartByIndex | train | public function getChartByIndex($index)
{
//check whether workshett name is set or not
if ($this->worksheetName == '')
throw new Exception('Worksheet name not specified');
$strURI = Product::$baseProductUri . '/cells/' | php | {
"resource": ""
} |
q688 | Worksheet.getHyperlinksCount | train | public function getHyperlinksCount()
{
//check whether workshett name is set or not
if ($this->worksheetName == '')
throw new Exception('Worksheet name not specified');
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() .
'/worksheets/' . $this->worksheetName . '/hyperlinks';
$signedURI = Utils::sign($strURI);
| php | {
"resource": ""
} |
q689 | Worksheet.getHyperlinkByIndex | train | public function getHyperlinkByIndex($index)
{
//check whether workshett name is set or not
if ($this->worksheetName == '')
throw new Exception('Worksheet name not specified');
$strURI = Product::$baseProductUri . '/cells/' | php | {
"resource": ""
} |
q690 | Worksheet.deleteHyperlinkByIndex | train | public function deleteHyperlinkByIndex($index)
{
//check whether workshett name is set or not
if ($this->worksheetName == '')
throw new Exception('Worksheet name not specified');
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() .
'/worksheets/' . $this->worksheetName . '/hyperlinks/' . $index;
$signedURI = Utils::sign($strURI);
| php | {
"resource": ""
} |
q691 | Worksheet.addHyperlink | train | public function addHyperlink($firstRow, $firstColumn, $totalRows, $totalColumns, $url)
{
//check whether worksheet name is set or not
if ($this->worksheetName == '')
throw new Exception('Worksheet name not specified');
if ($firstRow == '')
throw new Exception('First Row not specified');
if ($firstColumn == '')
throw new Exception('First Column not specified');
if ($totalRows == '')
throw new Exception('Total Rows not specified');
if ($totalColumns == '')
throw new Exception('Total Columns not specified');
if ($url == '')
throw new Exception('URL not specified');
| php | {
"resource": ""
} |
q692 | Worksheet.updateHyperlink | train | public function updateHyperlink($hyperlinkIndex, $url, $screenTip, $displayText)
{
//check whether worksheet name is set or not
if ($this->worksheetName == '')
throw new Exception('Worksheet name not specified');
if ($hyperlinkIndex == '')
throw new Exception('Hyperlink Index not specified');
if ($url == '')
throw new Exception('URL not specified');
if ($screenTip == '')
throw new Exception('Screen Tip not specified');
if ($displayText == '')
throw new Exception('Display Text not specified');
$data = array('address' => $url, 'ScreenTip' => $screenTip, 'TextToDisplay' => $displayText);
$json_data = json_encode($data);
| php | {
"resource": ""
} |
q693 | Worksheet.getComment | train | public function getComment($cellName)
{
//check whether workshett name is set or not
if ($this->worksheetName == '')
throw new Exception('Worksheet name not specified');
$strURI = Product::$baseProductUri . '/cells/' | php | {
"resource": ""
} |
q694 | Worksheet.getOleObjectByIndex | train | public function getOleObjectByIndex($index)
{
//check whether workshett name is set or not
if ($this->worksheetName == '')
throw new Exception('Worksheet name not specified');
$strURI = Product::$baseProductUri . '/cells/' | php | {
"resource": ""
} |
q695 | Worksheet.getPictureByIndex | train | public function getPictureByIndex($index)
{
//check whether worksheet name is set or not
if ($this->worksheetName == '')
throw new Exception('Worksheet name not specified');
$strURI = Product::$baseProductUri . '/cells/' | php | {
"resource": ""
} |
q696 | Worksheet.getValidationByIndex | train | public function getValidationByIndex($index)
{
//check whether worksheet name is set or not
if ($this->worksheetName == '')
throw new Exception('Worksheet name not specified');
$strURI = Product::$baseProductUri . '/cells/' | php | {
"resource": ""
} |
q697 | Worksheet.getMergedCellByIndex | train | public function getMergedCellByIndex($index)
{
//check whether workshett name is set or not
if ($this->worksheetName == '')
throw new Exception('Worksheet name not specified');
$strURI = Product::$baseProductUri . '/cells/' | php | {
"resource": ""
} |
q698 | Worksheet.getMergedCellsCount | train | public function getMergedCellsCount()
{
//check whether workshett name is set or not
if ($this->worksheetName == '')
throw new Exception('Worksheet name not specified');
$strURI = Product::$baseProductUri . '/cells/' | php | {
"resource": ""
} |
q699 | Worksheet.getValidationsCount | train | public function getValidationsCount()
{
//check whether workshett name is set or not
if ($this->worksheetName == '')
throw new Exception('Worksheet name not specified');
$strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() .
'/worksheets/' . $this->worksheetName . '/validations';
$signedURI = Utils::sign($strURI);
| php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.