_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q800
Workbook.createWorkbookFromTemplate
train
public function createWorkbookFromTemplate($templateFileName) { if ($templateFileName == '') throw new Exception('Template file not specified'); //build URI to merge Docs $strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '?templatefile=' . $templateFileName...
php
{ "resource": "" }
q801
Workbook.getWorksheetsCount
train
public function getWorksheetsCount() { //build URI to merge Docs $strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '/worksheets'; //sign URI $signedURI = Utils::sign($strURI); $responseStream = Utils::processCommand($signedURI, 'GET', '', ''); $j...
php
{ "resource": "" }
q802
Workbook.getNamesCount
train
public function getNamesCount() { //build URI to merge Docs $strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '/names'; //sign URI $signedURI = Utils::sign($strURI); $responseStream = Utils::processCommand($signedURI, 'GET', '', ''); $json = json...
php
{ "resource": "" }
q803
Workbook.getDefaultStyle
train
public function getDefaultStyle() { //build URI to merge Docs $strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '/defaultStyle'; //sign URI $signedURI = Utils::sign($strURI); $responseStream = Utils::processCommand($signedURI, 'GET', ''); $json =...
php
{ "resource": "" }
q804
Workbook.encryptWorkbook
train
public function encryptWorkbook($encryptionType = 'XOR', $password = '', $keyLength = '') { //Build JSON to post $fieldsArray['EncriptionType'] = $encryptionType; $fieldsArray['KeyLength'] = $keyLength; $fieldsArray['Password'] = $password; $json = json_encode($fieldsArray); ...
php
{ "resource": "" }
q805
Workbook.addWorksheet
train
public function addWorksheet($worksheetName) { $strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '/worksheets/' . $worksheetName; $signedURI = Utils::sign($strURI); $responseStream = Utils::processCommand($signedURI, 'PUT', '', ''); $json_response = json_decode(...
php
{ "resource": "" }
q806
Workbook.mergeWorkbook
train
public function mergeWorkbook($mergeFileName) { $strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '/merge?mergeWith=' . $mergeFileName; $signedURI = Utils::sign($strURI); $responseStream = Utils::processCommand($signedURI, 'POST', '', ''); $json_response = json_...
php
{ "resource": "" }
q807
Workbook.autofitRows
train
public function autofitRows($saveFormat = "") { $strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '?isAutoFit=true'; if ($saveFormat != '') $strURI .= '&format=' . $saveFormat; $signedURI = Utils::sign($strURI); $responseStream = Ut...
php
{ "resource": "" }
q808
Workbook.saveAs
train
public function saveAs($strXML, $outputFile) { if ($strXML == '') throw new Exception('XML Data not specified'); if ($outputFile == '') throw new Exception('Output Filename along extension not specified'); $strURI = Product::$baseProductUri . '/cells...
php
{ "resource": "" }
q809
Utils.codepointToUtf8
train
public static function codepointToUtf8( $codepoint ) { if ( $codepoint < 0x80 ) { return chr( $codepoint ); } if ( $codepoint < 0x800 ) { return chr( $codepoint >> 6 & 0x3f | 0xc0 ) . chr( $codepoint & 0x3f | 0x80 ); } if ( $codepoint < 0x10000 ) { return chr( $codepoint >> 12 & 0x0f | 0xe0 ) . ...
php
{ "resource": "" }
q810
Utils.hexSequenceToUtf8
train
public static function hexSequenceToUtf8( $sequence ) { $utf = ''; foreach ( explode( ' ', $sequence ) as $hex ) { $n = hexdec( $hex ); $utf .= self::codepointToUtf8( $n ); } return $utf; }
php
{ "resource": "" }
q811
Utils.utf8ToHexSequence
train
private static function utf8ToHexSequence( $str ) { $buf = ''; foreach ( preg_split( '//u', $str, -1, PREG_SPLIT_NO_EMPTY ) as $cp ) { $buf .= sprintf( '%04x ', self::utf8ToCodepoint( $cp ) ); } return rtrim( $buf ); }
php
{ "resource": "" }
q812
Utils.utf8ToCodepoint
train
public static function utf8ToCodepoint( $char ) { # Find the length $z = ord( $char[0] ); if ( $z & 0x80 ) { $length = 0; while ( $z & 0x80 ) { $length++; $z <<= 1; } } else { $length = 1; } if ( $length != strlen( $char ) ) { return false; } if ( $length == 1 ) { return ord(...
php
{ "resource": "" }
q813
HttpObservable.setContentLength
train
private function setContentLength() { if (!is_string($this->body)) { return; } $headers = array_map('strtolower', array_keys($this->headers)); if (!in_array('content-length', $headers, true)) { $this->headers['Content-Length'] = strlen($this->body); ...
php
{ "resource": "" }
q814
AttributeValue.instantiate
train
public static function instantiate(AttributeContract $attribute, $value) { if (! $attribute->supportsValues()) { throw new AttributeMustSupportValues(); } return new static([ 'attribute_id' => $attribute->id, 'value' => $value, ]); }
php
{ "resource": "" }
q815
Product.instantiate
train
public static function instantiate(ProductNumberContract $productNumber, ProductTypeContract $productType, $description) { return new static([ 'product_number' => $productNumber, 'product_type_id' => $productType->id, 'description' => $description, ]); }
php
{ "resource": "" }
q816
CronController.actionStart
train
public function actionStart($taskCommand = null ) { /** * @var $cron Crontab */ $cron = $this->module->get($this->module->nameComponent); $cron->eraseJobs(); $common_params = $this->module->params; if(!empty($this->module->tasks)) { if($taskComma...
php
{ "resource": "" }
q817
CronController.actionLs
train
public function actionLs($params = false){ /** * @var $cron Crontab */ if(false == $params) { $cron = $this->module->get($this->module->nameComponent); $jobs = $cron->getJobs(); foreach ($jobs as $index=>$job) { /** ...
php
{ "resource": "" }
q818
ActionsMadeMap.runActionHandler
train
protected function runActionHandler($action, TreeNodeInterface $node) { if ($node instanceof Token) { try { return $action($node->getContent()); } catch (AbortParsingException $e) { if (null === $e->getOffset()) { throw new AbortPar...
php
{ "resource": "" }
q819
Extractor.extractTextFromLocalFile
train
public function extractTextFromLocalFile($localFile, $language, $useDefaultDictionaries) { $strURI = Product::$baseProductUri . '/ocr/recognize?language=' . $language . '&useDefaultDictionaries='; $strURI .= ($useDefaultDictionaries) ? 'true' : 'false'; $signedURI = Utils::sign($strURI); ...
php
{ "resource": "" }
q820
Extractor.extractTextFromUrl
train
public function extractTextFromUrl($url, $language, $useDefaultDictionaries) { $strURI = Product::$baseProductUri . '/ocr/recognize?url=' . $url . '&language=' . $language . '&useDefaultDictionaries=' . $useDefaultDictionaries; $signedURI = Utils::sign($strURI); $responseStream = Utils::proc...
php
{ "resource": "" }
q821
BaseLexer.parse
train
public function parse(string $input) { $pos = 0; while (null !== ($match = $this->parseOne($input, $pos))) { $pos = $match->nextOffset; yield $match->token; } }
php
{ "resource": "" }
q822
BaseLexer.parseOne
train
public function parseOne(string $input, int $pos, array $preferredTokens = []): ?Match { $length = strlen($input); if ($pos >= $length) { return null; } $this->compile(); $whitespace_length = $this->getWhitespaceLength($input, $pos); if ($whitespace_leng...
php
{ "resource": "" }
q823
BaseLexer.checkOverlappingNames
train
private function checkOverlappingNames(array $maps): void { $index = 0; foreach ($maps as $type => $map) { $rest_maps = array_slice($maps, $index + 1, null, true); foreach ($rest_maps as $type2 => $map2) { $same = array_intersect_key($map, $map2); ...
php
{ "resource": "" }
q824
BaseLexer.buildFixedAndInlines
train
private function buildFixedAndInlines(array $fixedMap, array $inlines): array { $overlapped = array_intersect($fixedMap, $inlines); if ($overlapped) { throw new \InvalidArgumentException( "Duplicating fixed tokens and inline tokens strings: " . join(', ', ...
php
{ "resource": "" }
q825
BaseLexer.buildMap
train
private function buildMap(array $map, string $join): string { $alt = []; foreach ($map as $type => $re) { $alt[] = "(?<$type>$re)"; } if (false !== $join) { $alt = join($join, $alt); } return $alt; }
php
{ "resource": "" }
q826
BaseLexer.match
train
private function match(string $input, int $pos, array $preferredTokens): ?Match { $current_regexp = $this->getRegexpForTokens($preferredTokens); if (false === preg_match($current_regexp, $input, $match, 0, $pos)) { $error_code = preg_last_error(); throw new \RuntimeException...
php
{ "resource": "" }
q827
BaseLexer.getWhitespaceLength
train
private function getWhitespaceLength(string $input, int $pos): int { if ($this->regexpWhitespace) { if ( false === preg_match( $this->regexpWhitespace, $input, $match, 0, $pos ...
php
{ "resource": "" }
q828
BaseLexer.checkMapNames
train
private function checkMapNames(array $map): void { $names = array_keys($map); $bad_names = preg_grep(self::RE_NAME, $names, PREG_GREP_INVERT); if ($bad_names) { throw new \InvalidArgumentException( 'Bad names: ' . join(', ', $bad_names) ); } ...
php
{ "resource": "" }
q829
BaseLexer.validateRegExp
train
private static function validateRegExp(string $regExp, string $displayName): void { /** @uses convertErrorToException() */ set_error_handler([__CLASS__, 'convertErrorToException'], E_WARNING); try { if (false === preg_match($regExp, null)) { throw new \InvalidArgu...
php
{ "resource": "" }
q830
BaseLexer.textToRegExp
train
protected function textToRegExp(string $text): string { // preg_quote() is useless with /x modifier: https://3v4l.org/brdeT if (false === strpos($this->modifiers, 'x') || !preg_match('~[\\s/#]|\\\\E~', $text)) { return preg_quote($text, '/'); } // foo\Efoo --> \Qfoo\E\\...
php
{ "resource": "" }
q831
Symbol.compare
train
public static function compare(Symbol $a, Symbol $b): int { return ($a->isTerminal - $b->isTerminal) ?: strcmp($a->name, $b->name); }
php
{ "resource": "" }
q832
Symbol.compareList
train
public static function compareList(array $a, array $b): int { foreach ($a as $i => $symbol) { // $b finished, but $a not yet if (!isset($b[$i])) { // $a > $b return 1; } // $a[$i] <=> $b[$i] $result = static::compare...
php
{ "resource": "" }
q833
Symbol.dumpName
train
public static function dumpName(string $name): string { if (self::isLikeName($name)) { return $name; } return self::dumpInline($name); }
php
{ "resource": "" }
q834
Symbol.dumpType
train
public static function dumpType(string $type): string { if (self::isLikeName($type)) { return "<$type>"; } return self::dumpInline($type); }
php
{ "resource": "" }
q835
Symbol.dumpInline
train
public static function dumpInline(string $inline): string { if (false === strpos($inline, '"')) { return '"' . $inline . '"'; } if (false === strpos($inline, "'")) { return "'$inline'"; } return "<$inline>"; }
php
{ "resource": "" }
q836
Extractor.getText
train
public function getText() { $strURI = Product::$baseProductUri . '/words/' . $this->getFileName() . '/textItems'; $signedURI = Utils::sign($strURI); $responseStream = Utils::processCommand($signedURI, 'GET', '', ''); $json = json_decode($responseStream); return $json->T...
php
{ "resource": "" }
q837
Extractor.getDrawingObject
train
public function getDrawingObject($objectURI, $outputPath) { if ($outputPath == '') throw new Exception('Output path not specified'); if ($objectURI == '') throw new Exception('Object URI not specified'); $url_arr = explode('/', $objectURI); $objectIndex = ...
php
{ "resource": "" }
q838
Extractor.getProtection
train
public function getProtection() { $strURI = Product::$baseProductUri . '/words/' . $this->getFileName() . '/protection'; $signedURI = Utils::sign($strURI); $response = Utils::processCommand($signedURI, 'GET', '', ''); $json = json_decode($response); if ($json->Code == 200...
php
{ "resource": "" }
q839
StatementPool.push
train
protected function push(Statement $statement) { $maxConnections = $this->pool->getConnectionLimit(); if ($this->statements->count() > ($maxConnections / 10)) { return; } if ($maxConnections === $this->pool->getConnectionCount() && $this->pool->getIdleConnectionCount() =...
php
{ "resource": "" }
q840
StatementPool.pop
train
protected function pop(): \Generator { while (!$this->statements->isEmpty()) { $statement = $this->statements->shift(); \assert($statement instanceof Statement); if ($statement->isAlive()) { return $statement; } } $statement =...
php
{ "resource": "" }
q841
Converter.convertToImagebySize
train
public function convertToImagebySize($slideNumber, $imageFormat, $width, $height) { $strURI = Product::$baseProductUri . '/slides/' . $this->getFileName() . '/slides/' . $slideNumber . '?format=' . $imageFormat . '&width=' . $width . '&height=' . $height; $signedURI = Utils::sign($strURI); ...
php
{ "resource": "" }
q842
Converter.convertWithAdditionalSettings
train
public function convertWithAdditionalSettings($saveFormat = 'pdf', $textCompression = '', $embedFullFonts = '', $compliance ='', $jpegQuality = '', $saveMetafilesAsPng = '', $pdfPassword = '', $embedTrueTypeFontsForASCII = '') { $strURI = Product::$baseProductUri . '/slides/' . $this->getFileName() . '?form...
php
{ "resource": "" }
q843
Extractor.getTiffFrameProperties
train
public function getTiffFrameProperties($frameId) { if ($frameId == '') throw new Exception('Frame ID not specified'); //build URI $strURI = Product::$baseProductUri . '/imaging/' . $this->getFileName() . '/frames/' . $frameId . '/properties'; //sign URI $signed...
php
{ "resource": "" }
q844
Extractor.extractFrames
train
public function extractFrames($frameId, $outPath) { if ($frameId == '') throw new Exception('Frame ID not specified'); if ($outPath == '') throw new Exception('Output file not specified'); //build URI $strURI = Product::$baseProductUri . '/imaging/' . $this...
php
{ "resource": "" }
q845
Extractor.cropFrame
train
public function cropFrame($frameId, $x, $y, $recWidth, $recHeight, $outPath) { if ($frameId == '') throw new Exception('Frame ID not specified'); if ($x == '') throw new Exception('X position not specified'); if ($y == '') throw new Exception('Y positio...
php
{ "resource": "" }
q846
Extractor.manipulateFrame
train
public function manipulateFrame($frameId, $rotateFlipMethod, $newWidth, $newHeight, $x, $y, $rectWidth, $rectHeight, $outPath) { if ($frameId == '') throw new Exception('Frame ID not specified'); if ($rotateFlipMethod == '') throw new Exception('RotateFlip method not specif...
php
{ "resource": "" }
q847
UserIsAuthor.checkFlag
train
public function checkFlag(array $context): bool { if (!isset($context['user'])) { throw new \InvalidArgumentException(sprintf('The context parameter must contain a "user" key to be able to evaluate the %s flag.', $this->getName())); } $user = $context['user']; if (is_str...
php
{ "resource": "" }
q848
Stack.shift
train
public function shift(TreeNodeInterface $node, int $stateIndex): void { $item = new StackItem(); $item->state = $stateIndex; $item->node = $node; if ($this->actions) { $this->actions->applyToNode($node); } $this->items[] = $item; $this->stateInde...
php
{ "resource": "" }
q849
Stack.reduce
train
public function reduce(): void { $rule = $this->stateRow->reduceRule; if (!$rule) { throw new NoReduceException(); } $reduce_count = count($rule->getDefinition()); $total_count = count($this->items); if ($total_count < $reduce_count) { throw ne...
php
{ "resource": "" }
q850
QuoteManager.setInstallmentDataBeforeAuthorization
train
public function setInstallmentDataBeforeAuthorization($installmentQuantity) { if ($this->_calculator === null) { throw new LocalizedException(new Phrase('You need to set an installment calculator befor prior to' . 'installments')); } /* @var Quote $quote */ $...
php
{ "resource": "" }
q851
Calculator.getInstallmentConfig
train
public function getInstallmentConfig() { $installmentConfig = $this->_dataObjectFactory->create(); $maxInstallmentQty = $this->getMaximumInstallmentQuantity(); $installmentConfig->maximumInstallmentQty = $maxInstallmentQty; $installmentConfig->minimumInstallmentAmount = $this->getMi...
php
{ "resource": "" }
q852
Calculator.getInstallments
train
public function getInstallments($paymentAmount) { $installments = []; $this->setPaymentAmount($paymentAmount); $maxInstallmentQty = $this->getMaximumInstallmentQuantity(); # Looping through all possible installment values for ($curInstallment = 1; ($curInstallment <= 12 && ...
php
{ "resource": "" }
q853
Calculator.getInterestAmount
train
public function getInterestAmount($amount, $installmentQuantity) { $minimumAmountNoInterest = $this->getMinimumAmountNoInterest($installmentQuantity); if ( ($minimumAmountNoInterest === null) || ($minimumAmountNoInterest !== null) && ($amount < $minimumAmountNoInterest) ...
php
{ "resource": "" }
q854
Calculator.getInterestRateForInstallment
train
public function getInterestRateForInstallment($installments) { $interestRate = $this->getInterestRate(); $computationInstallments = ($installments - 1); $totalInterestRate = (float) pow($interestRate, $computationInstallments); return $totalInterestRate; }
php
{ "resource": "" }
q855
Calculator.getMinimumAmountNoInterest
train
public function getMinimumAmountNoInterest($installments) { $return = null; foreach ($this->_minimumAmountNoInterest as $installmentQty => $minOrderValue) { if ($installmentQty == $installments) { $return = (float) $minOrderValue; break; } ...
php
{ "resource": "" }
q856
Calculator.getTotalAmountAfterInterest
train
public function getTotalAmountAfterInterest($installments) { $return = $amount = $this->getPaymentAmount(); if ($this->isApplyInterest($installments)) { $return = ($amount) * $this->getInterestRateForInstallment($installments); } return $return; }
php
{ "resource": "" }
q857
Calculator.isApplyInterest
train
public function isApplyInterest($installments) { $return = true; $interestRate = $this->getInterestRate(); $paymentAmount = $this->getPaymentAmount(); if (($installments > 1) && ($interestRate > 1)) { # If we're not dealing with a one time payment and the interest rate ...
php
{ "resource": "" }
q858
Consumer.reset
train
public function reset() { // clears the object entirely $this->url = null; $this->params = array(); $this->options = array(); $this->callType = null; $this->responseType = null; }
php
{ "resource": "" }
q859
Consumer.setParams
train
public function setParams($params) { // $param should be a single key => value pair if (is_array($params)) { foreach ($params as $key => $param) { $this->params[$key] = $param; } } }
php
{ "resource": "" }
q860
Consumer.setOptions
train
public function setOptions($options) { // $param should be a single key => value pair if (is_array($options)) { foreach ($options as $key => $option) { $this->options[$key] = $option; } } }
php
{ "resource": "" }
q861
Consumer.doApiCall
train
public function doApiCall() { $parsedResponse = array(); $jsonResponse = false; $curlUrl = $this->createUrl(); if ($curlUrl) { $jsonResponse = $this->submitCurlRequest($curlUrl); } if ($jsonResponse) { $parsedResponse = $this->parseJ...
php
{ "resource": "" }
q862
Consumer.createUrl
train
public function createUrl() { $curlUrl = $this->url . '?'; foreach ($this->params as $key => $value) { $curlUrl .= $key . '=' . $value; $curlUrl .= '&'; } return $curlUrl; }
php
{ "resource": "" }
q863
Consumer.submitCurlRequest
train
protected function submitCurlRequest($curlUrl) { $session = curl_init(); curl_setopt($session, CURLOPT_URL, $curlUrl); curl_setopt($session, CURLOPT_HEADER, 0); curl_setopt($session, CURLOPT_RETURNTRANSFER, 1); if (!empty($this->options)) { forea...
php
{ "resource": "" }
q864
Utils.processCommand
train
public static function processCommand($url, $method = 'GET', $headerType = 'XML', $src = '', $returnType = 'xml') { $dispatcher = AsposeApp::getEventDispatcher(); $method = strtoupper($method); $headerType = strtoupper($headerType); AsposeApp::getLogger()->info("Aspose Cloud SDK: p...
php
{ "resource": "" }
q865
Utils.uploadFileBinary
train
public static function uploadFileBinary($url, $localFile, $headerType = 'XML', $method = 'PUT') { $method = strtoupper($method); $headerType = strtoupper($headerType); AsposeApp::getLogger()->info("Aspose Cloud SDK: uploadFileBinary called", array( 'url' => $url, 'lo...
php
{ "resource": "" }
q866
Utils.saveFile
train
public static function saveFile($input, $fileName) { $fh = fopen($fileName, 'w') or die('cant open file'); fwrite($fh, $input); fclose($fh); }
php
{ "resource": "" }
q867
Utils.getFieldCount
train
public function getFieldCount($jsonResponse, $fieldName) { $arr = json_decode($jsonResponse)->{$fieldName}; return count($arr, COUNT_RECURSIVE); }
php
{ "resource": "" }
q868
WeChatVideoDriver.getVideo
train
private function getVideo() { $videoUrl = 'http://file.api.wechat.com/cgi-bin/media/get?access_token='.$this->getAccessToken().'&media_id='.$this->event->get('MediaId'); return [new Video($videoUrl, $this->event)]; }
php
{ "resource": "" }
q869
BarcodeReader.read
train
public function read($symbology) { //build URI to read barcode $strURI = Product::$baseProductUri . '/barcode/' . $this->getFileName() . '/recognize?' . (!isset($symbology) || trim($symbology) === '' ? 'type=' : 'type=' . $symbology); //sign URI $signedURI = Utils::sign($strURI); ...
php
{ "resource": "" }
q870
BarcodeReader.readFromLocalImage
train
public function readFromLocalImage($localImage, $remoteFolder, $barcodeReadType) { $folder = new Folder(); $folder->UploadFile($localImage, $remoteFolder); $data = $this->ReadR(basename($localImage), $remoteFolder, $barcodeReadType); return $data; }
php
{ "resource": "" }
q871
BarcodeReader.readR
train
public function readR($remoteImageName, $remoteFolder, $readType) { $uri = $this->uriBuilder($remoteImageName, $remoteFolder, $readType); $signedURI = Utils::sign($uri); $responseStream = Utils::processCommand($signedURI, 'GET', '', ''); $json = json_decode($responseStream); ...
php
{ "resource": "" }
q872
BarcodeReader.uriBuilder
train
public function uriBuilder($remoteImage, $remoteFolder, $readType) { $uri = Product::$baseProductUri . '/barcode/'; if ($remoteImage != null) $uri .= $remoteImage . '/'; $uri .= 'recognize?'; if ($readType == 'AllSupportedTypes') $uri .= 'type='; else ...
php
{ "resource": "" }
q873
BarcodeReader.readFromURL
train
public function readFromURL($url, $symbology) { if ($url == '') throw new Exception('URL not specified'); if ($symbology == '') throw new Exception('Symbology not specified'); //build URI to read barcode $strURI = Product::$baseProductUri . '/barcode/recogni...
php
{ "resource": "" }
q874
BarcodeReader.readSpecificRegion
train
public function readSpecificRegion($symbology, $rectX, $rectY, $rectWidth, $rectHeight) { if ($symbology == '') throw new Exception('Symbology not specified'); if ($rectX == '') throw new Exception('X position not specified'); if ($rectY == '') throw new...
php
{ "resource": "" }
q875
BarcodeReader.readWithChecksum
train
public function readWithChecksum($symbology, $checksumValidation) { if ($symbology == '') throw new Exception('Symbology not specified'); if ($checksumValidation == '') throw new Exception('Checksum not specified'); //build URI to read barcode $strURI = Prod...
php
{ "resource": "" }
q876
BarcodeReader.readByAlgorithm
train
public function readByAlgorithm($symbology, $binarizationHints) { if ($symbology == '') throw new Exception('Symbology not specified'); if ($binarizationHints == '') throw new Exception('Binarization Hints count not specified'); //build URI to read barcode $...
php
{ "resource": "" }
q877
Field.insertPageNumber
train
public function insertPageNumber($fileName, $alignment, $format, $isTop, $setPageNumberOnFirstPage) { //check whether files are set or not if ($fileName == '') throw new Exception('File not specified'); //Build JSON to post $fieldsArray = array('Format' => $format, 'Alig...
php
{ "resource": "" }
q878
Field.getMailMergeFieldNames
train
public function getMailMergeFieldNames($fileName) { //check whether file is set or not if ($fileName == '') throw new Exception('No file name specified'); $strURI = Product::$baseProductUri . '/words/' . $fileName . '/mailMergeFieldNames'; $signedURI = Utils::sign($strU...
php
{ "resource": "" }
q879
ProductRepository.query
train
public function query($q = null) { return Product::where(function ($query) use ($q) { if ($q) { foreach (explode(' ', $q) as $keyword) { $query->where('description', 'like', "%{$keyword}%"); } } }) ...
php
{ "resource": "" }
q880
ProductRepository.save
train
public function save(ProductContract $product, array $attributes = []) { $result = $product->save(); $details = []; foreach ($attributes as $key => $value) { if ($value) { $details[$key] = compact('value'); } } $product->attributes()->...
php
{ "resource": "" }
q881
Resource.getResources
train
public function getResources() { //build URI $strURI = Product::$baseProductUri . '/tasks/' . $this->getFileName() . '/resources/'; //sign URI $signedURI = Utils::sign($strURI); $responseStream = Utils::processCommand($signedURI, 'GET', '', ''); $json = json_deco...
php
{ "resource": "" }
q882
Resource.getResource
train
public function getResource($resourceId) { if ($resourceId == '') throw new Exception('Resource ID not specified'); //build URI $strURI = Product::$baseProductUri . '/tasks/' . $this->getFileName() . '/resources/' . $resourceId; //sign URI $signedURI = Utils::...
php
{ "resource": "" }
q883
HasStub.getStubContent
train
protected function getStubContent($name) { if (!isset(static::$stubs[$name])) { if (!is_file($path = base_path("resources/stubs/vendor/models-generator/$name.stub"))) { $path = __DIR__."/../../resources/stubs/$name.stub"; } static::$stubs[$name] = file_ge...
php
{ "resource": "" }
q884
CommentsHelper.handle
train
public static function handle($model) { if (!$model->load(Yii::$app->request->post())) return false; return $model->save(); }
php
{ "resource": "" }
q885
Query.querySync
train
public function querySync(){ $adapter = $this->_dbAdapter ?: Table::getDefaultDbAdapter(); return $adapter->querySync($this->assemble(), $this->_bind, $this->_consistency, $this->_options); }
php
{ "resource": "" }
q886
Query.prepare
train
public function prepare(){ $adapter = $this->_dbAdapter ?: Table::getDefaultDbAdapter(); return $adapter->prepare($this->assemble()); }
php
{ "resource": "" }
q887
Config.loadParameters
train
public function loadParameters() { $container = \System::getContainer(); if ($container->hasParameter('contao.video.valid_extensions')) { $GLOBALS['TL_CONFIG']['validVideoTypes'] = implode(',', $container->getParameter('contao.video.valid_extensions')); } if ($container->hasParameter('contao.audio.va...
php
{ "resource": "" }
q888
Session.getFromRequest
train
public static function getFromRequest($create = true) { $sessionData = [ 'LastIP' => inet_pton($_SERVER['REMOTE_ADDR']), 'LastRequest' => time(), ]; // try to load from cookie if (!empty($_COOKIE[static::$cookieName])) { if ($Session = static::get...
php
{ "resource": "" }
q889
EditorController.overviewAction
train
public function overviewAction( Request $request, FormFactoryInterface $formFactory, ExtraFormBuilderInterface $extraFormBuilder ) { $formName = 'overview'; $data = $request->request->get($formName); $configurationRaw = $data['configuration']; $configuration =...
php
{ "resource": "" }
q890
ImageThumb.create
train
public function create($filename = null, array $options = [], array $plugins = []) { try { $thumb = new PHPThumb($filename, $options, $plugins); } catch (\Exception $exc) { throw new Exception\RuntimeException($exc->getMessage(), $exc->getCode(), $exc); } ret...
php
{ "resource": "" }
q891
ImageThumb.createReflection
train
public function createReflection($percent, $reflection, $white, $border, $borderColor) { return new Plugins\Reflection($percent, $reflection, $white, $border, $borderColor); }
php
{ "resource": "" }
q892
ImageThumb.createWatermark
train
public function createWatermark(PHPThumb $watermarkThumb, array $position = [0, 0], $scale = .5) { return new Plugins\Watermark($watermarkThumb, $position, $scale); }
php
{ "resource": "" }
q893
Table.offsetSet
train
public function offsetSet($columnName, $value) { if (!in_array($columnName, static::$_primary)){ $this->_modifiedData[$columnName] = $value; } parent::offsetSet($columnName, $value); }
php
{ "resource": "" }
q894
SerializerSubscriber.onPreSerialize
train
public function onPreSerialize(ObjectEvent $event) { $configuredType = $event->getObject(); if ($configuredType instanceof ConfiguredType) { try { $configurationArray = json_decode($configuredType->getConfiguration(), true); $extraFormType = $this->regist...
php
{ "resource": "" }
q895
Comments.outputComment
train
protected function outputComment($comment) { if ($this->commentOptions instanceof \Closure) { $options = call_user_func($this->commentOptions, $comment); } else { $options = $this->commentOptions; } $options = ArrayHelper::merge($options, ['data-comment-id'=>$comment->id]); if ($this->useBootstrapClass...
php
{ "resource": "" }
q896
PHPGit_Repository.create
train
public static function create($dir, $debug = false, array $options = array()) { $options = array_merge(self::$defaultOptions, $options); $commandString = $options['git_executable'].' init'; $command = new $options['command_class']($dir, $commandString, $debug); $command->run(); ...
php
{ "resource": "" }
q897
PHPGit_Repository.cloneUrl
train
public static function cloneUrl($url, $dir, $debug = false, array $options = array()) { $options = array_merge(self::$defaultOptions, $options); $commandString = $options['git_executable'].' clone '.escapeshellarg($url).' '.escapeshellarg($dir); $command = new $options['command_class'](getcw...
php
{ "resource": "" }
q898
PHPGit_Repository.getCommits
train
public function getCommits($nbCommits = 10) { $output = $this->git(sprintf('log -n %d --date=%s --format=format:%s', $nbCommits, $this->dateFormat, $this->logFormat)); return $this->parseLogsIntoArray($output); }
php
{ "resource": "" }
q899
PHPGit_Repository.parseLogsIntoArray
train
private function parseLogsIntoArray($logOutput) { $commits = array(); foreach(explode("\n", $logOutput) as $line) { $infos = explode('|', $line); $commits[] = array( 'id' => $infos[0], 'tree' => $infos[1], 'author' => array( 'name' => $infos[2], ...
php
{ "resource": "" }