repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
asposeforcloud/Aspose_Cloud_SDK_For_PHP | src/Aspose/Cloud/Slides/Converter.php | Converter.convertWithAdditionalSettings | public function convertWithAdditionalSettings($saveFormat = 'pdf', $textCompression = '', $embedFullFonts = '', $compliance ='', $jpegQuality = '', $saveMetafilesAsPng = '', $pdfPassword = '', $embedTrueTypeFontsForASCII = '')
{
$strURI = Product::$baseProductUri . '/slides/' . $this->getFileName() . '?format=' . $saveFormat;
if ($textCompression != '')
$strURI .= '&TextCompression=' . $textCompression;
if ($embedFullFonts != '')
$strURI .= '&EmbedFullFonts=' . $embedFullFonts;
if ($compliance != '')
$strURI .= '&Compliance=' . $compliance;
if ($jpegQuality != '')
$strURI .= '&JpegQuality=' . $jpegQuality;
if ($saveMetafilesAsPng != '')
$strURI .= '&SaveMetafilesAsPng=' . $saveMetafilesAsPng;
if ($pdfPassword != '')
$strURI .= '&PdfPassword=' . $pdfPassword;
if ($embedTrueTypeFontsForASCII != '')
$strURI .= '&EmbedTrueTypeFontsForASCII=' . $embedTrueTypeFontsForASCII;
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$v_output = Utils::validateOutput($responseStream);
if ($v_output === '') {
$outputPath = AsposeApp::$outPutLocation . Utils::getFileName($this->getFileName()) . '.' . $saveFormat;
Utils::saveFile($responseStream, $outputPath);
return $outputPath;
} else {
return $v_output;
}
} | php | public function convertWithAdditionalSettings($saveFormat = 'pdf', $textCompression = '', $embedFullFonts = '', $compliance ='', $jpegQuality = '', $saveMetafilesAsPng = '', $pdfPassword = '', $embedTrueTypeFontsForASCII = '')
{
$strURI = Product::$baseProductUri . '/slides/' . $this->getFileName() . '?format=' . $saveFormat;
if ($textCompression != '')
$strURI .= '&TextCompression=' . $textCompression;
if ($embedFullFonts != '')
$strURI .= '&EmbedFullFonts=' . $embedFullFonts;
if ($compliance != '')
$strURI .= '&Compliance=' . $compliance;
if ($jpegQuality != '')
$strURI .= '&JpegQuality=' . $jpegQuality;
if ($saveMetafilesAsPng != '')
$strURI .= '&SaveMetafilesAsPng=' . $saveMetafilesAsPng;
if ($pdfPassword != '')
$strURI .= '&PdfPassword=' . $pdfPassword;
if ($embedTrueTypeFontsForASCII != '')
$strURI .= '&EmbedTrueTypeFontsForASCII=' . $embedTrueTypeFontsForASCII;
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$v_output = Utils::validateOutput($responseStream);
if ($v_output === '') {
$outputPath = AsposeApp::$outPutLocation . Utils::getFileName($this->getFileName()) . '.' . $saveFormat;
Utils::saveFile($responseStream, $outputPath);
return $outputPath;
} else {
return $v_output;
}
} | [
"public",
"function",
"convertWithAdditionalSettings",
"(",
"$",
"saveFormat",
"=",
"'pdf'",
",",
"$",
"textCompression",
"=",
"''",
",",
"$",
"embedFullFonts",
"=",
"''",
",",
"$",
"compliance",
"=",
"''",
",",
"$",
"jpegQuality",
"=",
"''",
",",
"$",
"sa... | Convert PowerPoint Documents to other File Formats with Additional Settings
@param type $saveFormat Return the presentation in the specified format.
@param type $textCompression Specifies compression type to be used for all textual content in the document.
@param type $embedFullFonts Determines if all characters of font should be embedded or only used subset.
@param type $compliance Desired conformance level for generated PDF document.
@param type $jpegQuality Value determining the quality of the JPEG images inside PDF document.
@param type $saveMetafilesAsPng True to convert all metafiles used in a presentation to the PNG images.
@param type $pdfPassword Setting user password to protect the PDF document.
@param type $embedTrueTypeFontsForASCII Determines service will embed common fonts for ASCII.
@return string Returns the file path. | [
"Convert",
"PowerPoint",
"Documents",
"to",
"other",
"File",
"Formats",
"with",
"Additional",
"Settings"
] | 4950f2f2d24c9a101bf8e0a552d3801c251adac0 | https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_PHP/blob/4950f2f2d24c9a101bf8e0a552d3801c251adac0/src/Aspose/Cloud/Slides/Converter.php#L172-L209 | train |
asposeforcloud/Aspose_Cloud_SDK_For_PHP | src/Aspose/Cloud/Imaging/Extractor.php | Extractor.getTiffFrameProperties | 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
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
if ($json->Code == 200)
return $json;
else
return false;
} | php | 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
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
if ($json->Code == 200)
return $json;
else
return false;
} | [
"public",
"function",
"getTiffFrameProperties",
"(",
"$",
"frameId",
")",
"{",
"if",
"(",
"$",
"frameId",
"==",
"''",
")",
"throw",
"new",
"Exception",
"(",
"'Frame ID not specified'",
")",
";",
"//build URI",
"$",
"strURI",
"=",
"Product",
"::",
"$",
"baseP... | Get TIFF Frame Properties.
@param integer $frameId Number of frame.
@return array|boolean Returns the document properties.
@throws Exception | [
"Get",
"TIFF",
"Frame",
"Properties",
"."
] | 4950f2f2d24c9a101bf8e0a552d3801c251adac0 | https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_PHP/blob/4950f2f2d24c9a101bf8e0a552d3801c251adac0/src/Aspose/Cloud/Imaging/Extractor.php#L31-L51 | train |
asposeforcloud/Aspose_Cloud_SDK_For_PHP | src/Aspose/Cloud/Imaging/Extractor.php | Extractor.extractFrames | 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->getFileName() . '/frames/' . $frameId . '?saveOtherFrames=false&outPath=' . $outPath;
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$v_output = Utils::validateOutput($responseStream);
if ($v_output === '') {
$folder = new Folder();
$outputStream = $folder->GetFile($outPath);
$outputPath = AsposeApp::$outPutLocation . $outPath;
Utils::saveFile($outputStream, $outputPath);
return $outputPath;
} else
return $v_output;
} | php | 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->getFileName() . '/frames/' . $frameId . '?saveOtherFrames=false&outPath=' . $outPath;
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$v_output = Utils::validateOutput($responseStream);
if ($v_output === '') {
$folder = new Folder();
$outputStream = $folder->GetFile($outPath);
$outputPath = AsposeApp::$outPutLocation . $outPath;
Utils::saveFile($outputStream, $outputPath);
return $outputPath;
} else
return $v_output;
} | [
"public",
"function",
"extractFrames",
"(",
"$",
"frameId",
",",
"$",
"outPath",
")",
"{",
"if",
"(",
"$",
"frameId",
"==",
"''",
")",
"throw",
"new",
"Exception",
"(",
"'Frame ID not specified'",
")",
";",
"if",
"(",
"$",
"outPath",
"==",
"''",
")",
"... | Extract Frame from a Multi-Frame TIFF Image.
@param integer $frameId Number of frame.
@param string $outPath Path to updated file.
@return string Returns the file path.
@throws Exception | [
"Extract",
"Frame",
"from",
"a",
"Multi",
"-",
"Frame",
"TIFF",
"Image",
"."
] | 4950f2f2d24c9a101bf8e0a552d3801c251adac0 | https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_PHP/blob/4950f2f2d24c9a101bf8e0a552d3801c251adac0/src/Aspose/Cloud/Imaging/Extractor.php#L62-L89 | train |
asposeforcloud/Aspose_Cloud_SDK_For_PHP | src/Aspose/Cloud/Imaging/Extractor.php | Extractor.cropFrame | 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 position not specified');
if ($recWidth == '')
throw new Exception('Width of cropping rectangle not specified');
if ($recHeight == '')
throw new Exception('Height of cropping rectangle not specified');
if ($outPath == '')
throw new Exception('Output file not specified');
//build URI
$strURI = Product::$baseProductUri . '/imaging/' . $this->getFileName() . '/frames/' . $frameId . '?saveOtherFrames=true&$x=' . $x . '&y=' . $y . '&rectWidth=' . $recWidth . '&rectHeight=' . $recHeight . '&outPath=' . $outPath;
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$v_output = Utils::validateOutput($responseStream);
if ($v_output === '') {
$folder = new Folder();
$outputStream = $folder->GetFile($outPath);
$outputPath = AsposeApp::$outPutLocation . $outPath;
Utils::saveFile($outputStream, $outputPath);
return $outputPath;
} else
return $v_output;
} | php | 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 position not specified');
if ($recWidth == '')
throw new Exception('Width of cropping rectangle not specified');
if ($recHeight == '')
throw new Exception('Height of cropping rectangle not specified');
if ($outPath == '')
throw new Exception('Output file not specified');
//build URI
$strURI = Product::$baseProductUri . '/imaging/' . $this->getFileName() . '/frames/' . $frameId . '?saveOtherFrames=true&$x=' . $x . '&y=' . $y . '&rectWidth=' . $recWidth . '&rectHeight=' . $recHeight . '&outPath=' . $outPath;
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$v_output = Utils::validateOutput($responseStream);
if ($v_output === '') {
$folder = new Folder();
$outputStream = $folder->GetFile($outPath);
$outputPath = AsposeApp::$outPutLocation . $outPath;
Utils::saveFile($outputStream, $outputPath);
return $outputPath;
} else
return $v_output;
} | [
"public",
"function",
"cropFrame",
"(",
"$",
"frameId",
",",
"$",
"x",
",",
"$",
"y",
",",
"$",
"recWidth",
",",
"$",
"recHeight",
",",
"$",
"outPath",
")",
"{",
"if",
"(",
"$",
"frameId",
"==",
"''",
")",
"throw",
"new",
"Exception",
"(",
"'Frame ... | Crop a TIFF Frame.
@param integer $frameId Number of the frame.
@param integer $x X position of start point for cropping rectangle.
@param integer $y Y position of start point for cropping rectangle.
@param integer $rectWidth Width of cropping rectangle.
@param integer $rectHeight Height of cropping rectangle.
@param string $outPath Path to updated file.
@return string Returns the file path.
@throws Exception | [
"Crop",
"a",
"TIFF",
"Frame",
"."
] | 4950f2f2d24c9a101bf8e0a552d3801c251adac0 | https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_PHP/blob/4950f2f2d24c9a101bf8e0a552d3801c251adac0/src/Aspose/Cloud/Imaging/Extractor.php#L150-L189 | train |
asposeforcloud/Aspose_Cloud_SDK_For_PHP | src/Aspose/Cloud/Imaging/Extractor.php | Extractor.manipulateFrame | 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 specified');
if ($newWidth == '')
throw new Exception('New width not specified');
if ($newHeight == '')
throw new Exception('New height not specified');
if ($x == '')
throw new Exception('X position not specified');
if ($y == '')
throw new Exception('Y position not specified');
if ($rectWidth == '')
throw new Exception('Width of cropping rectangle not specified');
if ($rectHeight == '')
throw new Exception('Height of cropping rectangle not specified');
if ($outPath == '')
throw new Exception('Output file not specified');
//build URI
$strURI = Product::$baseProductUri . '/imaging/' . $this->getFileName() . '/frames/' . $frameId . '?saveOtherFrames=false&rotateFlipMethod=' . $rotateFlipMethod . '&newWidth=' . $newWidth . '&newHeight=' . $newHeight . '&x=' . $x . '&y=' . $y . '&rectWidth=' . $rectWidth . '&rectHeight=' . $rectHeight . '&outPath=' . $outPath;
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$v_output = Utils::validateOutput($responseStream);
if ($v_output === '') {
$folder = new Folder();
$outputStream = $folder->GetFile($outPath);
$outputPath = AsposeApp::$outPutLocation . $outPath;
Utils::saveFile($outputStream, $outputPath);
return $outputPath;
} else
return $v_output;
} | php | 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 specified');
if ($newWidth == '')
throw new Exception('New width not specified');
if ($newHeight == '')
throw new Exception('New height not specified');
if ($x == '')
throw new Exception('X position not specified');
if ($y == '')
throw new Exception('Y position not specified');
if ($rectWidth == '')
throw new Exception('Width of cropping rectangle not specified');
if ($rectHeight == '')
throw new Exception('Height of cropping rectangle not specified');
if ($outPath == '')
throw new Exception('Output file not specified');
//build URI
$strURI = Product::$baseProductUri . '/imaging/' . $this->getFileName() . '/frames/' . $frameId . '?saveOtherFrames=false&rotateFlipMethod=' . $rotateFlipMethod . '&newWidth=' . $newWidth . '&newHeight=' . $newHeight . '&x=' . $x . '&y=' . $y . '&rectWidth=' . $rectWidth . '&rectHeight=' . $rectHeight . '&outPath=' . $outPath;
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$v_output = Utils::validateOutput($responseStream);
if ($v_output === '') {
$folder = new Folder();
$outputStream = $folder->GetFile($outPath);
$outputPath = AsposeApp::$outPutLocation . $outPath;
Utils::saveFile($outputStream, $outputPath);
return $outputPath;
} else
return $v_output;
} | [
"public",
"function",
"manipulateFrame",
"(",
"$",
"frameId",
",",
"$",
"rotateFlipMethod",
",",
"$",
"newWidth",
",",
"$",
"newHeight",
",",
"$",
"x",
",",
"$",
"y",
",",
"$",
"rectWidth",
",",
"$",
"rectHeight",
",",
"$",
"outPath",
")",
"{",
"if",
... | Manipulate a Frame and Save the Modified Frame Along with Unmodified Frames.
@param integer $frameId Number of frame.
@param string $rotateFlipMethod RotateFlip method.
@param integer $newWidth New width of the scaled image.
@param integer $newHeight New height of the scaled image.
@param integer $x X position of start point for cropping rectangle.
@param integer $y Y position of start point for cropping rectangle.
@param integer $rectWidth Width of cropping rectangle.
@param integer $rectHeight Height of cropping rectangle.
@param string $outPath Path to updated file.
@return string Returns the file path.
@throws Exception | [
"Manipulate",
"a",
"Frame",
"and",
"Save",
"the",
"Modified",
"Frame",
"Along",
"with",
"Unmodified",
"Frames",
"."
] | 4950f2f2d24c9a101bf8e0a552d3801c251adac0 | https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_PHP/blob/4950f2f2d24c9a101bf8e0a552d3801c251adac0/src/Aspose/Cloud/Imaging/Extractor.php#L249-L297 | train |
ordermind/symfony-logical-authorization-bundle | PermissionTypes/Flag/Flags/UserIsAuthor.php | UserIsAuthor.checkFlag | 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_string($user)) { //Anonymous user
return false;
}
if (!($user instanceof UserInterface)) {
throw new \InvalidArgumentException(sprintf('The user class must implement Ordermind\LogicalAuthorizationBundle\Interfaces\UserInterface to be able to evaluate the %s flag.', $this->getName()));
}
if (!isset($context['model'])) {
throw new \InvalidArgumentException(sprintf('Missing key "model" in context parameter. We cannot evaluate the %s flag without a model.', $this->getName()));
}
$model = $context['model'];
if (is_string($model) && class_exists($model)) {
// A class string was passed which means that we don't have an actual object to evaluate. We interpret this as it not having an author which means that we return false.
return false;
}
if ($model instanceof UserInterface) {
return $user->getId() === $model->getId();
}
if ($model instanceof ModelInterface) {
$author = $model->getAuthor();
// If there is no author it probably means that the entity is not yet persisted. In that case it's reasonable to assume that the current user is the author.
// If the lack of author is due to some other reason it's also reasonable to fall back to granting permission because the reason for this flag is to protect models that do have an author against other users.
if (!$author) {
return true;
}
if (!($author instanceof UserInterface)) {
throw new \InvalidArgumentException(sprintf('The author of the model must implement Ordermind\LogicalAuthorizationBundle\Interfaces\UserInterface to be able to evaluate the %s flag.', $this->getName()));
}
return $user->getId() === $author->getId();
}
throw new \InvalidArgumentException(sprintf('The model class must implement either Ordermind\LogicalAuthorizationBundle\Interfaces\ModelInterface or Ordermind\LogicalAuthorizationBundle\Interfaces\UserInterface to be able to evaluate the %s flag.', $this->getName()));
} | php | 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_string($user)) { //Anonymous user
return false;
}
if (!($user instanceof UserInterface)) {
throw new \InvalidArgumentException(sprintf('The user class must implement Ordermind\LogicalAuthorizationBundle\Interfaces\UserInterface to be able to evaluate the %s flag.', $this->getName()));
}
if (!isset($context['model'])) {
throw new \InvalidArgumentException(sprintf('Missing key "model" in context parameter. We cannot evaluate the %s flag without a model.', $this->getName()));
}
$model = $context['model'];
if (is_string($model) && class_exists($model)) {
// A class string was passed which means that we don't have an actual object to evaluate. We interpret this as it not having an author which means that we return false.
return false;
}
if ($model instanceof UserInterface) {
return $user->getId() === $model->getId();
}
if ($model instanceof ModelInterface) {
$author = $model->getAuthor();
// If there is no author it probably means that the entity is not yet persisted. In that case it's reasonable to assume that the current user is the author.
// If the lack of author is due to some other reason it's also reasonable to fall back to granting permission because the reason for this flag is to protect models that do have an author against other users.
if (!$author) {
return true;
}
if (!($author instanceof UserInterface)) {
throw new \InvalidArgumentException(sprintf('The author of the model must implement Ordermind\LogicalAuthorizationBundle\Interfaces\UserInterface to be able to evaluate the %s flag.', $this->getName()));
}
return $user->getId() === $author->getId();
}
throw new \InvalidArgumentException(sprintf('The model class must implement either Ordermind\LogicalAuthorizationBundle\Interfaces\ModelInterface or Ordermind\LogicalAuthorizationBundle\Interfaces\UserInterface to be able to evaluate the %s flag.', $this->getName()));
} | [
"public",
"function",
"checkFlag",
"(",
"array",
"$",
"context",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"context",
"[",
"'user'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The context ... | Checks if the author of a model is the same as the user in a given context.
@param array $context The context for evaluating the flag. The context must contain a 'user' key and a 'model' key. The user needs to implement Ordermind\LogicalAuthorizationBundle\Interfaces\UserInterface and the model needs to implement Ordermind\LogicalAuthorizationBundle\Interfaces\ModelInterface. You can get the current user by calling getCurrentUser() from the service 'logauth.service.helper'.
@return bool TRUE if the user is the author of the model and FALSE if it isn't. There is no support for anonymous authors so if the user is anonymous it will always return FALSE. | [
"Checks",
"if",
"the",
"author",
"of",
"a",
"model",
"is",
"the",
"same",
"as",
"the",
"user",
"in",
"a",
"given",
"context",
"."
] | 3b051f0984dcf3527024b64040bfc4b2b0855f3b | https://github.com/ordermind/symfony-logical-authorization-bundle/blob/3b051f0984dcf3527024b64040bfc4b2b0855f3b/PermissionTypes/Flag/Flags/UserIsAuthor.php#L30-L74 | train |
Vovan-VE/parser | src/stack/Stack.php | Stack.shift | 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->stateIndex = $stateIndex;
$this->stateRow = $this->table->getRow($stateIndex);
} | php | 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->stateIndex = $stateIndex;
$this->stateRow = $this->table->getRow($stateIndex);
} | [
"public",
"function",
"shift",
"(",
"TreeNodeInterface",
"$",
"node",
",",
"int",
"$",
"stateIndex",
")",
":",
"void",
"{",
"$",
"item",
"=",
"new",
"StackItem",
"(",
")",
";",
"$",
"item",
"->",
"state",
"=",
"$",
"stateIndex",
";",
"$",
"item",
"->... | Perform a Shift of a node into the stack
@param TreeNodeInterface $node Node to add into the stack
@param int $stateIndex Next state index to switch to
@throws AbortParsingException | [
"Perform",
"a",
"Shift",
"of",
"a",
"node",
"into",
"the",
"stack"
] | 2aaf29054129bb70167c0cc278a401ef933e87ce | https://github.com/Vovan-VE/parser/blob/2aaf29054129bb70167c0cc278a401ef933e87ce/src/stack/Stack.php#L71-L84 | train |
Vovan-VE/parser | src/stack/Stack.php | Stack.reduce | 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 new InternalException('Not enough items in stack');
}
$nodes = [];
$offset = null;
$reduce_items = array_slice($this->items, -$reduce_count);
foreach ($rule->getDefinition() as $i => $symbol) {
$item = $reduce_items[$i];
if ($item->node->getNodeName() !== $symbol->getName()) {
throw new InternalException('Unexpected stack content');
}
if (!$symbol->isHidden()) {
$nodes[] = $item->node;
}
if (null === $offset) {
$offset = $item->node->getOffset();
}
}
$base_state_index = ($total_count > $reduce_count)
? $this->items[$total_count - 1 - $reduce_count]->state
: 0;
$base_state_row = $this->table->getRow($base_state_index);
$new_symbol_name = $rule->getSubject()->getName();
$new_node = new NonTerminal($new_symbol_name, $nodes, $rule->getTag(), $offset);
$goto = $base_state_row->gotoSwitches;
if (!isset($goto[$new_symbol_name])) {
throw new InternalException('No required state in GOTO table');
}
$next_state = $goto[$new_symbol_name];
array_splice($this->items, -$reduce_count);
$this->shift($new_node, $next_state);
} | php | 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 new InternalException('Not enough items in stack');
}
$nodes = [];
$offset = null;
$reduce_items = array_slice($this->items, -$reduce_count);
foreach ($rule->getDefinition() as $i => $symbol) {
$item = $reduce_items[$i];
if ($item->node->getNodeName() !== $symbol->getName()) {
throw new InternalException('Unexpected stack content');
}
if (!$symbol->isHidden()) {
$nodes[] = $item->node;
}
if (null === $offset) {
$offset = $item->node->getOffset();
}
}
$base_state_index = ($total_count > $reduce_count)
? $this->items[$total_count - 1 - $reduce_count]->state
: 0;
$base_state_row = $this->table->getRow($base_state_index);
$new_symbol_name = $rule->getSubject()->getName();
$new_node = new NonTerminal($new_symbol_name, $nodes, $rule->getTag(), $offset);
$goto = $base_state_row->gotoSwitches;
if (!isset($goto[$new_symbol_name])) {
throw new InternalException('No required state in GOTO table');
}
$next_state = $goto[$new_symbol_name];
array_splice($this->items, -$reduce_count);
$this->shift($new_node, $next_state);
} | [
"public",
"function",
"reduce",
"(",
")",
":",
"void",
"{",
"$",
"rule",
"=",
"$",
"this",
"->",
"stateRow",
"->",
"reduceRule",
";",
"if",
"(",
"!",
"$",
"rule",
")",
"{",
"throw",
"new",
"NoReduceException",
"(",
")",
";",
"}",
"$",
"reduce_count",... | Perform the Reduce
@throws NoReduceException No rule to reduce by in the current state
@throws InternalException Internal package error
@throws AbortParsingException | [
"Perform",
"the",
"Reduce"
] | 2aaf29054129bb70167c0cc278a401ef933e87ce | https://github.com/Vovan-VE/parser/blob/2aaf29054129bb70167c0cc278a401ef933e87ce/src/stack/Stack.php#L92-L138 | train |
gabrielqs/Magento2-Installments | Model/QuoteManager.php | QuoteManager.setInstallmentDataBeforeAuthorization | 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 */
$quote = $this->_getQuote();
$interestRate = $this->_getCalculator()->getInterestRateForInstallment($installmentQuantity);
$interestAmount = $this->_getCalculator()->getInterestAmount($this->_getPaymentAmount(), $installmentQuantity);
$baseinterestAmount = $this->_getCalculator()
->getInterestAmount($this->_getBasePaymentAmount(), $installmentQuantity);
$quote
->setGabrielqsInstallmentsQty($installmentQuantity)
->setGabrielqsInstallmentsInterestRate($interestRate)
->setGabrielqsInstallmentsInterestAmount($interestAmount)
->setBaseGabrielqsInstallmentsInterestAmount($baseinterestAmount)
->setTotalsCollectedFlag(false)
->collectTotals();
} | php | 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 */
$quote = $this->_getQuote();
$interestRate = $this->_getCalculator()->getInterestRateForInstallment($installmentQuantity);
$interestAmount = $this->_getCalculator()->getInterestAmount($this->_getPaymentAmount(), $installmentQuantity);
$baseinterestAmount = $this->_getCalculator()
->getInterestAmount($this->_getBasePaymentAmount(), $installmentQuantity);
$quote
->setGabrielqsInstallmentsQty($installmentQuantity)
->setGabrielqsInstallmentsInterestRate($interestRate)
->setGabrielqsInstallmentsInterestAmount($interestAmount)
->setBaseGabrielqsInstallmentsInterestAmount($baseinterestAmount)
->setTotalsCollectedFlag(false)
->collectTotals();
} | [
"public",
"function",
"setInstallmentDataBeforeAuthorization",
"(",
"$",
"installmentQuantity",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_calculator",
"===",
"null",
")",
"{",
"throw",
"new",
"LocalizedException",
"(",
"new",
"Phrase",
"(",
"'You need to set an inst... | Sets interest info on order object with help from the installments order manager class
@param int $installmentQuantity
@return void
@throws LocalizedException | [
"Sets",
"interest",
"info",
"on",
"order",
"object",
"with",
"help",
"from",
"the",
"installments",
"order",
"manager",
"class"
] | cee656c8e48c852f7bc658916ec2e5e74f999157 | https://github.com/gabrielqs/Magento2-Installments/blob/cee656c8e48c852f7bc658916ec2e5e74f999157/Model/QuoteManager.php#L90-L111 | train |
gabrielqs/Magento2-Installments | Model/Calculator.php | Calculator.getInstallmentConfig | public function getInstallmentConfig()
{
$installmentConfig = $this->_dataObjectFactory->create();
$maxInstallmentQty = $this->getMaximumInstallmentQuantity();
$installmentConfig->maximumInstallmentQty = $maxInstallmentQty;
$installmentConfig->minimumInstallmentAmount = $this->getMinimumInstallmentAmount();
$installmentConfig->interestRate = $this->getInterestRate();
$installments = [];
# Looping through all possible installment values
for ($curInstallment = 1; ($curInstallment <= 12 && $curInstallment <= $maxInstallmentQty); $curInstallment++) {
if ($curInstallment === 1) {
# If this is a one time payment, we use the current value and only one installment, no interest
$installments[$curInstallment] = $this->_dataObjectFactory->create();
$installments[$curInstallment]->interestRate = $this->getInterestRateForInstallment($curInstallment);
$installments[$curInstallment]->numberInstallments = 1;
$installments[$curInstallment]->minimumAmountNoInterest = null;
continue;
} else {
$installments[$curInstallment] = $this->_dataObjectFactory->create();
$installments[$curInstallment]->interestRate = $this->getInterestRateForInstallment($curInstallment);
$installments[$curInstallment]->numberInstallments = $curInstallment;
$installments[$curInstallment]->minimumAmountNoInterest =
$this->getMinimumAmountNoInterest($curInstallment);
}
}
$installmentConfig->installments = $installments;
return $installmentConfig;
} | php | public function getInstallmentConfig()
{
$installmentConfig = $this->_dataObjectFactory->create();
$maxInstallmentQty = $this->getMaximumInstallmentQuantity();
$installmentConfig->maximumInstallmentQty = $maxInstallmentQty;
$installmentConfig->minimumInstallmentAmount = $this->getMinimumInstallmentAmount();
$installmentConfig->interestRate = $this->getInterestRate();
$installments = [];
# Looping through all possible installment values
for ($curInstallment = 1; ($curInstallment <= 12 && $curInstallment <= $maxInstallmentQty); $curInstallment++) {
if ($curInstallment === 1) {
# If this is a one time payment, we use the current value and only one installment, no interest
$installments[$curInstallment] = $this->_dataObjectFactory->create();
$installments[$curInstallment]->interestRate = $this->getInterestRateForInstallment($curInstallment);
$installments[$curInstallment]->numberInstallments = 1;
$installments[$curInstallment]->minimumAmountNoInterest = null;
continue;
} else {
$installments[$curInstallment] = $this->_dataObjectFactory->create();
$installments[$curInstallment]->interestRate = $this->getInterestRateForInstallment($curInstallment);
$installments[$curInstallment]->numberInstallments = $curInstallment;
$installments[$curInstallment]->minimumAmountNoInterest =
$this->getMinimumAmountNoInterest($curInstallment);
}
}
$installmentConfig->installments = $installments;
return $installmentConfig;
} | [
"public",
"function",
"getInstallmentConfig",
"(",
")",
"{",
"$",
"installmentConfig",
"=",
"$",
"this",
"->",
"_dataObjectFactory",
"->",
"create",
"(",
")",
";",
"$",
"maxInstallmentQty",
"=",
"$",
"this",
"->",
"getMaximumInstallmentQuantity",
"(",
")",
";",
... | Returns all the information that another class might need to compute interest rates and installments
@return DataObject | [
"Returns",
"all",
"the",
"information",
"that",
"another",
"class",
"might",
"need",
"to",
"compute",
"interest",
"rates",
"and",
"installments"
] | cee656c8e48c852f7bc658916ec2e5e74f999157 | https://github.com/gabrielqs/Magento2-Installments/blob/cee656c8e48c852f7bc658916ec2e5e74f999157/Model/Calculator.php#L68-L100 | train |
gabrielqs/Magento2-Installments | Model/Calculator.php | Calculator.getInstallments | public function getInstallments($paymentAmount)
{
$installments = [];
$this->setPaymentAmount($paymentAmount);
$maxInstallmentQty = $this->getMaximumInstallmentQuantity();
# Looping through all possible installment values
for ($curInstallment = 1; ($curInstallment <= 12 && $curInstallment <= $maxInstallmentQty); $curInstallment++) {
if ($curInstallment === 1) {
# If this is a one time payment, we use the current value and only one installment, no interest
$installments[$curInstallment] = $this->_dataObjectFactory->create();
$installments[$curInstallment]->installmentValue = $paymentAmount;
$installments[$curInstallment]->numberInstallments = 1;
$installments[$curInstallment]->interestsApplied = false;
continue;
} else {
$totalAmountAfterInterest = $this->getTotalAmountAfterInterest($curInstallment);
$amountPerInstallment = $totalAmountAfterInterest / $curInstallment;
# If the total per installment is less then the minimum installment amount, we won't
# include this installment
$minimumInstallmentAmount = $this->getMinimumInstallmentAmount();
if ($amountPerInstallment < $minimumInstallmentAmount) {
continue;
}
$installments[$curInstallment] = $this->_dataObjectFactory->create();
$installments[$curInstallment]->installmentValue = $amountPerInstallment;
$installments[$curInstallment]->numberInstallments = $curInstallment;
$installments[$curInstallment]->interestsApplied = $this->isApplyInterest($curInstallment);
}
}
return (array) $installments;
} | php | public function getInstallments($paymentAmount)
{
$installments = [];
$this->setPaymentAmount($paymentAmount);
$maxInstallmentQty = $this->getMaximumInstallmentQuantity();
# Looping through all possible installment values
for ($curInstallment = 1; ($curInstallment <= 12 && $curInstallment <= $maxInstallmentQty); $curInstallment++) {
if ($curInstallment === 1) {
# If this is a one time payment, we use the current value and only one installment, no interest
$installments[$curInstallment] = $this->_dataObjectFactory->create();
$installments[$curInstallment]->installmentValue = $paymentAmount;
$installments[$curInstallment]->numberInstallments = 1;
$installments[$curInstallment]->interestsApplied = false;
continue;
} else {
$totalAmountAfterInterest = $this->getTotalAmountAfterInterest($curInstallment);
$amountPerInstallment = $totalAmountAfterInterest / $curInstallment;
# If the total per installment is less then the minimum installment amount, we won't
# include this installment
$minimumInstallmentAmount = $this->getMinimumInstallmentAmount();
if ($amountPerInstallment < $minimumInstallmentAmount) {
continue;
}
$installments[$curInstallment] = $this->_dataObjectFactory->create();
$installments[$curInstallment]->installmentValue = $amountPerInstallment;
$installments[$curInstallment]->numberInstallments = $curInstallment;
$installments[$curInstallment]->interestsApplied = $this->isApplyInterest($curInstallment);
}
}
return (array) $installments;
} | [
"public",
"function",
"getInstallments",
"(",
"$",
"paymentAmount",
")",
"{",
"$",
"installments",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"setPaymentAmount",
"(",
"$",
"paymentAmount",
")",
";",
"$",
"maxInstallmentQty",
"=",
"$",
"this",
"->",
"getMaximumIn... | Computes the installments for a given payment amount
@param float $paymentAmount
@return DataObject[] | [
"Computes",
"the",
"installments",
"for",
"a",
"given",
"payment",
"amount"
] | cee656c8e48c852f7bc658916ec2e5e74f999157 | https://github.com/gabrielqs/Magento2-Installments/blob/cee656c8e48c852f7bc658916ec2e5e74f999157/Model/Calculator.php#L107-L144 | train |
gabrielqs/Magento2-Installments | Model/Calculator.php | Calculator.getInterestAmount | public function getInterestAmount($amount, $installmentQuantity)
{
$minimumAmountNoInterest = $this->getMinimumAmountNoInterest($installmentQuantity);
if (
($minimumAmountNoInterest === null) ||
($minimumAmountNoInterest !== null) && ($amount < $minimumAmountNoInterest)
) {
$interestRateForInstallment = $this->getInterestRateForInstallment($installmentQuantity);
} else {
$interestRateForInstallment = 1;
}
$totalInstallmentAmount = $interestRateForInstallment * $amount;
return ($totalInstallmentAmount - $amount);
} | php | public function getInterestAmount($amount, $installmentQuantity)
{
$minimumAmountNoInterest = $this->getMinimumAmountNoInterest($installmentQuantity);
if (
($minimumAmountNoInterest === null) ||
($minimumAmountNoInterest !== null) && ($amount < $minimumAmountNoInterest)
) {
$interestRateForInstallment = $this->getInterestRateForInstallment($installmentQuantity);
} else {
$interestRateForInstallment = 1;
}
$totalInstallmentAmount = $interestRateForInstallment * $amount;
return ($totalInstallmentAmount - $amount);
} | [
"public",
"function",
"getInterestAmount",
"(",
"$",
"amount",
",",
"$",
"installmentQuantity",
")",
"{",
"$",
"minimumAmountNoInterest",
"=",
"$",
"this",
"->",
"getMinimumAmountNoInterest",
"(",
"$",
"installmentQuantity",
")",
";",
"if",
"(",
"(",
"$",
"minim... | Returns the interest fee for a given amount and interest rate
@param float $amount
@param int $installmentQuantity
@return float | [
"Returns",
"the",
"interest",
"fee",
"for",
"a",
"given",
"amount",
"and",
"interest",
"rate"
] | cee656c8e48c852f7bc658916ec2e5e74f999157 | https://github.com/gabrielqs/Magento2-Installments/blob/cee656c8e48c852f7bc658916ec2e5e74f999157/Model/Calculator.php#L152-L168 | train |
gabrielqs/Magento2-Installments | Model/Calculator.php | Calculator.getInterestRateForInstallment | public function getInterestRateForInstallment($installments)
{
$interestRate = $this->getInterestRate();
$computationInstallments = ($installments - 1);
$totalInterestRate = (float) pow($interestRate, $computationInstallments);
return $totalInterestRate;
} | php | public function getInterestRateForInstallment($installments)
{
$interestRate = $this->getInterestRate();
$computationInstallments = ($installments - 1);
$totalInterestRate = (float) pow($interestRate, $computationInstallments);
return $totalInterestRate;
} | [
"public",
"function",
"getInterestRateForInstallment",
"(",
"$",
"installments",
")",
"{",
"$",
"interestRate",
"=",
"$",
"this",
"->",
"getInterestRate",
"(",
")",
";",
"$",
"computationInstallments",
"=",
"(",
"$",
"installments",
"-",
"1",
")",
";",
"$",
... | Given a number of installments, returns the total interest rate do be applied
@param int $installments
@return float | [
"Given",
"a",
"number",
"of",
"installments",
"returns",
"the",
"total",
"interest",
"rate",
"do",
"be",
"applied"
] | cee656c8e48c852f7bc658916ec2e5e74f999157 | https://github.com/gabrielqs/Magento2-Installments/blob/cee656c8e48c852f7bc658916ec2e5e74f999157/Model/Calculator.php#L184-L190 | train |
gabrielqs/Magento2-Installments | Model/Calculator.php | Calculator.getMinimumAmountNoInterest | public function getMinimumAmountNoInterest($installments)
{
$return = null;
foreach ($this->_minimumAmountNoInterest as $installmentQty => $minOrderValue) {
if ($installmentQty == $installments) {
$return = (float) $minOrderValue;
break;
}
}
return $return;
} | php | public function getMinimumAmountNoInterest($installments)
{
$return = null;
foreach ($this->_minimumAmountNoInterest as $installmentQty => $minOrderValue) {
if ($installmentQty == $installments) {
$return = (float) $minOrderValue;
break;
}
}
return $return;
} | [
"public",
"function",
"getMinimumAmountNoInterest",
"(",
"$",
"installments",
")",
"{",
"$",
"return",
"=",
"null",
";",
"foreach",
"(",
"$",
"this",
"->",
"_minimumAmountNoInterest",
"as",
"$",
"installmentQty",
"=>",
"$",
"minOrderValue",
")",
"{",
"if",
"("... | Gets the minimum amount for which, in the specified installment qty, no interest should apply
@param int $installments
@return float|null | [
"Gets",
"the",
"minimum",
"amount",
"for",
"which",
"in",
"the",
"specified",
"installment",
"qty",
"no",
"interest",
"should",
"apply"
] | cee656c8e48c852f7bc658916ec2e5e74f999157 | https://github.com/gabrielqs/Magento2-Installments/blob/cee656c8e48c852f7bc658916ec2e5e74f999157/Model/Calculator.php#L206-L218 | train |
gabrielqs/Magento2-Installments | Model/Calculator.php | Calculator.getTotalAmountAfterInterest | public function getTotalAmountAfterInterest($installments)
{
$return = $amount = $this->getPaymentAmount();
if ($this->isApplyInterest($installments)) {
$return = ($amount) * $this->getInterestRateForInstallment($installments);
}
return $return;
} | php | public function getTotalAmountAfterInterest($installments)
{
$return = $amount = $this->getPaymentAmount();
if ($this->isApplyInterest($installments)) {
$return = ($amount) * $this->getInterestRateForInstallment($installments);
}
return $return;
} | [
"public",
"function",
"getTotalAmountAfterInterest",
"(",
"$",
"installments",
")",
"{",
"$",
"return",
"=",
"$",
"amount",
"=",
"$",
"this",
"->",
"getPaymentAmount",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isApplyInterest",
"(",
"$",
"installments",
... | Computes the maximum amount after interest is applied
@param int $installments
@return float | [
"Computes",
"the",
"maximum",
"amount",
"after",
"interest",
"is",
"applied"
] | cee656c8e48c852f7bc658916ec2e5e74f999157 | https://github.com/gabrielqs/Magento2-Installments/blob/cee656c8e48c852f7bc658916ec2e5e74f999157/Model/Calculator.php#L243-L252 | train |
gabrielqs/Magento2-Installments | Model/Calculator.php | Calculator.isApplyInterest | 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 is defined, interest will always be
# applied, except when the payment total is higher than the minimum order value for no interest setting
$minimumOrderValueNoInterest = $this->getMinimumAmountNoInterest($installments);
if ( ($paymentAmount > $minimumOrderValueNoInterest) && ($minimumOrderValueNoInterest !== null) ) {
$return = false;
}
}
return $return;
} | php | 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 is defined, interest will always be
# applied, except when the payment total is higher than the minimum order value for no interest setting
$minimumOrderValueNoInterest = $this->getMinimumAmountNoInterest($installments);
if ( ($paymentAmount > $minimumOrderValueNoInterest) && ($minimumOrderValueNoInterest !== null) ) {
$return = false;
}
}
return $return;
} | [
"public",
"function",
"isApplyInterest",
"(",
"$",
"installments",
")",
"{",
"$",
"return",
"=",
"true",
";",
"$",
"interestRate",
"=",
"$",
"this",
"->",
"getInterestRate",
"(",
")",
";",
"$",
"paymentAmount",
"=",
"$",
"this",
"->",
"getPaymentAmount",
"... | Decides whether interest should be applied to the current payment
@param int $installments
@return bool $return | [
"Decides",
"whether",
"interest",
"should",
"be",
"applied",
"to",
"the",
"current",
"payment"
] | cee656c8e48c852f7bc658916ec2e5e74f999157 | https://github.com/gabrielqs/Magento2-Installments/blob/cee656c8e48c852f7bc658916ec2e5e74f999157/Model/Calculator.php#L259-L276 | train |
adamculp/api-consumer | src/ApiConsumer/Consumer.php | Consumer.reset | public function reset()
{
// clears the object entirely
$this->url = null;
$this->params = array();
$this->options = array();
$this->callType = null;
$this->responseType = null;
} | php | public function reset()
{
// clears the object entirely
$this->url = null;
$this->params = array();
$this->options = array();
$this->callType = null;
$this->responseType = null;
} | [
"public",
"function",
"reset",
"(",
")",
"{",
"// clears the object entirely",
"$",
"this",
"->",
"url",
"=",
"null",
";",
"$",
"this",
"->",
"params",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"options",
"=",
"array",
"(",
")",
";",
"$",
"this... | Resets all variables to prepare for fresh object creation if needed for
looping. | [
"Resets",
"all",
"variables",
"to",
"prepare",
"for",
"fresh",
"object",
"creation",
"if",
"needed",
"for",
"looping",
"."
] | 12b1a1d362e54952c0c2f2f62f1dbed99f09b688 | https://github.com/adamculp/api-consumer/blob/12b1a1d362e54952c0c2f2f62f1dbed99f09b688/src/ApiConsumer/Consumer.php#L57-L65 | train |
adamculp/api-consumer | src/ApiConsumer/Consumer.php | Consumer.setParams | 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 | 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;
}
}
} | [
"public",
"function",
"setParams",
"(",
"$",
"params",
")",
"{",
"// $param should be a single key => value pair",
"if",
"(",
"is_array",
"(",
"$",
"params",
")",
")",
"{",
"foreach",
"(",
"$",
"params",
"as",
"$",
"key",
"=>",
"$",
"param",
")",
"{",
"$",... | Expects an array of one or more key=>value pairs of params to later add
to the URL string
@param array $params | [
"Expects",
"an",
"array",
"of",
"one",
"or",
"more",
"key",
"=",
">",
"value",
"pairs",
"of",
"params",
"to",
"later",
"add",
"to",
"the",
"URL",
"string"
] | 12b1a1d362e54952c0c2f2f62f1dbed99f09b688 | https://github.com/adamculp/api-consumer/blob/12b1a1d362e54952c0c2f2f62f1dbed99f09b688/src/ApiConsumer/Consumer.php#L138-L146 | train |
adamculp/api-consumer | src/ApiConsumer/Consumer.php | Consumer.setOptions | 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 | 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;
}
}
} | [
"public",
"function",
"setOptions",
"(",
"$",
"options",
")",
"{",
"// $param should be a single key => value pair",
"if",
"(",
"is_array",
"(",
"$",
"options",
")",
")",
"{",
"foreach",
"(",
"$",
"options",
"as",
"$",
"key",
"=>",
"$",
"option",
")",
"{",
... | Expects an array of one or more key=>value pairs of params to later use
as options with curl to alter the way curl is used.
To view a list of potential curl options see: http://php.net/manual/en/function.curl-setopt.php
NOTE: The curl option($key) should not be passed as a string.
@param array $options | [
"Expects",
"an",
"array",
"of",
"one",
"or",
"more",
"key",
"=",
">",
"value",
"pairs",
"of",
"params",
"to",
"later",
"use",
"as",
"options",
"with",
"curl",
"to",
"alter",
"the",
"way",
"curl",
"is",
"used",
"."
] | 12b1a1d362e54952c0c2f2f62f1dbed99f09b688 | https://github.com/adamculp/api-consumer/blob/12b1a1d362e54952c0c2f2f62f1dbed99f09b688/src/ApiConsumer/Consumer.php#L168-L176 | train |
adamculp/api-consumer | src/ApiConsumer/Consumer.php | Consumer.doApiCall | public function doApiCall()
{
$parsedResponse = array();
$jsonResponse = false;
$curlUrl = $this->createUrl();
if ($curlUrl) {
$jsonResponse = $this->submitCurlRequest($curlUrl);
}
if ($jsonResponse) {
$parsedResponse = $this->parseJsonResponse($jsonResponse);
}
return $parsedResponse;
} | php | public function doApiCall()
{
$parsedResponse = array();
$jsonResponse = false;
$curlUrl = $this->createUrl();
if ($curlUrl) {
$jsonResponse = $this->submitCurlRequest($curlUrl);
}
if ($jsonResponse) {
$parsedResponse = $this->parseJsonResponse($jsonResponse);
}
return $parsedResponse;
} | [
"public",
"function",
"doApiCall",
"(",
")",
"{",
"$",
"parsedResponse",
"=",
"array",
"(",
")",
";",
"$",
"jsonResponse",
"=",
"false",
";",
"$",
"curlUrl",
"=",
"$",
"this",
"->",
"createUrl",
"(",
")",
";",
"if",
"(",
"$",
"curlUrl",
")",
"{",
"... | This is a wrapper to execute the entire process of an API call. It initiates
the creation of the URL, and using the returned URL it initiates the curl
request, and the resulting JSON is then sent to the parser. The end result
is a usable array.
@return array | [
"This",
"is",
"a",
"wrapper",
"to",
"execute",
"the",
"entire",
"process",
"of",
"an",
"API",
"call",
".",
"It",
"initiates",
"the",
"creation",
"of",
"the",
"URL",
"and",
"using",
"the",
"returned",
"URL",
"it",
"initiates",
"the",
"curl",
"request",
"a... | 12b1a1d362e54952c0c2f2f62f1dbed99f09b688 | https://github.com/adamculp/api-consumer/blob/12b1a1d362e54952c0c2f2f62f1dbed99f09b688/src/ApiConsumer/Consumer.php#L196-L212 | train |
adamculp/api-consumer | src/ApiConsumer/Consumer.php | Consumer.createUrl | public function createUrl()
{
$curlUrl = $this->url . '?';
foreach ($this->params as $key => $value) {
$curlUrl .= $key . '=' . $value;
$curlUrl .= '&';
}
return $curlUrl;
} | php | public function createUrl()
{
$curlUrl = $this->url . '?';
foreach ($this->params as $key => $value) {
$curlUrl .= $key . '=' . $value;
$curlUrl .= '&';
}
return $curlUrl;
} | [
"public",
"function",
"createUrl",
"(",
")",
"{",
"$",
"curlUrl",
"=",
"$",
"this",
"->",
"url",
".",
"'?'",
";",
"foreach",
"(",
"$",
"this",
"->",
"params",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"curlUrl",
".=",
"$",
"key",
".",
... | Create the URL string, complete with any params.
@return string | [
"Create",
"the",
"URL",
"string",
"complete",
"with",
"any",
"params",
"."
] | 12b1a1d362e54952c0c2f2f62f1dbed99f09b688 | https://github.com/adamculp/api-consumer/blob/12b1a1d362e54952c0c2f2f62f1dbed99f09b688/src/ApiConsumer/Consumer.php#L219-L229 | train |
adamculp/api-consumer | src/ApiConsumer/Consumer.php | Consumer.submitCurlRequest | 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)) {
foreach ($this->options as $key => $value) {
curl_setopt($session, $key, $value);
}
}
$rawResponse = curl_exec($session);
curl_close($session);
return $rawResponse;
} | php | 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)) {
foreach ($this->options as $key => $value) {
curl_setopt($session, $key, $value);
}
}
$rawResponse = curl_exec($session);
curl_close($session);
return $rawResponse;
} | [
"protected",
"function",
"submitCurlRequest",
"(",
"$",
"curlUrl",
")",
"{",
"$",
"session",
"=",
"curl_init",
"(",
")",
";",
"curl_setopt",
"(",
"$",
"session",
",",
"CURLOPT_URL",
",",
"$",
"curlUrl",
")",
";",
"curl_setopt",
"(",
"$",
"session",
",",
... | Build the curl resource and execute it, to return the raw result.
@param string $curlUrl
@return mixed | [
"Build",
"the",
"curl",
"resource",
"and",
"execute",
"it",
"to",
"return",
"the",
"raw",
"result",
"."
] | 12b1a1d362e54952c0c2f2f62f1dbed99f09b688 | https://github.com/adamculp/api-consumer/blob/12b1a1d362e54952c0c2f2f62f1dbed99f09b688/src/ApiConsumer/Consumer.php#L237-L256 | train |
asposeforcloud/Aspose_Cloud_SDK_For_PHP | src/Aspose/Cloud/Common/Utils.php | Utils.processCommand | 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: processCommand called", array(
'url' => $url,
'method' => $method,
'headerType' => $headerType,
'src' => $src,
'returnType' => $returnType,
));
$session = curl_init();
curl_setopt($session, CURLOPT_URL, $url);
if ($method == 'GET') {
curl_setopt($session, CURLOPT_HTTPGET, 1);
} else {
curl_setopt($session, CURLOPT_POST, 1);
curl_setopt($session, CURLOPT_POSTFIELDS, $src);
curl_setopt($session, CURLOPT_CUSTOMREQUEST, $method);
}
curl_setopt($session, CURLOPT_HEADER, false);
if ($headerType == 'XML') {
curl_setopt($session, CURLOPT_HTTPHEADER, array('Accept: application/' . $returnType . '', 'Content-Type: application/xml', 'x-aspose-client: PHPSDK/v1.0'));
} else {
curl_setopt($session, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'x-aspose-client: PHPSDK/v1.0'));
}
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
if (preg_match('/^(https)/i', $url))
curl_setopt($session, CURLOPT_SSL_VERIFYPEER, false);
// Allow users to register curl options before the call is executed
$event = new ProcessCommandEvent($session);
$dispatcher->dispatch(ProcessCommandEvent::PRE_CURL, $event);
$result = curl_exec($session);
$headers = curl_getinfo($session);
if (substr($headers['http_code'], 0, 1) != '2') {
if (curl_errno($session) !== 0) {
throw new AsposeCurlException(curl_strerror(curl_errno($session)), $headers, curl_errno($session));
AsposeApp::getLogger()->warning(curl_strerror(curl_errno($session)));
} else {
throw new Exception($result);
AsposeApp::getLogger()->warning($result);
}
} else {
if (preg_match('/You have processed/i', $result) || preg_match('/Your pricing plan allows only/i', $result)) {
AsposeApp::getLogger()->alert($result);
throw new Exception($result);
}
}
// Allow users to alter the result
$event = new ProcessCommandEvent($session, $result);
/** @var ProcessCommandEvent $dispatchedEvent */
$dispatchedEvent = $dispatcher->dispatch(ProcessCommandEvent::POST_CURL, $event);
curl_close($session);
// TODO test or the Event result needs to be returned in case an listener was triggered
return $dispatchedEvent->getResult();
} | php | 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: processCommand called", array(
'url' => $url,
'method' => $method,
'headerType' => $headerType,
'src' => $src,
'returnType' => $returnType,
));
$session = curl_init();
curl_setopt($session, CURLOPT_URL, $url);
if ($method == 'GET') {
curl_setopt($session, CURLOPT_HTTPGET, 1);
} else {
curl_setopt($session, CURLOPT_POST, 1);
curl_setopt($session, CURLOPT_POSTFIELDS, $src);
curl_setopt($session, CURLOPT_CUSTOMREQUEST, $method);
}
curl_setopt($session, CURLOPT_HEADER, false);
if ($headerType == 'XML') {
curl_setopt($session, CURLOPT_HTTPHEADER, array('Accept: application/' . $returnType . '', 'Content-Type: application/xml', 'x-aspose-client: PHPSDK/v1.0'));
} else {
curl_setopt($session, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'x-aspose-client: PHPSDK/v1.0'));
}
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
if (preg_match('/^(https)/i', $url))
curl_setopt($session, CURLOPT_SSL_VERIFYPEER, false);
// Allow users to register curl options before the call is executed
$event = new ProcessCommandEvent($session);
$dispatcher->dispatch(ProcessCommandEvent::PRE_CURL, $event);
$result = curl_exec($session);
$headers = curl_getinfo($session);
if (substr($headers['http_code'], 0, 1) != '2') {
if (curl_errno($session) !== 0) {
throw new AsposeCurlException(curl_strerror(curl_errno($session)), $headers, curl_errno($session));
AsposeApp::getLogger()->warning(curl_strerror(curl_errno($session)));
} else {
throw new Exception($result);
AsposeApp::getLogger()->warning($result);
}
} else {
if (preg_match('/You have processed/i', $result) || preg_match('/Your pricing plan allows only/i', $result)) {
AsposeApp::getLogger()->alert($result);
throw new Exception($result);
}
}
// Allow users to alter the result
$event = new ProcessCommandEvent($session, $result);
/** @var ProcessCommandEvent $dispatchedEvent */
$dispatchedEvent = $dispatcher->dispatch(ProcessCommandEvent::POST_CURL, $event);
curl_close($session);
// TODO test or the Event result needs to be returned in case an listener was triggered
return $dispatchedEvent->getResult();
} | [
"public",
"static",
"function",
"processCommand",
"(",
"$",
"url",
",",
"$",
"method",
"=",
"'GET'",
",",
"$",
"headerType",
"=",
"'XML'",
",",
"$",
"src",
"=",
"''",
",",
"$",
"returnType",
"=",
"'xml'",
")",
"{",
"$",
"dispatcher",
"=",
"AsposeApp",
... | Performs Aspose Api Request.
@param string $url Target Aspose API URL.
@param string $method Method to access the API such as GET, POST, PUT and DELETE
@param string $headerType XML or JSON
@param string $src Post data.
@param string $returnType
@return string
@throws Exception | [
"Performs",
"Aspose",
"Api",
"Request",
"."
] | 4950f2f2d24c9a101bf8e0a552d3801c251adac0 | https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_PHP/blob/4950f2f2d24c9a101bf8e0a552d3801c251adac0/src/Aspose/Cloud/Common/Utils.php#L95-L164 | train |
asposeforcloud/Aspose_Cloud_SDK_For_PHP | src/Aspose/Cloud/Common/Utils.php | Utils.uploadFileBinary | 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,
'localFile' => $localFile,
'headerType' => $headerType,
'method' => $method,
));
$fp = fopen($localFile, 'r');
$session = curl_init();
curl_setopt($session, CURLOPT_VERBOSE, 1);
curl_setopt($session, CURLOPT_USERPWD, 'user:password');
curl_setopt($session, CURLOPT_URL, $url);
if ($method == 'PUT') {
curl_setopt($session, CURLOPT_PUT, 1);
} else {
curl_setopt($session, CURLOPT_UPLOAD, true);
curl_setopt($session, CURLOPT_CUSTOMREQUEST, 'POST');
}
curl_setopt($session, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($session, CURLOPT_HEADER, false);
if ($headerType == 'XML') {
curl_setopt($session, CURLOPT_HTTPHEADER, array('Accept: application/xml', 'Content-Type: application/xml', 'x-aspose-client: PHPSDK/v1.0'));
} else {
curl_setopt($session, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'x-aspose-client: PHPSDK/v1.0'));
}
curl_setopt($session, CURLOPT_INFILE, $fp);
curl_setopt($session, CURLOPT_INFILESIZE, filesize($localFile));
$result = curl_exec($session);
curl_close($session);
fclose($fp);
return $result;
} | php | 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,
'localFile' => $localFile,
'headerType' => $headerType,
'method' => $method,
));
$fp = fopen($localFile, 'r');
$session = curl_init();
curl_setopt($session, CURLOPT_VERBOSE, 1);
curl_setopt($session, CURLOPT_USERPWD, 'user:password');
curl_setopt($session, CURLOPT_URL, $url);
if ($method == 'PUT') {
curl_setopt($session, CURLOPT_PUT, 1);
} else {
curl_setopt($session, CURLOPT_UPLOAD, true);
curl_setopt($session, CURLOPT_CUSTOMREQUEST, 'POST');
}
curl_setopt($session, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($session, CURLOPT_HEADER, false);
if ($headerType == 'XML') {
curl_setopt($session, CURLOPT_HTTPHEADER, array('Accept: application/xml', 'Content-Type: application/xml', 'x-aspose-client: PHPSDK/v1.0'));
} else {
curl_setopt($session, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'x-aspose-client: PHPSDK/v1.0'));
}
curl_setopt($session, CURLOPT_INFILE, $fp);
curl_setopt($session, CURLOPT_INFILESIZE, filesize($localFile));
$result = curl_exec($session);
curl_close($session);
fclose($fp);
return $result;
} | [
"public",
"static",
"function",
"uploadFileBinary",
"(",
"$",
"url",
",",
"$",
"localFile",
",",
"$",
"headerType",
"=",
"'XML'",
",",
"$",
"method",
"=",
"'PUT'",
")",
"{",
"$",
"method",
"=",
"strtoupper",
"(",
"$",
"method",
")",
";",
"$",
"headerTy... | Performs Aspose Api Request to Upload a file.
@param string $url Target Aspose API URL.
@param string $localFile Local file
@param string $headerType XML or JSON
@param string $method
@return mixed | [
"Performs",
"Aspose",
"Api",
"Request",
"to",
"Upload",
"a",
"file",
"."
] | 4950f2f2d24c9a101bf8e0a552d3801c251adac0 | https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_PHP/blob/4950f2f2d24c9a101bf8e0a552d3801c251adac0/src/Aspose/Cloud/Common/Utils.php#L175-L211 | train |
asposeforcloud/Aspose_Cloud_SDK_For_PHP | src/Aspose/Cloud/Common/Utils.php | Utils.saveFile | public static function saveFile($input, $fileName)
{
$fh = fopen($fileName, 'w') or die('cant open file');
fwrite($fh, $input);
fclose($fh);
} | php | public static function saveFile($input, $fileName)
{
$fh = fopen($fileName, 'w') or die('cant open file');
fwrite($fh, $input);
fclose($fh);
} | [
"public",
"static",
"function",
"saveFile",
"(",
"$",
"input",
",",
"$",
"fileName",
")",
"{",
"$",
"fh",
"=",
"fopen",
"(",
"$",
"fileName",
",",
"'w'",
")",
"or",
"die",
"(",
"'cant open file'",
")",
";",
"fwrite",
"(",
"$",
"fh",
",",
"$",
"inpu... | Saves the files
@param string $input input stream.
@param string $fileName fileName along with the full path. | [
"Saves",
"the",
"files"
] | 4950f2f2d24c9a101bf8e0a552d3801c251adac0 | https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_PHP/blob/4950f2f2d24c9a101bf8e0a552d3801c251adac0/src/Aspose/Cloud/Common/Utils.php#L265-L270 | train |
asposeforcloud/Aspose_Cloud_SDK_For_PHP | src/Aspose/Cloud/Common/Utils.php | Utils.getFieldCount | public function getFieldCount($jsonResponse, $fieldName)
{
$arr = json_decode($jsonResponse)->{$fieldName};
return count($arr, COUNT_RECURSIVE);
} | php | public function getFieldCount($jsonResponse, $fieldName)
{
$arr = json_decode($jsonResponse)->{$fieldName};
return count($arr, COUNT_RECURSIVE);
} | [
"public",
"function",
"getFieldCount",
"(",
"$",
"jsonResponse",
",",
"$",
"fieldName",
")",
"{",
"$",
"arr",
"=",
"json_decode",
"(",
"$",
"jsonResponse",
")",
"->",
"{",
"$",
"fieldName",
"}",
";",
"return",
"count",
"(",
"$",
"arr",
",",
"COUNT_RECURS... | This method parses XML for a count of a particular field.
@param string $jsonResponse JSON Response string.
@param string $fieldName Field to be found.
@return getFieldCount($jsonResponse, $fieldName) - String Value of the given Field. | [
"This",
"method",
"parses",
"XML",
"for",
"a",
"count",
"of",
"a",
"particular",
"field",
"."
] | 4950f2f2d24c9a101bf8e0a552d3801c251adac0 | https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_PHP/blob/4950f2f2d24c9a101bf8e0a552d3801c251adac0/src/Aspose/Cloud/Common/Utils.php#L341-L345 | train |
botman/driver-wechat | src/WeChatVideoDriver.php | WeChatVideoDriver.getVideo | 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 | 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)];
} | [
"private",
"function",
"getVideo",
"(",
")",
"{",
"$",
"videoUrl",
"=",
"'http://file.api.wechat.com/cgi-bin/media/get?access_token='",
".",
"$",
"this",
"->",
"getAccessToken",
"(",
")",
".",
"'&media_id='",
".",
"$",
"this",
"->",
"event",
"->",
"get",
"(",
"'... | Create the video url from an incoming message.
@return array | [
"Create",
"the",
"video",
"url",
"from",
"an",
"incoming",
"message",
"."
] | 8b621f2fc4b79f556fa936a78acf247307c040a2 | https://github.com/botman/driver-wechat/blob/8b621f2fc4b79f556fa936a78acf247307c040a2/src/WeChatVideoDriver.php#L47-L52 | train |
asposeforcloud/Aspose_Cloud_SDK_For_PHP | src/Aspose/Cloud/Barcode/BarCodeReader.php | BarcodeReader.read | 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);
//get response stream
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
//returns a list of extracted barcodes
return $json->Barcodes;
} | php | 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);
//get response stream
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
//returns a list of extracted barcodes
return $json->Barcodes;
} | [
"public",
"function",
"read",
"(",
"$",
"symbology",
")",
"{",
"//build URI to read barcode",
"$",
"strURI",
"=",
"Product",
"::",
"$",
"baseProductUri",
".",
"'/barcode/'",
".",
"$",
"this",
"->",
"getFileName",
"(",
")",
".",
"'/recognize?'",
".",
"(",
"!"... | Reads all or specific barcodes from images.
@param string $symbology Type of barcode.
@return array
@throws Exception | [
"Reads",
"all",
"or",
"specific",
"barcodes",
"from",
"images",
"."
] | 4950f2f2d24c9a101bf8e0a552d3801c251adac0 | https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_PHP/blob/4950f2f2d24c9a101bf8e0a552d3801c251adac0/src/Aspose/Cloud/Barcode/BarCodeReader.php#L30-L43 | train |
asposeforcloud/Aspose_Cloud_SDK_For_PHP | src/Aspose/Cloud/Barcode/BarCodeReader.php | BarcodeReader.readFromLocalImage | public function readFromLocalImage($localImage, $remoteFolder, $barcodeReadType)
{
$folder = new Folder();
$folder->UploadFile($localImage, $remoteFolder);
$data = $this->ReadR(basename($localImage), $remoteFolder, $barcodeReadType);
return $data;
} | php | public function readFromLocalImage($localImage, $remoteFolder, $barcodeReadType)
{
$folder = new Folder();
$folder->UploadFile($localImage, $remoteFolder);
$data = $this->ReadR(basename($localImage), $remoteFolder, $barcodeReadType);
return $data;
} | [
"public",
"function",
"readFromLocalImage",
"(",
"$",
"localImage",
",",
"$",
"remoteFolder",
",",
"$",
"barcodeReadType",
")",
"{",
"$",
"folder",
"=",
"new",
"Folder",
"(",
")",
";",
"$",
"folder",
"->",
"UploadFile",
"(",
"$",
"localImage",
",",
"$",
... | Read Barcode from Local Image.
@param string $localImage Path of the local image.
@param string $remoteFolder Name of the remote folder.
@param string $barcodeReadType Type to read barcode.
@return array
@throws Exception | [
"Read",
"Barcode",
"from",
"Local",
"Image",
"."
] | 4950f2f2d24c9a101bf8e0a552d3801c251adac0 | https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_PHP/blob/4950f2f2d24c9a101bf8e0a552d3801c251adac0/src/Aspose/Cloud/Barcode/BarCodeReader.php#L55-L61 | train |
asposeforcloud/Aspose_Cloud_SDK_For_PHP | src/Aspose/Cloud/Barcode/BarCodeReader.php | BarcodeReader.readR | 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);
return $json->Barcodes;
} | php | 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);
return $json->Barcodes;
} | [
"public",
"function",
"readR",
"(",
"$",
"remoteImageName",
",",
"$",
"remoteFolder",
",",
"$",
"readType",
")",
"{",
"$",
"uri",
"=",
"$",
"this",
"->",
"uriBuilder",
"(",
"$",
"remoteImageName",
",",
"$",
"remoteFolder",
",",
"$",
"readType",
")",
";",... | Read Barcode from Aspose Cloud Storage
@param string $remoteImageName Name of the remote image.
@param string $remoteFolder Name of the folder.
@param string $readType Type to read barcode.
@return array
@throws Exception | [
"Read",
"Barcode",
"from",
"Aspose",
"Cloud",
"Storage"
] | 4950f2f2d24c9a101bf8e0a552d3801c251adac0 | https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_PHP/blob/4950f2f2d24c9a101bf8e0a552d3801c251adac0/src/Aspose/Cloud/Barcode/BarCodeReader.php#L73-L81 | train |
asposeforcloud/Aspose_Cloud_SDK_For_PHP | src/Aspose/Cloud/Barcode/BarCodeReader.php | BarcodeReader.uriBuilder | public function uriBuilder($remoteImage, $remoteFolder, $readType)
{
$uri = Product::$baseProductUri . '/barcode/';
if ($remoteImage != null)
$uri .= $remoteImage . '/';
$uri .= 'recognize?';
if ($readType == 'AllSupportedTypes')
$uri .= 'type=';
else
$uri .= 'type=' . $readType;
if ($remoteFolder != null && trim($remoteFolder) === '')
$uri .= '&format=' . $remoteFolder;
if ($remoteFolder != null && trim($remoteFolder) === '')
$uri .= '&folder=' . $remoteFolder;
return $uri;
} | php | public function uriBuilder($remoteImage, $remoteFolder, $readType)
{
$uri = Product::$baseProductUri . '/barcode/';
if ($remoteImage != null)
$uri .= $remoteImage . '/';
$uri .= 'recognize?';
if ($readType == 'AllSupportedTypes')
$uri .= 'type=';
else
$uri .= 'type=' . $readType;
if ($remoteFolder != null && trim($remoteFolder) === '')
$uri .= '&format=' . $remoteFolder;
if ($remoteFolder != null && trim($remoteFolder) === '')
$uri .= '&folder=' . $remoteFolder;
return $uri;
} | [
"public",
"function",
"uriBuilder",
"(",
"$",
"remoteImage",
",",
"$",
"remoteFolder",
",",
"$",
"readType",
")",
"{",
"$",
"uri",
"=",
"Product",
"::",
"$",
"baseProductUri",
".",
"'/barcode/'",
";",
"if",
"(",
"$",
"remoteImage",
"!=",
"null",
")",
"$"... | Build uri.
@param string $remoteImage Name of the image.
@param string $remoteFolder Name of the folder.
@param string $readType Type to read barcode.
@return string | [
"Build",
"uri",
"."
] | 4950f2f2d24c9a101bf8e0a552d3801c251adac0 | https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_PHP/blob/4950f2f2d24c9a101bf8e0a552d3801c251adac0/src/Aspose/Cloud/Barcode/BarCodeReader.php#L92-L107 | train |
asposeforcloud/Aspose_Cloud_SDK_For_PHP | src/Aspose/Cloud/Barcode/BarCodeReader.php | BarcodeReader.readFromURL | 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/recognize?type=' . $symbology . '&url=' . $url;
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'POST', '', '');
$json = json_decode($responseStream);
if ($json->Code == 200)
return $json->Barcodes;
else
return false;
} | php | 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/recognize?type=' . $symbology . '&url=' . $url;
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'POST', '', '');
$json = json_decode($responseStream);
if ($json->Code == 200)
return $json->Barcodes;
else
return false;
} | [
"public",
"function",
"readFromURL",
"(",
"$",
"url",
",",
"$",
"symbology",
")",
"{",
"if",
"(",
"$",
"url",
"==",
"''",
")",
"throw",
"new",
"Exception",
"(",
"'URL not specified'",
")",
";",
"if",
"(",
"$",
"symbology",
"==",
"''",
")",
"throw",
"... | Read Barcode from External Image URL
@param string $url URL of the barcode image.
@param string $symbology Type of barcode.
@return array
@throws Exception | [
"Read",
"Barcode",
"from",
"External",
"Image",
"URL"
] | 4950f2f2d24c9a101bf8e0a552d3801c251adac0 | https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_PHP/blob/4950f2f2d24c9a101bf8e0a552d3801c251adac0/src/Aspose/Cloud/Barcode/BarCodeReader.php#L118-L140 | train |
asposeforcloud/Aspose_Cloud_SDK_For_PHP | src/Aspose/Cloud/Barcode/BarCodeReader.php | BarcodeReader.readSpecificRegion | 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 Exception('Y position not specified');
if ($rectWidth == '')
throw new Exception('Width not specified');
if ($rectHeight == '')
throw new Exception('Height not specified');
//build URI to read barcode
$strURI = Product::$baseProductUri . '/barcode/' . $this->getFileName() . '/recognize?type=' . $symbology . '&rectX=' . $rectX . '&rectY=' . $rectY
. '&rectWidth=' . $rectWidth . '&rectHeight=' . $rectHeight;
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
if ($json->Code == 200)
return $json->Barcodes;
else
return false;
} | php | 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 Exception('Y position not specified');
if ($rectWidth == '')
throw new Exception('Width not specified');
if ($rectHeight == '')
throw new Exception('Height not specified');
//build URI to read barcode
$strURI = Product::$baseProductUri . '/barcode/' . $this->getFileName() . '/recognize?type=' . $symbology . '&rectX=' . $rectX . '&rectY=' . $rectY
. '&rectWidth=' . $rectWidth . '&rectHeight=' . $rectHeight;
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
if ($json->Code == 200)
return $json->Barcodes;
else
return false;
} | [
"public",
"function",
"readSpecificRegion",
"(",
"$",
"symbology",
",",
"$",
"rectX",
",",
"$",
"rectY",
",",
"$",
"rectWidth",
",",
"$",
"rectHeight",
")",
"{",
"if",
"(",
"$",
"symbology",
"==",
"''",
")",
"throw",
"new",
"Exception",
"(",
"'Symbology ... | Read Barcode from Specific Region of Image
@param string $symbology string of barcode.
@param string $rectX
@param string $rectY
@param string $rectWidth
@param string $rectHeight
@return array
@throws Exception | [
"Read",
"Barcode",
"from",
"Specific",
"Region",
"of",
"Image"
] | 4950f2f2d24c9a101bf8e0a552d3801c251adac0 | https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_PHP/blob/4950f2f2d24c9a101bf8e0a552d3801c251adac0/src/Aspose/Cloud/Barcode/BarCodeReader.php#L154-L186 | train |
asposeforcloud/Aspose_Cloud_SDK_For_PHP | src/Aspose/Cloud/Barcode/BarCodeReader.php | BarcodeReader.readWithChecksum | 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 = Product::$baseProductUri . '/barcode/' . $this->getFileName() . '/recognize?type=' . $symbology . '&checksumValidation=' . $checksumValidation;
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
if ($json->Code == 200)
return $json->Barcodes;
else
return false;
} | php | 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 = Product::$baseProductUri . '/barcode/' . $this->getFileName() . '/recognize?type=' . $symbology . '&checksumValidation=' . $checksumValidation;
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
if ($json->Code == 200)
return $json->Barcodes;
else
return false;
} | [
"public",
"function",
"readWithChecksum",
"(",
"$",
"symbology",
",",
"$",
"checksumValidation",
")",
"{",
"if",
"(",
"$",
"symbology",
"==",
"''",
")",
"throw",
"new",
"Exception",
"(",
"'Symbology not specified'",
")",
";",
"if",
"(",
"$",
"checksumValidatio... | Recognize Barcode with Checksum Option from Storage
@param string $symbology Type of barcode.
@param string $checksumValidation Checksum validation parameter.
@return array
@throws Exception | [
"Recognize",
"Barcode",
"with",
"Checksum",
"Option",
"from",
"Storage"
] | 4950f2f2d24c9a101bf8e0a552d3801c251adac0 | https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_PHP/blob/4950f2f2d24c9a101bf8e0a552d3801c251adac0/src/Aspose/Cloud/Barcode/BarCodeReader.php#L197-L219 | train |
asposeforcloud/Aspose_Cloud_SDK_For_PHP | src/Aspose/Cloud/Barcode/BarCodeReader.php | BarcodeReader.readByAlgorithm | 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
$strURI = Product::$baseProductUri . '/barcode/' . $this->getFileName() . '/recognize?type=' . $symbology . '&BinarizationHints=' . $binarizationHints;
//sign URI
$signedURI = Utils::sign($strURI);
$response = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($response);
if ($json->Code == 200)
return $json->Barcodes;
else
return false;
} | php | 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
$strURI = Product::$baseProductUri . '/barcode/' . $this->getFileName() . '/recognize?type=' . $symbology . '&BinarizationHints=' . $binarizationHints;
//sign URI
$signedURI = Utils::sign($strURI);
$response = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($response);
if ($json->Code == 200)
return $json->Barcodes;
else
return false;
} | [
"public",
"function",
"readByAlgorithm",
"(",
"$",
"symbology",
",",
"$",
"binarizationHints",
")",
"{",
"if",
"(",
"$",
"symbology",
"==",
"''",
")",
"throw",
"new",
"Exception",
"(",
"'Symbology not specified'",
")",
";",
"if",
"(",
"$",
"binarizationHints",... | Read Barcodes by Applying Image Processing Algorithm
@param type $symbology Type of barcode.
@param type $binarizationHints Image processing algorithm.
@return object|boolean
@throws Exception | [
"Read",
"Barcodes",
"by",
"Applying",
"Image",
"Processing",
"Algorithm"
] | 4950f2f2d24c9a101bf8e0a552d3801c251adac0 | https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_PHP/blob/4950f2f2d24c9a101bf8e0a552d3801c251adac0/src/Aspose/Cloud/Barcode/BarCodeReader.php#L263-L285 | train |
asposeforcloud/Aspose_Cloud_SDK_For_PHP | src/Aspose/Cloud/Words/Field.php | Field.insertPageNumber | 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, 'Alignment' => $alignment,
'IsTop' => $isTop, 'SetPageNumberOnFirstPage' => $setPageNumberOnFirstPage);
$json = json_encode($fieldsArray);
//build URI to insert page number
$strURI = Product::$baseProductUri . '/words/' . $fileName . '/insertPageNumbers';
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'POST', 'json', $json);
$v_output = Utils::validateOutput($responseStream);
if ($v_output === '') {
//Save docs on server
$folder = new Folder();
$outputStream = $folder->GetFile($fileName);
$outputPath = AsposeApp::$outPutLocation . $fileName;
Utils::saveFile($outputStream, $outputPath);
return $outputPath;
} else
return $v_output;
} | php | 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, 'Alignment' => $alignment,
'IsTop' => $isTop, 'SetPageNumberOnFirstPage' => $setPageNumberOnFirstPage);
$json = json_encode($fieldsArray);
//build URI to insert page number
$strURI = Product::$baseProductUri . '/words/' . $fileName . '/insertPageNumbers';
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'POST', 'json', $json);
$v_output = Utils::validateOutput($responseStream);
if ($v_output === '') {
//Save docs on server
$folder = new Folder();
$outputStream = $folder->GetFile($fileName);
$outputPath = AsposeApp::$outPutLocation . $fileName;
Utils::saveFile($outputStream, $outputPath);
return $outputPath;
} else
return $v_output;
} | [
"public",
"function",
"insertPageNumber",
"(",
"$",
"fileName",
",",
"$",
"alignment",
",",
"$",
"format",
",",
"$",
"isTop",
",",
"$",
"setPageNumberOnFirstPage",
")",
"{",
"//check whether files are set or not",
"if",
"(",
"$",
"fileName",
"==",
"''",
")",
"... | Inserts page number field into the document.
@param string $fileName Name of the file.
@param string $alignment Alignment of page number.
@param string $format Format for page numbers.
@param boolean $isTop Either True or False.
@param integer $setPageNumberOnFirstPage Set value for first page number.
@return string Returns the file path.
@throws Exception | [
"Inserts",
"page",
"number",
"field",
"into",
"the",
"document",
"."
] | 4950f2f2d24c9a101bf8e0a552d3801c251adac0 | https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_PHP/blob/4950f2f2d24c9a101bf8e0a552d3801c251adac0/src/Aspose/Cloud/Words/Field.php#L28-L58 | train |
asposeforcloud/Aspose_Cloud_SDK_For_PHP | src/Aspose/Cloud/Words/Field.php | Field.getMailMergeFieldNames | 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($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
return $json->FieldNames->Names;
} | php | 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($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
return $json->FieldNames->Names;
} | [
"public",
"function",
"getMailMergeFieldNames",
"(",
"$",
"fileName",
")",
"{",
"//check whether file is set or not",
"if",
"(",
"$",
"fileName",
"==",
"''",
")",
"throw",
"new",
"Exception",
"(",
"'No file name specified'",
")",
";",
"$",
"strURI",
"=",
"Product"... | Gets all merge filed names from document.
@param string $fileName The name of source file.
@return array
@throws Exception | [
"Gets",
"all",
"merge",
"filed",
"names",
"from",
"document",
"."
] | 4950f2f2d24c9a101bf8e0a552d3801c251adac0 | https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_PHP/blob/4950f2f2d24c9a101bf8e0a552d3801c251adac0/src/Aspose/Cloud/Words/Field.php#L68-L83 | train |
Speelpenning-nl/laravel-products | src/Repositories/ProductRepository.php | ProductRepository.query | public function query($q = null)
{
return Product::where(function ($query) use ($q) {
if ($q) {
foreach (explode(' ', $q) as $keyword) {
$query->where('description', 'like', "%{$keyword}%");
}
}
})
->orderBy('description')
->paginate();
} | php | public function query($q = null)
{
return Product::where(function ($query) use ($q) {
if ($q) {
foreach (explode(' ', $q) as $keyword) {
$query->where('description', 'like', "%{$keyword}%");
}
}
})
->orderBy('description')
->paginate();
} | [
"public",
"function",
"query",
"(",
"$",
"q",
"=",
"null",
")",
"{",
"return",
"Product",
"::",
"where",
"(",
"function",
"(",
"$",
"query",
")",
"use",
"(",
"$",
"q",
")",
"{",
"if",
"(",
"$",
"q",
")",
"{",
"foreach",
"(",
"explode",
"(",
"' ... | Queries the product catalogue and returns a paginated result.
@param null|string $q
@return LengthAwarePaginator | [
"Queries",
"the",
"product",
"catalogue",
"and",
"returns",
"a",
"paginated",
"result",
"."
] | 41522ebbdd41108c1d4532bb42be602cc0c530c4 | https://github.com/Speelpenning-nl/laravel-products/blob/41522ebbdd41108c1d4532bb42be602cc0c530c4/src/Repositories/ProductRepository.php#L75-L86 | train |
Speelpenning-nl/laravel-products | src/Repositories/ProductRepository.php | ProductRepository.save | public function save(ProductContract $product, array $attributes = [])
{
$result = $product->save();
$details = [];
foreach ($attributes as $key => $value) {
if ($value) {
$details[$key] = compact('value');
}
}
$product->attributes()->sync($details);
return $result;
} | php | public function save(ProductContract $product, array $attributes = [])
{
$result = $product->save();
$details = [];
foreach ($attributes as $key => $value) {
if ($value) {
$details[$key] = compact('value');
}
}
$product->attributes()->sync($details);
return $result;
} | [
"public",
"function",
"save",
"(",
"ProductContract",
"$",
"product",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
"{",
"$",
"result",
"=",
"$",
"product",
"->",
"save",
"(",
")",
";",
"$",
"details",
"=",
"[",
"]",
";",
"foreach",
"(",
"$"... | Stores a product.
@param ProductContract $product
@param array $attributes
@return bool | [
"Stores",
"a",
"product",
"."
] | 41522ebbdd41108c1d4532bb42be602cc0c530c4 | https://github.com/Speelpenning-nl/laravel-products/blob/41522ebbdd41108c1d4532bb42be602cc0c530c4/src/Repositories/ProductRepository.php#L95-L108 | train |
asposeforcloud/Aspose_Cloud_SDK_For_PHP | src/Aspose/Cloud/Tasks/Resource.php | Resource.getResources | 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_decode($responseStream);
if ($json->Code == 200)
return $json->Resources->ResourceItem;
else
return false;
} | php | 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_decode($responseStream);
if ($json->Code == 200)
return $json->Resources->ResourceItem;
else
return false;
} | [
"public",
"function",
"getResources",
"(",
")",
"{",
"//build URI",
"$",
"strURI",
"=",
"Product",
"::",
"$",
"baseProductUri",
".",
"'/tasks/'",
".",
"$",
"this",
"->",
"getFileName",
"(",
")",
".",
"'/resources/'",
";",
"//sign URI",
"$",
"signedURI",
"=",... | Get project resource items. Each resource item has a link to get full
resource representation in the project.
@return array Returns the resources.
@throws Exception | [
"Get",
"project",
"resource",
"items",
".",
"Each",
"resource",
"item",
"has",
"a",
"link",
"to",
"get",
"full",
"resource",
"representation",
"in",
"the",
"project",
"."
] | 4950f2f2d24c9a101bf8e0a552d3801c251adac0 | https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_PHP/blob/4950f2f2d24c9a101bf8e0a552d3801c251adac0/src/Aspose/Cloud/Tasks/Resource.php#L30-L48 | train |
asposeforcloud/Aspose_Cloud_SDK_For_PHP | src/Aspose/Cloud/Tasks/Resource.php | Resource.getResource | 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::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
if ($json->Code == 200)
return $json->Resource;
else
return false;
} | php | 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::sign($strURI);
$responseStream = Utils::processCommand($signedURI, 'GET', '', '');
$json = json_decode($responseStream);
if ($json->Code == 200)
return $json->Resource;
else
return false;
} | [
"public",
"function",
"getResource",
"(",
"$",
"resourceId",
")",
"{",
"if",
"(",
"$",
"resourceId",
"==",
"''",
")",
"throw",
"new",
"Exception",
"(",
"'Resource ID not specified'",
")",
";",
"//build URI",
"$",
"strURI",
"=",
"Product",
"::",
"$",
"basePro... | Get resource information.
@param integer $resourceId The id of the project resource.
@return string Returns project resource.
@throws Exception | [
"Get",
"resource",
"information",
"."
] | 4950f2f2d24c9a101bf8e0a552d3801c251adac0 | https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_PHP/blob/4950f2f2d24c9a101bf8e0a552d3801c251adac0/src/Aspose/Cloud/Tasks/Resource.php#L58-L79 | train |
AXN-Informatique/laravel-models-generator | src/Traits/HasStub.php | HasStub.getStubContent | 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_get_contents($path);
}
return static::$stubs[$name];
} | php | 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_get_contents($path);
}
return static::$stubs[$name];
} | [
"protected",
"function",
"getStubContent",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"static",
"::",
"$",
"stubs",
"[",
"$",
"name",
"]",
")",
")",
"{",
"if",
"(",
"!",
"is_file",
"(",
"$",
"path",
"=",
"base_path",
"(",
"\"resource... | Retourne le contenu d'un stub.
@param string $name
@return string | [
"Retourne",
"le",
"contenu",
"d",
"un",
"stub",
"."
] | f3f185b1274afff91885033e630b133e089bcc56 | https://github.com/AXN-Informatique/laravel-models-generator/blob/f3f185b1274afff91885033e630b133e089bcc56/src/Traits/HasStub.php#L20-L31 | train |
asinfotrack/yii2-comments | helpers/CommentsHelper.php | CommentsHelper.handle | public static function handle($model)
{
if (!$model->load(Yii::$app->request->post())) return false;
return $model->save();
} | php | public static function handle($model)
{
if (!$model->load(Yii::$app->request->post())) return false;
return $model->save();
} | [
"public",
"static",
"function",
"handle",
"(",
"$",
"model",
")",
"{",
"if",
"(",
"!",
"$",
"model",
"->",
"load",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
")",
")",
")",
"return",
"false",
";",
"return",
"$",
"model",
"-... | Handles a comment model when submitted
@param \asinfotrack\yii2\comments\models\Comment $model
@return bool true if created
@throws \yii\db\Exception | [
"Handles",
"a",
"comment",
"model",
"when",
"submitted"
] | 8f3b1ea239a4e940bc32472d16fb09c2b71135f7 | https://github.com/asinfotrack/yii2-comments/blob/8f3b1ea239a4e940bc32472d16fb09c2b71135f7/helpers/CommentsHelper.php#L23-L27 | train |
shen2/FluentCQL | src/Query.php | Query.querySync | public function querySync(){
$adapter = $this->_dbAdapter ?: Table::getDefaultDbAdapter();
return $adapter->querySync($this->assemble(), $this->_bind, $this->_consistency, $this->_options);
} | php | public function querySync(){
$adapter = $this->_dbAdapter ?: Table::getDefaultDbAdapter();
return $adapter->querySync($this->assemble(), $this->_bind, $this->_consistency, $this->_options);
} | [
"public",
"function",
"querySync",
"(",
")",
"{",
"$",
"adapter",
"=",
"$",
"this",
"->",
"_dbAdapter",
"?",
":",
"Table",
"::",
"getDefaultDbAdapter",
"(",
")",
";",
"return",
"$",
"adapter",
"->",
"querySync",
"(",
"$",
"this",
"->",
"assemble",
"(",
... | Executes the current query and returns the response
@throws \Cassandra\Response\Exception
@return \Cassandra\Response | [
"Executes",
"the",
"current",
"query",
"and",
"returns",
"the",
"response"
] | b323ce0d0d410502aa3887efc31efb30325c8c4d | https://github.com/shen2/FluentCQL/blob/b323ce0d0d410502aa3887efc31efb30325c8c4d/src/Query.php#L108-L112 | train |
shen2/FluentCQL | src/Query.php | Query.prepare | public function prepare(){
$adapter = $this->_dbAdapter ?: Table::getDefaultDbAdapter();
return $adapter->prepare($this->assemble());
} | php | public function prepare(){
$adapter = $this->_dbAdapter ?: Table::getDefaultDbAdapter();
return $adapter->prepare($this->assemble());
} | [
"public",
"function",
"prepare",
"(",
")",
"{",
"$",
"adapter",
"=",
"$",
"this",
"->",
"_dbAdapter",
"?",
":",
"Table",
"::",
"getDefaultDbAdapter",
"(",
")",
";",
"return",
"$",
"adapter",
"->",
"prepare",
"(",
"$",
"this",
"->",
"assemble",
"(",
")"... | Prepares the current query and returns the response
@throws \Cassandra\Response\Exception
@return \Cassandra\Result | [
"Prepares",
"the",
"current",
"query",
"and",
"returns",
"the",
"response"
] | b323ce0d0d410502aa3887efc31efb30325c8c4d | https://github.com/shen2/FluentCQL/blob/b323ce0d0d410502aa3887efc31efb30325c8c4d/src/Query.php#L131-L135 | train |
agoat/contao-customcontentelements-bundle | src/Resources/contao/classes/Config.php | Config.loadParameters | 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.valid_extensions'))
{
$GLOBALS['TL_CONFIG']['validAudioTypes'] = implode(',', $container->getParameter('contao.audio.valid_extensions'));
}
} | php | 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.valid_extensions'))
{
$GLOBALS['TL_CONFIG']['validAudioTypes'] = implode(',', $container->getParameter('contao.audio.valid_extensions'));
}
} | [
"public",
"function",
"loadParameters",
"(",
")",
"{",
"$",
"container",
"=",
"\\",
"System",
"::",
"getContainer",
"(",
")",
";",
"if",
"(",
"$",
"container",
"->",
"hasParameter",
"(",
"'contao.video.valid_extensions'",
")",
")",
"{",
"$",
"GLOBALS",
"[",
... | Push symfony configuration into the contao config array | [
"Push",
"symfony",
"configuration",
"into",
"the",
"contao",
"config",
"array"
] | a74d880d74352d2ed887e13f29115bbc48ad84cc | https://github.com/agoat/contao-customcontentelements-bundle/blob/a74d880d74352d2ed887e13f29115bbc48ad84cc/src/Resources/contao/classes/Config.php#L24-L37 | train |
Divergence/framework | src/Models/Auth/Session.php | Session.getFromRequest | 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::getByHandle($_COOKIE[static::$cookieName])) {
// update session & check expiration
$Session = static::updateSession($Session, $sessionData);
}
}
// try to load from any request method
if (empty($Session) && !empty($_REQUEST[static::$cookieName])) {
if ($Session = static::getByHandle($_REQUEST[static::$cookieName])) {
// update session & check expiration
$Session = static::updateSession($Session, $sessionData);
}
}
if (!empty($Session)) {
// session found
return $Session;
} elseif ($create) {
// create session
return static::create($sessionData, true);
} else {
// no session available
return false;
}
} | php | 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::getByHandle($_COOKIE[static::$cookieName])) {
// update session & check expiration
$Session = static::updateSession($Session, $sessionData);
}
}
// try to load from any request method
if (empty($Session) && !empty($_REQUEST[static::$cookieName])) {
if ($Session = static::getByHandle($_REQUEST[static::$cookieName])) {
// update session & check expiration
$Session = static::updateSession($Session, $sessionData);
}
}
if (!empty($Session)) {
// session found
return $Session;
} elseif ($create) {
// create session
return static::create($sessionData, true);
} else {
// no session available
return false;
}
} | [
"public",
"static",
"function",
"getFromRequest",
"(",
"$",
"create",
"=",
"true",
")",
"{",
"$",
"sessionData",
"=",
"[",
"'LastIP'",
"=>",
"inet_pton",
"(",
"$",
"_SERVER",
"[",
"'REMOTE_ADDR'",
"]",
")",
",",
"'LastRequest'",
"=>",
"time",
"(",
")",
"... | Gets or sets up a session based on current cookies.
Will always update the current session's LastIP and LastRequest fields.
@param boolean $create
@return static|false | [
"Gets",
"or",
"sets",
"up",
"a",
"session",
"based",
"on",
"current",
"cookies",
".",
"Will",
"always",
"update",
"the",
"current",
"session",
"s",
"LastIP",
"and",
"LastRequest",
"fields",
"."
] | daaf78aa4b10ad59bf52b9e31480c748ad82e8c3 | https://github.com/Divergence/framework/blob/daaf78aa4b10ad59bf52b9e31480c748ad82e8c3/src/Models/Auth/Session.php#L71-L104 | train |
IDCI-Consulting/ExtraFormBundle | Controller/EditorController.php | EditorController.overviewAction | public function overviewAction(
Request $request,
FormFactoryInterface $formFactory,
ExtraFormBuilderInterface $extraFormBuilder
) {
$formName = 'overview';
$data = $request->request->get($formName);
$configurationRaw = $data['configuration'];
$configuration = json_decode($configurationRaw, true);
$overviewBuilder = $formFactory
->createNamedBuilder($formName)
->setAction($this->generateUrl('idci_extra_form_editor_overview'))
->add('configuration', HiddenType::class, array(
'data' => $configurationRaw,
))
;
$form = $extraFormBuilder
->build($configuration, array(), array(), $overviewBuilder)
->add('submit', SubmitType::class)
->getForm()
;
// The form overview has been submitted
if (count($data) > 1) {
$form->handleRequest($request);
if ($form->isValid()) {
return new Response('This form was well submitted');
}
}
// Render the form with or without errors
return $this->render('@IDCIExtraForm/Editor/overview.html.twig', array(
'form' => $form->createView(),
));
} | php | public function overviewAction(
Request $request,
FormFactoryInterface $formFactory,
ExtraFormBuilderInterface $extraFormBuilder
) {
$formName = 'overview';
$data = $request->request->get($formName);
$configurationRaw = $data['configuration'];
$configuration = json_decode($configurationRaw, true);
$overviewBuilder = $formFactory
->createNamedBuilder($formName)
->setAction($this->generateUrl('idci_extra_form_editor_overview'))
->add('configuration', HiddenType::class, array(
'data' => $configurationRaw,
))
;
$form = $extraFormBuilder
->build($configuration, array(), array(), $overviewBuilder)
->add('submit', SubmitType::class)
->getForm()
;
// The form overview has been submitted
if (count($data) > 1) {
$form->handleRequest($request);
if ($form->isValid()) {
return new Response('This form was well submitted');
}
}
// Render the form with or without errors
return $this->render('@IDCIExtraForm/Editor/overview.html.twig', array(
'form' => $form->createView(),
));
} | [
"public",
"function",
"overviewAction",
"(",
"Request",
"$",
"request",
",",
"FormFactoryInterface",
"$",
"formFactory",
",",
"ExtraFormBuilderInterface",
"$",
"extraFormBuilder",
")",
"{",
"$",
"formName",
"=",
"'overview'",
";",
"$",
"data",
"=",
"$",
"request",... | Overview action.
@Route("/overview", name="idci_extra_form_editor_overview", methods={"POST"}) | [
"Overview",
"action",
"."
] | 3481c69fd078754f3d0c5947dd59a5536ed13da0 | https://github.com/IDCI-Consulting/ExtraFormBundle/blob/3481c69fd078754f3d0c5947dd59a5536ed13da0/Controller/EditorController.php#L26-L62 | train |
webino/WebinoImageThumb | src/WebinoImageThumb/Service/ImageThumb.php | ImageThumb.create | 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);
}
return $thumb;
} | php | 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);
}
return $thumb;
} | [
"public",
"function",
"create",
"(",
"$",
"filename",
"=",
"null",
",",
"array",
"$",
"options",
"=",
"[",
"]",
",",
"array",
"$",
"plugins",
"=",
"[",
"]",
")",
"{",
"try",
"{",
"$",
"thumb",
"=",
"new",
"PHPThumb",
"(",
"$",
"filename",
",",
"$... | Create image thumbnail object
@param string $filename
@param array $options
@param array $plugins
@return PHPThumb | [
"Create",
"image",
"thumbnail",
"object"
] | ec9ea61bdb1e18fb8246e405a5784c653103ed5c | https://github.com/webino/WebinoImageThumb/blob/ec9ea61bdb1e18fb8246e405a5784c653103ed5c/src/WebinoImageThumb/Service/ImageThumb.php#L32-L41 | train |
webino/WebinoImageThumb | src/WebinoImageThumb/Service/ImageThumb.php | ImageThumb.createReflection | public function createReflection($percent, $reflection, $white, $border, $borderColor)
{
return new Plugins\Reflection($percent, $reflection, $white, $border, $borderColor);
} | php | public function createReflection($percent, $reflection, $white, $border, $borderColor)
{
return new Plugins\Reflection($percent, $reflection, $white, $border, $borderColor);
} | [
"public",
"function",
"createReflection",
"(",
"$",
"percent",
",",
"$",
"reflection",
",",
"$",
"white",
",",
"$",
"border",
",",
"$",
"borderColor",
")",
"{",
"return",
"new",
"Plugins",
"\\",
"Reflection",
"(",
"$",
"percent",
",",
"$",
"reflection",
... | Create reflection plugin
@param int $percent
@param int $reflection
@param int $white
@param bool $border
@param string $borderColor hex
@return Plugins\Reflection | [
"Create",
"reflection",
"plugin"
] | ec9ea61bdb1e18fb8246e405a5784c653103ed5c | https://github.com/webino/WebinoImageThumb/blob/ec9ea61bdb1e18fb8246e405a5784c653103ed5c/src/WebinoImageThumb/Service/ImageThumb.php#L53-L56 | train |
webino/WebinoImageThumb | src/WebinoImageThumb/Service/ImageThumb.php | ImageThumb.createWatermark | public function createWatermark(PHPThumb $watermarkThumb, array $position = [0, 0], $scale = .5)
{
return new Plugins\Watermark($watermarkThumb, $position, $scale);
} | php | public function createWatermark(PHPThumb $watermarkThumb, array $position = [0, 0], $scale = .5)
{
return new Plugins\Watermark($watermarkThumb, $position, $scale);
} | [
"public",
"function",
"createWatermark",
"(",
"PHPThumb",
"$",
"watermarkThumb",
",",
"array",
"$",
"position",
"=",
"[",
"0",
",",
"0",
"]",
",",
"$",
"scale",
"=",
".5",
")",
"{",
"return",
"new",
"Plugins",
"\\",
"Watermark",
"(",
"$",
"watermarkThumb... | Create a watermark on image
@param PHPThumb $watermarkThumb
@param array $position
@param float $scale
@return Plugins\Watermark | [
"Create",
"a",
"watermark",
"on",
"image"
] | ec9ea61bdb1e18fb8246e405a5784c653103ed5c | https://github.com/webino/WebinoImageThumb/blob/ec9ea61bdb1e18fb8246e405a5784c653103ed5c/src/WebinoImageThumb/Service/ImageThumb.php#L90-L93 | train |
shen2/FluentCQL | src/Table.php | Table.offsetSet | public function offsetSet($columnName, $value)
{
if (!in_array($columnName, static::$_primary)){
$this->_modifiedData[$columnName] = $value;
}
parent::offsetSet($columnName, $value);
} | php | public function offsetSet($columnName, $value)
{
if (!in_array($columnName, static::$_primary)){
$this->_modifiedData[$columnName] = $value;
}
parent::offsetSet($columnName, $value);
} | [
"public",
"function",
"offsetSet",
"(",
"$",
"columnName",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"columnName",
",",
"static",
"::",
"$",
"_primary",
")",
")",
"{",
"$",
"this",
"->",
"_modifiedData",
"[",
"$",
"columnName",... | Set row field value
@param string $columnName The column key.
@param mixed $value The value for the property.
@return void | [
"Set",
"row",
"field",
"value"
] | b323ce0d0d410502aa3887efc31efb30325c8c4d | https://github.com/shen2/FluentCQL/blob/b323ce0d0d410502aa3887efc31efb30325c8c4d/src/Table.php#L284-L291 | train |
IDCI-Consulting/ExtraFormBundle | Event/Subscriber/SerializerSubscriber.php | SerializerSubscriber.onPreSerialize | public function onPreSerialize(ObjectEvent $event)
{
$configuredType = $event->getObject();
if ($configuredType instanceof ConfiguredType) {
try {
$configurationArray = json_decode($configuredType->getConfiguration(), true);
$extraFormType = $this->registry->getType($configurationArray['form_type']);
$configuredType->setExtraFormType($extraFormType);
} catch (\Exception $e) {
return;
}
}
} | php | public function onPreSerialize(ObjectEvent $event)
{
$configuredType = $event->getObject();
if ($configuredType instanceof ConfiguredType) {
try {
$configurationArray = json_decode($configuredType->getConfiguration(), true);
$extraFormType = $this->registry->getType($configurationArray['form_type']);
$configuredType->setExtraFormType($extraFormType);
} catch (\Exception $e) {
return;
}
}
} | [
"public",
"function",
"onPreSerialize",
"(",
"ObjectEvent",
"$",
"event",
")",
"{",
"$",
"configuredType",
"=",
"$",
"event",
"->",
"getObject",
"(",
")",
";",
"if",
"(",
"$",
"configuredType",
"instanceof",
"ConfiguredType",
")",
"{",
"try",
"{",
"$",
"co... | Method called on pre serialize event.
@param ObjectEvent $event | [
"Method",
"called",
"on",
"pre",
"serialize",
"event",
"."
] | 3481c69fd078754f3d0c5947dd59a5536ed13da0 | https://github.com/IDCI-Consulting/ExtraFormBundle/blob/3481c69fd078754f3d0c5947dd59a5536ed13da0/Event/Subscriber/SerializerSubscriber.php#L49-L62 | train |
asinfotrack/yii2-comments | widgets/Comments.php | Comments.outputComment | 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->useBootstrapClasses) Html::addCssClass($options, 'media');
//render comment
echo Html::beginTag('div', $options);
//body
$wrapperOptions = ['class'=>'comment-wrapper'];
if ($this->useBootstrapClasses) Html::addCssClass($wrapperOptions, 'media-body');
echo Html::beginTag('div', $wrapperOptions);
//title
if (!empty($comment->title)) {
$titleOptions = ['class'=>'comment-title'];
if ($this->useBootstrapClasses) Html::addCssClass($titleOptions, 'media-heading');
$title = $this->encodeCommentTitle ? Html::encode($comment->title) : $comment->title;
echo Html::tag($this->commentTitleTag, $title, $titleOptions);
}
//content
$content = $this->encodeCommentContents ? Html::encode($comment->content) : $comment->content;
echo Html::tag('div', $content, ['class'=>'comment-content']);
//meta
echo Html::beginTag('dl', ['class'=>'comment-meta']);
echo Html::tag('dt', Yii::t('app', 'Created'));
echo Html::tag('dd', Yii::$app->formatter->asDatetime($comment->created));
if (!empty($comment->updated) && $comment->updated != $comment->created) {
echo Html::tag('dt', Yii::t('app', 'Updated'));
echo Html::tag('dd', Yii::$app->formatter->asDatetime($comment->updated));
}
if (!empty($comment->user_id)) {
$author = $this->authorCallback === null ? $comment->created_by : call_user_func($this->authorCallback, $comment->created_by);
echo Html::tag('dt', Yii::t('app', 'Author'));
echo Html::tag('dd', $author);
}
echo Html::endTag('dl');
echo Html::endTag('div');
echo Html::endTag('div');
} | php | 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->useBootstrapClasses) Html::addCssClass($options, 'media');
//render comment
echo Html::beginTag('div', $options);
//body
$wrapperOptions = ['class'=>'comment-wrapper'];
if ($this->useBootstrapClasses) Html::addCssClass($wrapperOptions, 'media-body');
echo Html::beginTag('div', $wrapperOptions);
//title
if (!empty($comment->title)) {
$titleOptions = ['class'=>'comment-title'];
if ($this->useBootstrapClasses) Html::addCssClass($titleOptions, 'media-heading');
$title = $this->encodeCommentTitle ? Html::encode($comment->title) : $comment->title;
echo Html::tag($this->commentTitleTag, $title, $titleOptions);
}
//content
$content = $this->encodeCommentContents ? Html::encode($comment->content) : $comment->content;
echo Html::tag('div', $content, ['class'=>'comment-content']);
//meta
echo Html::beginTag('dl', ['class'=>'comment-meta']);
echo Html::tag('dt', Yii::t('app', 'Created'));
echo Html::tag('dd', Yii::$app->formatter->asDatetime($comment->created));
if (!empty($comment->updated) && $comment->updated != $comment->created) {
echo Html::tag('dt', Yii::t('app', 'Updated'));
echo Html::tag('dd', Yii::$app->formatter->asDatetime($comment->updated));
}
if (!empty($comment->user_id)) {
$author = $this->authorCallback === null ? $comment->created_by : call_user_func($this->authorCallback, $comment->created_by);
echo Html::tag('dt', Yii::t('app', 'Author'));
echo Html::tag('dd', $author);
}
echo Html::endTag('dl');
echo Html::endTag('div');
echo Html::endTag('div');
} | [
"protected",
"function",
"outputComment",
"(",
"$",
"comment",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"commentOptions",
"instanceof",
"\\",
"Closure",
")",
"{",
"$",
"options",
"=",
"call_user_func",
"(",
"$",
"this",
"->",
"commentOptions",
",",
"$",
"co... | Outputs a single comment
@param $comment \asinfotrack\yii2\comments\models\Comment the comment model | [
"Outputs",
"a",
"single",
"comment"
] | 8f3b1ea239a4e940bc32472d16fb09c2b71135f7 | https://github.com/asinfotrack/yii2-comments/blob/8f3b1ea239a4e940bc32472d16fb09c2b71135f7/widgets/Comments.php#L140-L187 | train |
ornicar/php-git-repo | lib/PHPGit/Repository.php | PHPGit_Repository.create | 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();
$repo = new self($dir, $debug, $options);
return $repo;
} | php | 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();
$repo = new self($dir, $debug, $options);
return $repo;
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"dir",
",",
"$",
"debug",
"=",
"false",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"options",
"=",
"array_merge",
"(",
"self",
"::",
"$",
"defaultOptions",
",",
"$",
"optio... | Create a new Git repository in filesystem, running "git init"
Returns the git repository wrapper
@param string $dir real filesystem path of the repository
@param boolean $debug
@param array $options
@return PHPGit_Repository | [
"Create",
"a",
"new",
"Git",
"repository",
"in",
"filesystem",
"running",
"git",
"init",
"Returns",
"the",
"git",
"repository",
"wrapper"
] | dfcd5c4684c0c2beb56453132c2adc019868e71d | https://github.com/ornicar/php-git-repo/blob/dfcd5c4684c0c2beb56453132c2adc019868e71d/lib/PHPGit/Repository.php#L85-L95 | train |
ornicar/php-git-repo | lib/PHPGit/Repository.php | PHPGit_Repository.cloneUrl | 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'](getcwd(), $commandString, $debug);
$command->run();
$repo = new self($dir, $debug, $options);
return $repo;
} | php | 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'](getcwd(), $commandString, $debug);
$command->run();
$repo = new self($dir, $debug, $options);
return $repo;
} | [
"public",
"static",
"function",
"cloneUrl",
"(",
"$",
"url",
",",
"$",
"dir",
",",
"$",
"debug",
"=",
"false",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"options",
"=",
"array_merge",
"(",
"self",
"::",
"$",
"defaultOptions... | Clone a new Git repository in filesystem, running "git clone"
Returns the git repository wrapper
@param string $url of the repository
@param string $dir real filesystem path of the repository
@param boolean $debug
@param array $options
@return PHPGit_Repository | [
"Clone",
"a",
"new",
"Git",
"repository",
"in",
"filesystem",
"running",
"git",
"clone",
"Returns",
"the",
"git",
"repository",
"wrapper"
] | dfcd5c4684c0c2beb56453132c2adc019868e71d | https://github.com/ornicar/php-git-repo/blob/dfcd5c4684c0c2beb56453132c2adc019868e71d/lib/PHPGit/Repository.php#L107-L117 | train |
ornicar/php-git-repo | lib/PHPGit/Repository.php | PHPGit_Repository.getCommits | 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 | 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);
} | [
"public",
"function",
"getCommits",
"(",
"$",
"nbCommits",
"=",
"10",
")",
"{",
"$",
"output",
"=",
"$",
"this",
"->",
"git",
"(",
"sprintf",
"(",
"'log -n %d --date=%s --format=format:%s'",
",",
"$",
"nbCommits",
",",
"$",
"this",
"->",
"dateFormat",
",",
... | Return the result of `git log` formatted in a PHP array
@return array list of commits and their properties | [
"Return",
"the",
"result",
"of",
"git",
"log",
"formatted",
"in",
"a",
"PHP",
"array"
] | dfcd5c4684c0c2beb56453132c2adc019868e71d | https://github.com/ornicar/php-git-repo/blob/dfcd5c4684c0c2beb56453132c2adc019868e71d/lib/PHPGit/Repository.php#L180-L184 | train |
ornicar/php-git-repo | lib/PHPGit/Repository.php | PHPGit_Repository.parseLogsIntoArray | 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],
'email' => $infos[3]
),
'authored_date' => $infos[4],
'commiter' => array(
'name' => $infos[5],
'email' => $infos[6]
),
'committed_date' => $infos[7],
'message' => $infos[8]
);
}
return $commits;
} | php | 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],
'email' => $infos[3]
),
'authored_date' => $infos[4],
'commiter' => array(
'name' => $infos[5],
'email' => $infos[6]
),
'committed_date' => $infos[7],
'message' => $infos[8]
);
}
return $commits;
} | [
"private",
"function",
"parseLogsIntoArray",
"(",
"$",
"logOutput",
")",
"{",
"$",
"commits",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"explode",
"(",
"\"\\n\"",
",",
"$",
"logOutput",
")",
"as",
"$",
"line",
")",
"{",
"$",
"infos",
"=",
"explode",... | Convert a formatted log string into an array
@param string $logOutput The output from a `git log` command formated using $this->logFormat | [
"Convert",
"a",
"formatted",
"log",
"string",
"into",
"an",
"array"
] | dfcd5c4684c0c2beb56453132c2adc019868e71d | https://github.com/ornicar/php-git-repo/blob/dfcd5c4684c0c2beb56453132c2adc019868e71d/lib/PHPGit/Repository.php#L190-L212 | train |
Vanare/behat-cucumber-formatter | src/Printer/FileOutputPrinter.php | FileOutputPrinter.setOutputPath | public function setOutputPath($path)
{
if (!file_exists($path)) {
if (!mkdir($path, 0755, true)) {
throw new BadOutputPathException(
sprintf(
'Output path %s does not exist and could not be created!',
$path
),
$path
);
}
} else {
if (!is_dir($path)) {
throw new BadOutputPathException(
sprintf(
'The argument to `output` is expected to the a directory, but got %s!',
$path
),
$path
);
}
}
$this->path = $path;
} | php | public function setOutputPath($path)
{
if (!file_exists($path)) {
if (!mkdir($path, 0755, true)) {
throw new BadOutputPathException(
sprintf(
'Output path %s does not exist and could not be created!',
$path
),
$path
);
}
} else {
if (!is_dir($path)) {
throw new BadOutputPathException(
sprintf(
'The argument to `output` is expected to the a directory, but got %s!',
$path
),
$path
);
}
}
$this->path = $path;
} | [
"public",
"function",
"setOutputPath",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"path",
")",
")",
"{",
"if",
"(",
"!",
"mkdir",
"(",
"$",
"path",
",",
"0755",
",",
"true",
")",
")",
"{",
"throw",
"new",
"BadOutputPathExc... | Sets output path.
@param string $path | [
"Sets",
"output",
"path",
"."
] | b28ae403404be4c74c740a3948d9338fc51443a3 | https://github.com/Vanare/behat-cucumber-formatter/blob/b28ae403404be4c74c740a3948d9338fc51443a3/src/Printer/FileOutputPrinter.php#L35-L59 | train |
dynamic/foxystripe | src/Controller/FoxyStripeController.php | FoxyStripeController.processFoxyRequest | protected function processFoxyRequest(HTTPRequest $request)
{
$encryptedData = $request->postVar('FoxyData')
? urldecode($request->postVar('FoxyData'))
: urldecode($request->postVar('FoxySubscriptionData'));
$decryptedData = $this->decryptFeedData($encryptedData);
$this->parseFeedData($encryptedData, $decryptedData);
$this->extend('addIntegrations', $encryptedData);
} | php | protected function processFoxyRequest(HTTPRequest $request)
{
$encryptedData = $request->postVar('FoxyData')
? urldecode($request->postVar('FoxyData'))
: urldecode($request->postVar('FoxySubscriptionData'));
$decryptedData = $this->decryptFeedData($encryptedData);
$this->parseFeedData($encryptedData, $decryptedData);
$this->extend('addIntegrations', $encryptedData);
} | [
"protected",
"function",
"processFoxyRequest",
"(",
"HTTPRequest",
"$",
"request",
")",
"{",
"$",
"encryptedData",
"=",
"$",
"request",
"->",
"postVar",
"(",
"'FoxyData'",
")",
"?",
"urldecode",
"(",
"$",
"request",
"->",
"postVar",
"(",
"'FoxyData'",
")",
"... | Process a request after a transaction is completed via Foxy
@param HTTPRequest $request | [
"Process",
"a",
"request",
"after",
"a",
"transaction",
"is",
"completed",
"via",
"Foxy"
] | cfffae6021788de18fd78489753821f7faf5b9a9 | https://github.com/dynamic/foxystripe/blob/cfffae6021788de18fd78489753821f7faf5b9a9/src/Controller/FoxyStripeController.php#L63-L73 | train |
dynamic/foxystripe | src/Controller/FoxyStripeController.php | FoxyStripeController.parseFeedData | private function parseFeedData($encryptedData, $decryptedData)
{
$orders = new \SimpleXMLElement($decryptedData);
// loop over each transaction to find FoxyCart Order ID
foreach ($orders->transactions->transaction as $transaction) {
$this->processTransaction($transaction, $encryptedData);
}
} | php | private function parseFeedData($encryptedData, $decryptedData)
{
$orders = new \SimpleXMLElement($decryptedData);
// loop over each transaction to find FoxyCart Order ID
foreach ($orders->transactions->transaction as $transaction) {
$this->processTransaction($transaction, $encryptedData);
}
} | [
"private",
"function",
"parseFeedData",
"(",
"$",
"encryptedData",
",",
"$",
"decryptedData",
")",
"{",
"$",
"orders",
"=",
"new",
"\\",
"SimpleXMLElement",
"(",
"$",
"decryptedData",
")",
";",
"// loop over each transaction to find FoxyCart Order ID",
"foreach",
"(",... | Parse the XML data feed from Foxy to a SimpleXMLElement object
@param $encrypted
@param $decrypted
@throws \SilverStripe\ORM\ValidationException | [
"Parse",
"the",
"XML",
"data",
"feed",
"from",
"Foxy",
"to",
"a",
"SimpleXMLElement",
"object"
] | cfffae6021788de18fd78489753821f7faf5b9a9 | https://github.com/dynamic/foxystripe/blob/cfffae6021788de18fd78489753821f7faf5b9a9/src/Controller/FoxyStripeController.php#L95-L103 | train |
dynamic/foxystripe | src/Controller/FoxyStripeController.php | FoxyStripeController.sso | public function sso()
{
// GET variables from FoxyCart Request
$fcsid = $this->request->getVar('fcsid');
$timestampNew = strtotime('+30 days');
// get current member if logged in. If not, create a 'fake' user with Customer_ID = 0
// fake user will redirect to FC checkout, ask customer to log in
// to do: consider a login/registration form here if not logged in
if (!$Member = Security::getCurrentUser()) {
$Member = new Member();
$Member->Customer_ID = 0;
}
$auth_token = sha1($Member->Customer_ID . '|' . $timestampNew . '|' . FoxyCart::getStoreKey());
$config = FoxyStripeSetting::current_foxystripe_setting();
if ($config->CustomSSL) {
$link = FoxyCart::getFoxyCartStoreName();
} else {
$link = FoxyCart::getFoxyCartStoreName() . '.foxycart.com';
}
$params = [
'fc_auth_token' => $auth_token,
'fcsid' => $fcsid,
'fc_customer_id' => $Member->Customer_ID,
'timestamp' => $timestampNew,
];
$httpQuery = http_build_query($params);
$this->redirect("https://{$link}/checkout?$httpQuery");
} | php | public function sso()
{
// GET variables from FoxyCart Request
$fcsid = $this->request->getVar('fcsid');
$timestampNew = strtotime('+30 days');
// get current member if logged in. If not, create a 'fake' user with Customer_ID = 0
// fake user will redirect to FC checkout, ask customer to log in
// to do: consider a login/registration form here if not logged in
if (!$Member = Security::getCurrentUser()) {
$Member = new Member();
$Member->Customer_ID = 0;
}
$auth_token = sha1($Member->Customer_ID . '|' . $timestampNew . '|' . FoxyCart::getStoreKey());
$config = FoxyStripeSetting::current_foxystripe_setting();
if ($config->CustomSSL) {
$link = FoxyCart::getFoxyCartStoreName();
} else {
$link = FoxyCart::getFoxyCartStoreName() . '.foxycart.com';
}
$params = [
'fc_auth_token' => $auth_token,
'fcsid' => $fcsid,
'fc_customer_id' => $Member->Customer_ID,
'timestamp' => $timestampNew,
];
$httpQuery = http_build_query($params);
$this->redirect("https://{$link}/checkout?$httpQuery");
} | [
"public",
"function",
"sso",
"(",
")",
"{",
"// GET variables from FoxyCart Request",
"$",
"fcsid",
"=",
"$",
"this",
"->",
"request",
"->",
"getVar",
"(",
"'fcsid'",
")",
";",
"$",
"timestampNew",
"=",
"strtotime",
"(",
"'+30 days'",
")",
";",
"// get current... | Single Sign on integration with FoxyCart. | [
"Single",
"Sign",
"on",
"integration",
"with",
"FoxyCart",
"."
] | cfffae6021788de18fd78489753821f7faf5b9a9 | https://github.com/dynamic/foxystripe/blob/cfffae6021788de18fd78489753821f7faf5b9a9/src/Controller/FoxyStripeController.php#L128-L161 | train |
amphp/cluster | src/Cluster.php | Cluster.terminate | private static function terminate(): Promise
{
if (self::$onClose === null) {
return Promise\any([]);
}
if (self::$signalWatchers) {
foreach (self::$signalWatchers as $watcher) {
Loop::cancel($watcher);
}
}
$onClose = self::$onClose;
self::$onClose = null;
$promises = [];
foreach ($onClose as $callable) {
$promises[] = call($callable);
}
return Promise\any($promises);
} | php | private static function terminate(): Promise
{
if (self::$onClose === null) {
return Promise\any([]);
}
if (self::$signalWatchers) {
foreach (self::$signalWatchers as $watcher) {
Loop::cancel($watcher);
}
}
$onClose = self::$onClose;
self::$onClose = null;
$promises = [];
foreach ($onClose as $callable) {
$promises[] = call($callable);
}
return Promise\any($promises);
} | [
"private",
"static",
"function",
"terminate",
"(",
")",
":",
"Promise",
"{",
"if",
"(",
"self",
"::",
"$",
"onClose",
"===",
"null",
")",
"{",
"return",
"Promise",
"\\",
"any",
"(",
"[",
"]",
")",
";",
"}",
"if",
"(",
"self",
"::",
"$",
"signalWatc... | Invokes any termination callbacks.
@return Promise | [
"Invokes",
"any",
"termination",
"callbacks",
"."
] | 33e7b71902ce85c221d4d3d35d4bd879af052686 | https://github.com/amphp/cluster/blob/33e7b71902ce85c221d4d3d35d4bd879af052686/src/Cluster.php#L108-L129 | train |
amphp/cluster | src/Cluster.php | Cluster.onReceivedMessage | private static function onReceivedMessage(string $event, $data)
{
foreach (self::$onMessage[$event] ?? [] as $callback) {
asyncCall($callback, $data);
}
} | php | private static function onReceivedMessage(string $event, $data)
{
foreach (self::$onMessage[$event] ?? [] as $callback) {
asyncCall($callback, $data);
}
} | [
"private",
"static",
"function",
"onReceivedMessage",
"(",
"string",
"$",
"event",
",",
"$",
"data",
")",
"{",
"foreach",
"(",
"self",
"::",
"$",
"onMessage",
"[",
"$",
"event",
"]",
"??",
"[",
"]",
"as",
"$",
"callback",
")",
"{",
"asyncCall",
"(",
... | Internal callback triggered when a message is received from the parent.
@param string $event
@param mixed $data | [
"Internal",
"callback",
"triggered",
"when",
"a",
"message",
"is",
"received",
"from",
"the",
"parent",
"."
] | 33e7b71902ce85c221d4d3d35d4bd879af052686 | https://github.com/amphp/cluster/blob/33e7b71902ce85c221d4d3d35d4bd879af052686/src/Cluster.php#L182-L187 | train |
amphp/cluster | src/Cluster.php | Cluster.createLogHandler | public static function createLogHandler(string $logLevel = LogLevel::DEBUG, bool $bubble = false): HandlerInterface
{
if (!self::isWorker()) {
throw new \Error(__FUNCTION__ . " should only be called when running as a worker. " .
"Create your own log handler when not running as part of a cluster");
}
return new Internal\IpcLogHandler(self::$client, $logLevel, $bubble);
} | php | public static function createLogHandler(string $logLevel = LogLevel::DEBUG, bool $bubble = false): HandlerInterface
{
if (!self::isWorker()) {
throw new \Error(__FUNCTION__ . " should only be called when running as a worker. " .
"Create your own log handler when not running as part of a cluster");
}
return new Internal\IpcLogHandler(self::$client, $logLevel, $bubble);
} | [
"public",
"static",
"function",
"createLogHandler",
"(",
"string",
"$",
"logLevel",
"=",
"LogLevel",
"::",
"DEBUG",
",",
"bool",
"$",
"bubble",
"=",
"false",
")",
":",
"HandlerInterface",
"{",
"if",
"(",
"!",
"self",
"::",
"isWorker",
"(",
")",
")",
"{",... | Creates a log handler in worker processes that communicates log messages to the parent.
@param string $logLevel Log level for the IPC handler
@param bool $bubble Bubble flag for the IPC handler
@return HandlerInterface
@throws \Error Thrown if not running as a worker. | [
"Creates",
"a",
"log",
"handler",
"in",
"worker",
"processes",
"that",
"communicates",
"log",
"messages",
"to",
"the",
"parent",
"."
] | 33e7b71902ce85c221d4d3d35d4bd879af052686 | https://github.com/amphp/cluster/blob/33e7b71902ce85c221d4d3d35d4bd879af052686/src/Cluster.php#L254-L262 | train |
Divergence/framework | src/Helpers/Util.php | Util.prepareOptions | public static function prepareOptions($value, $defaults = [])
{
if (is_string($value)) {
$value = json_decode($value, true);
}
return is_array($value) ? array_merge($defaults, $value) : $defaults;
} | php | public static function prepareOptions($value, $defaults = [])
{
if (is_string($value)) {
$value = json_decode($value, true);
}
return is_array($value) ? array_merge($defaults, $value) : $defaults;
} | [
"public",
"static",
"function",
"prepareOptions",
"(",
"$",
"value",
",",
"$",
"defaults",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"json_decode",
"(",
"$",
"value",
",",
"true",
")",
";"... | Prepares options.
@param string|array $value Option. If provided a string will be assumed to be json and it will attempt to json_decode it and merge it with defaults. Or provide the array yourself.
@param array $defaults Defaults for the options array
@return array Merged array from $defaults and $value | [
"Prepares",
"options",
"."
] | daaf78aa4b10ad59bf52b9e31480c748ad82e8c3 | https://github.com/Divergence/framework/blob/daaf78aa4b10ad59bf52b9e31480c748ad82e8c3/src/Helpers/Util.php#L27-L34 | train |
FastFeed/FastFeed | src/Aggregator/EzRSSAggregator.php | EzRSSAggregator.process | public function process(DOMElement $node, Item $item)
{
foreach ($this->keys as $key) {
$item->setExtra($key, $this->getValue($node, $key));
}
} | php | public function process(DOMElement $node, Item $item)
{
foreach ($this->keys as $key) {
$item->setExtra($key, $this->getValue($node, $key));
}
} | [
"public",
"function",
"process",
"(",
"DOMElement",
"$",
"node",
",",
"Item",
"$",
"item",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"keys",
"as",
"$",
"key",
")",
"{",
"$",
"item",
"->",
"setExtra",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"g... | Execute the Aggregator
@param DOMElement $node
@param Item $item | [
"Execute",
"the",
"Aggregator"
] | 2c8fbf91d37969b61fadefb4d647f2a366159c88 | https://github.com/FastFeed/FastFeed/blob/2c8fbf91d37969b61fadefb4d647f2a366159c88/src/Aggregator/EzRSSAggregator.php#L33-L38 | train |
dynamic/foxystripe | src/ORM/CustomerExtension.php | CustomerExtension.onAfterWrite | public function onAfterWrite()
{
parent::onAfterWrite();
if ($this->owner->PasswordEncryption != Security::config()->get('password_encryption_algorithm')) {
$this->resetPasswordEncryption();
}
} | php | public function onAfterWrite()
{
parent::onAfterWrite();
if ($this->owner->PasswordEncryption != Security::config()->get('password_encryption_algorithm')) {
$this->resetPasswordEncryption();
}
} | [
"public",
"function",
"onAfterWrite",
"(",
")",
"{",
"parent",
"::",
"onAfterWrite",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"owner",
"->",
"PasswordEncryption",
"!=",
"Security",
"::",
"config",
"(",
")",
"->",
"get",
"(",
"'password_encryption_algorit... | If the PasswordEncryption for the current membrer is different than the default, update to the default. | [
"If",
"the",
"PasswordEncryption",
"for",
"the",
"current",
"membrer",
"is",
"different",
"than",
"the",
"default",
"update",
"to",
"the",
"default",
"."
] | cfffae6021788de18fd78489753821f7faf5b9a9 | https://github.com/dynamic/foxystripe/blob/cfffae6021788de18fd78489753821f7faf5b9a9/src/ORM/CustomerExtension.php#L83-L90 | train |
dynamic/foxystripe | src/ORM/CustomerExtension.php | CustomerExtension.setDataFromTransaction | public function setDataFromTransaction($transaction)
{
foreach ($this->owner->config()->get('customer_map') as $type => $map) {
switch ($type) {
case 'int':
foreach ($map as $foxyField => $foxyStripeField) {
if ((int)$transaction->{$foxyField}) {
$this->owner->{$foxyStripeField} = (int)$transaction->{$foxyField};
}
}
break;
case 'string':
foreach ($map as $foxyField => $foxyStripeField) {
if ((string)$transaction->{$foxyField}) {
$this->owner->{$foxyStripeField} = (string)$transaction->{$foxyField};
}
}
break;
}
}
$this->owner->PasswordEncryption = 'none';
return $this->owner;
} | php | public function setDataFromTransaction($transaction)
{
foreach ($this->owner->config()->get('customer_map') as $type => $map) {
switch ($type) {
case 'int':
foreach ($map as $foxyField => $foxyStripeField) {
if ((int)$transaction->{$foxyField}) {
$this->owner->{$foxyStripeField} = (int)$transaction->{$foxyField};
}
}
break;
case 'string':
foreach ($map as $foxyField => $foxyStripeField) {
if ((string)$transaction->{$foxyField}) {
$this->owner->{$foxyStripeField} = (string)$transaction->{$foxyField};
}
}
break;
}
}
$this->owner->PasswordEncryption = 'none';
return $this->owner;
} | [
"public",
"function",
"setDataFromTransaction",
"(",
"$",
"transaction",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"owner",
"->",
"config",
"(",
")",
"->",
"get",
"(",
"'customer_map'",
")",
"as",
"$",
"type",
"=>",
"$",
"map",
")",
"{",
"switch",
"... | Use the config setting for Member mapping the Foxy fields to the SilverStripe fields.
@param $transaction | [
"Use",
"the",
"config",
"setting",
"for",
"Member",
"mapping",
"the",
"Foxy",
"fields",
"to",
"the",
"SilverStripe",
"fields",
"."
] | cfffae6021788de18fd78489753821f7faf5b9a9 | https://github.com/dynamic/foxystripe/blob/cfffae6021788de18fd78489753821f7faf5b9a9/src/ORM/CustomerExtension.php#L97-L120 | train |
dynamic/foxystripe | src/ORM/CustomerExtension.php | CustomerExtension.resetPasswordEncryption | private function resetPasswordEncryption()
{
$defaultEncryption = Security::config()->get('password_encryption_algorithm');
if ($this->owner->PasswordEncryption != $defaultEncryption) {
DB::prepared_query(
'UPDATE "Member" SET "PasswordEncryption" = ? WHERE ID = ?',
[$defaultEncryption, $this->owner->ID]
);
}
} | php | private function resetPasswordEncryption()
{
$defaultEncryption = Security::config()->get('password_encryption_algorithm');
if ($this->owner->PasswordEncryption != $defaultEncryption) {
DB::prepared_query(
'UPDATE "Member" SET "PasswordEncryption" = ? WHERE ID = ?',
[$defaultEncryption, $this->owner->ID]
);
}
} | [
"private",
"function",
"resetPasswordEncryption",
"(",
")",
"{",
"$",
"defaultEncryption",
"=",
"Security",
"::",
"config",
"(",
")",
"->",
"get",
"(",
"'password_encryption_algorithm'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"owner",
"->",
"PasswordEncryption"... | Reset the password encryption for the member to the config default.
Passwords from Foxy are encrypted so the encryption type is set to "none" when processing
the account from the data feed. Reseting is required for login to work on the website. | [
"Reset",
"the",
"password",
"encryption",
"for",
"the",
"member",
"to",
"the",
"config",
"default",
".",
"Passwords",
"from",
"Foxy",
"are",
"encrypted",
"so",
"the",
"encryption",
"type",
"is",
"set",
"to",
"none",
"when",
"processing",
"the",
"account",
"f... | cfffae6021788de18fd78489753821f7faf5b9a9 | https://github.com/dynamic/foxystripe/blob/cfffae6021788de18fd78489753821f7faf5b9a9/src/ORM/CustomerExtension.php#L127-L136 | train |
IDCI-Consulting/ExtraFormBundle | Configuration/Builder/ExtraFormBuilder.php | ExtraFormBuilder.buildConstraint | protected function buildConstraint(array $constraint)
{
$extraFormConstraint = $this
->constraintRegistry
->getConstraint($constraint['extra_form_constraint'])
;
$className = $extraFormConstraint->getClassName();
$options = isset($constraint['options']) ? $constraint['options'] : array();
return new $className($options);
} | php | protected function buildConstraint(array $constraint)
{
$extraFormConstraint = $this
->constraintRegistry
->getConstraint($constraint['extra_form_constraint'])
;
$className = $extraFormConstraint->getClassName();
$options = isset($constraint['options']) ? $constraint['options'] : array();
return new $className($options);
} | [
"protected",
"function",
"buildConstraint",
"(",
"array",
"$",
"constraint",
")",
"{",
"$",
"extraFormConstraint",
"=",
"$",
"this",
"->",
"constraintRegistry",
"->",
"getConstraint",
"(",
"$",
"constraint",
"[",
"'extra_form_constraint'",
"]",
")",
";",
"$",
"c... | Build constraint.
@param array $constraint
@return Symfony\Component\Validator\Constraint | [
"Build",
"constraint",
"."
] | 3481c69fd078754f3d0c5947dd59a5536ed13da0 | https://github.com/IDCI-Consulting/ExtraFormBundle/blob/3481c69fd078754f3d0c5947dd59a5536ed13da0/Configuration/Builder/ExtraFormBuilder.php#L141-L152 | train |
IDCI-Consulting/ExtraFormBundle | Configuration/Builder/ExtraFormBuilder.php | ExtraFormBuilder.buildFormOptions | protected function buildFormOptions($name, array $field, $data = null)
{
// Allow sub options structure (collection case)
if (isset($field['options']['constraints'])) {
$field['options']['options'] = $this->buildFormOptions('', $field['options']);
}
$constraints = array();
foreach ($field['constraints'] as $constraint) {
$constraints[] = $this->buildConstraint($constraint);
}
$field['options']['constraints'] = $constraints;
if (null !== $data && isset($data[$name])) {
$field['options']['data'] = $data[$name];
}
return $field['options'];
} | php | protected function buildFormOptions($name, array $field, $data = null)
{
// Allow sub options structure (collection case)
if (isset($field['options']['constraints'])) {
$field['options']['options'] = $this->buildFormOptions('', $field['options']);
}
$constraints = array();
foreach ($field['constraints'] as $constraint) {
$constraints[] = $this->buildConstraint($constraint);
}
$field['options']['constraints'] = $constraints;
if (null !== $data && isset($data[$name])) {
$field['options']['data'] = $data[$name];
}
return $field['options'];
} | [
"protected",
"function",
"buildFormOptions",
"(",
"$",
"name",
",",
"array",
"$",
"field",
",",
"$",
"data",
"=",
"null",
")",
"{",
"// Allow sub options structure (collection case)",
"if",
"(",
"isset",
"(",
"$",
"field",
"[",
"'options'",
"]",
"[",
"'constra... | Build form options.
@param string $name
@param array $field
@param array|null $data
@return array | [
"Build",
"form",
"options",
"."
] | 3481c69fd078754f3d0c5947dd59a5536ed13da0 | https://github.com/IDCI-Consulting/ExtraFormBundle/blob/3481c69fd078754f3d0c5947dd59a5536ed13da0/Configuration/Builder/ExtraFormBuilder.php#L163-L182 | train |
dynamic/foxystripe | src/Controller/DonationProductController.php | DonationProductController.updatevalue | public function updatevalue(\SilverStripe\Control\HTTPRequest $request)
{
if ($request->getVar('Price') && FoxyStripeSetting::current_foxystripe_setting()->CartValidation) {
$vars = $request->getVars();
$signedPrice = FoxyCart_Helper::fc_hash_value($this->Code, 'price', $vars['Price'], 'name', false);
$json = json_encode(['Price' => $signedPrice]);
$this->response->setBody($json);
$this->response->addHeader('Content-Type', 'application/json');
return $this->response;
}
return 'false';
} | php | public function updatevalue(\SilverStripe\Control\HTTPRequest $request)
{
if ($request->getVar('Price') && FoxyStripeSetting::current_foxystripe_setting()->CartValidation) {
$vars = $request->getVars();
$signedPrice = FoxyCart_Helper::fc_hash_value($this->Code, 'price', $vars['Price'], 'name', false);
$json = json_encode(['Price' => $signedPrice]);
$this->response->setBody($json);
$this->response->addHeader('Content-Type', 'application/json');
return $this->response;
}
return 'false';
} | [
"public",
"function",
"updatevalue",
"(",
"\\",
"SilverStripe",
"\\",
"Control",
"\\",
"HTTPRequest",
"$",
"request",
")",
"{",
"if",
"(",
"$",
"request",
"->",
"getVar",
"(",
"'Price'",
")",
"&&",
"FoxyStripeSetting",
"::",
"current_foxystripe_setting",
"(",
... | create new encrypted price value based on user input.
@param $request
@return string|\SilverStripe\Control\HTTPResponse | [
"create",
"new",
"encrypted",
"price",
"value",
"based",
"on",
"user",
"input",
"."
] | cfffae6021788de18fd78489753821f7faf5b9a9 | https://github.com/dynamic/foxystripe/blob/cfffae6021788de18fd78489753821f7faf5b9a9/src/Controller/DonationProductController.php#L73-L87 | train |
FastFeed/FastFeed | src/FastFeed.php | FastFeed.addFeed | public function addFeed($channel, $feed)
{
if (!filter_var($feed, FILTER_VALIDATE_URL)) {
throw new LogicException('You tried to add a invalid url.');
}
$this->feeds[$channel][] = $feed;
} | php | public function addFeed($channel, $feed)
{
if (!filter_var($feed, FILTER_VALIDATE_URL)) {
throw new LogicException('You tried to add a invalid url.');
}
$this->feeds[$channel][] = $feed;
} | [
"public",
"function",
"addFeed",
"(",
"$",
"channel",
",",
"$",
"feed",
")",
"{",
"if",
"(",
"!",
"filter_var",
"(",
"$",
"feed",
",",
"FILTER_VALIDATE_URL",
")",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"'You tried to add a invalid url.'",
")",
";",... | Add feed to channel
@param string $channel
@param string $feed
@throws LogicException | [
"Add",
"feed",
"to",
"channel"
] | 2c8fbf91d37969b61fadefb4d647f2a366159c88 | https://github.com/FastFeed/FastFeed/blob/2c8fbf91d37969b61fadefb4d647f2a366159c88/src/FastFeed.php#L87-L93 | train |
FastFeed/FastFeed | src/FastFeed.php | FastFeed.getFeed | public function getFeed($channel)
{
if (!isset($this->feeds[$channel])) {
throw new LogicException('You tried to get a not existent channel');
}
return $this->feeds[$channel];
} | php | public function getFeed($channel)
{
if (!isset($this->feeds[$channel])) {
throw new LogicException('You tried to get a not existent channel');
}
return $this->feeds[$channel];
} | [
"public",
"function",
"getFeed",
"(",
"$",
"channel",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"feeds",
"[",
"$",
"channel",
"]",
")",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"'You tried to get a not existent channel'",
")",
";",... | Retrieve a channel
@param string $channel
@return string
@throws LogicException | [
"Retrieve",
"a",
"channel"
] | 2c8fbf91d37969b61fadefb4d647f2a366159c88 | https://github.com/FastFeed/FastFeed/blob/2c8fbf91d37969b61fadefb4d647f2a366159c88/src/FastFeed.php#L124-L131 | train |
FastFeed/FastFeed | src/FastFeed.php | FastFeed.setFeed | public function setFeed($channel, $feed)
{
if (!is_string($channel)) {
throw new LogicException('You tried to add a invalid channel.');
}
$this->feeds[$channel] = array();
$this->addFeed($channel, $feed);
} | php | public function setFeed($channel, $feed)
{
if (!is_string($channel)) {
throw new LogicException('You tried to add a invalid channel.');
}
$this->feeds[$channel] = array();
$this->addFeed($channel, $feed);
} | [
"public",
"function",
"setFeed",
"(",
"$",
"channel",
",",
"$",
"feed",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"channel",
")",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"'You tried to add a invalid channel.'",
")",
";",
"}",
"$",
"this",
... | Set a channel
@param string $channel
@param string $feed
@throws LogicException | [
"Set",
"a",
"channel"
] | 2c8fbf91d37969b61fadefb4d647f2a366159c88 | https://github.com/FastFeed/FastFeed/blob/2c8fbf91d37969b61fadefb4d647f2a366159c88/src/FastFeed.php#L211-L218 | train |
FastFeed/FastFeed | src/FastFeed.php | FastFeed.get | protected function get($url)
{
$request = $this->http->get(
$url,
array('User-Agent' => self::USER_AGENT.' v.'.self::VERSION)
);
$response = $request->send();
if (!$response->isSuccessful()) {
$this->log('fail with '.$response->getStatusCode().' http code in url "'.$url.'" ');
return;
}
$this->logger->log(LogLevel::INFO, 'retrieved url "'.$url.'" ');
return $response->getBody();
} | php | protected function get($url)
{
$request = $this->http->get(
$url,
array('User-Agent' => self::USER_AGENT.' v.'.self::VERSION)
);
$response = $request->send();
if (!$response->isSuccessful()) {
$this->log('fail with '.$response->getStatusCode().' http code in url "'.$url.'" ');
return;
}
$this->logger->log(LogLevel::INFO, 'retrieved url "'.$url.'" ');
return $response->getBody();
} | [
"protected",
"function",
"get",
"(",
"$",
"url",
")",
"{",
"$",
"request",
"=",
"$",
"this",
"->",
"http",
"->",
"get",
"(",
"$",
"url",
",",
"array",
"(",
"'User-Agent'",
"=>",
"self",
"::",
"USER_AGENT",
".",
"' v.'",
".",
"self",
"::",
"VERSION",
... | Retrieve content from a resource
@param $url
@return \Guzzle\Http\EntityBodyInterface|string | [
"Retrieve",
"content",
"from",
"a",
"resource"
] | 2c8fbf91d37969b61fadefb4d647f2a366159c88 | https://github.com/FastFeed/FastFeed/blob/2c8fbf91d37969b61fadefb4d647f2a366159c88/src/FastFeed.php#L227-L244 | train |
alphazygma/Combinatorics | src/Math/Combinatorics/Permutation.php | Permutation.getPermutations | public function getPermutations(array $sourceDataSet, $subsetSize = null)
{
$combinationMap = $this->_combination->getCombinations($sourceDataSet, $subsetSize);
$permutationsMap = [];
foreach ($combinationMap as $combination) {
$permutationsMap = array_merge(
$permutationsMap,
$this->_findPermutations($combination)
);
}
return $permutationsMap;
} | php | public function getPermutations(array $sourceDataSet, $subsetSize = null)
{
$combinationMap = $this->_combination->getCombinations($sourceDataSet, $subsetSize);
$permutationsMap = [];
foreach ($combinationMap as $combination) {
$permutationsMap = array_merge(
$permutationsMap,
$this->_findPermutations($combination)
);
}
return $permutationsMap;
} | [
"public",
"function",
"getPermutations",
"(",
"array",
"$",
"sourceDataSet",
",",
"$",
"subsetSize",
"=",
"null",
")",
"{",
"$",
"combinationMap",
"=",
"$",
"this",
"->",
"_combination",
"->",
"getCombinations",
"(",
"$",
"sourceDataSet",
",",
"$",
"subsetSize... | Creates all the possible permutations for the source data set.
@param array $sourceDataSet The source data from which to calculate permutations.
@param int $subsetSize (Optional)<br/>If supplied, only permutations of the indicated
size will be returned.
<p>If the subset size is greater than the source data set size, only permutations for
the wil be calculated for largest SET.</p>
<p>If the subset size is less or equal to 0, only one permutation will be returned with
no elements.</p>
@return array A list of arrays containing all the combinations from the source data set. | [
"Creates",
"all",
"the",
"possible",
"permutations",
"for",
"the",
"source",
"data",
"set",
"."
] | 153d096119d21190a32bbe567f1eec367e2f4709 | https://github.com/alphazygma/Combinatorics/blob/153d096119d21190a32bbe567f1eec367e2f4709/src/Math/Combinatorics/Permutation.php#L70-L83 | train |
alphazygma/Combinatorics | src/Math/Combinatorics/Permutation.php | Permutation._findPermutations | private function _findPermutations($combination)
{
// If the combination only has 1 element, then the permutation is the same as the combination
if (count($combination) <= 1) {
return [$combination];
}
$permutationList = [];
$startKey = $this->_processSubPermutations($combination, $permutationList);
// Now that the first element has been rotated to the end, we calculate permutations until
// we reach the first element which is now at the end of the combiatnion.
$key = key($combination);
while ($key != $startKey) {
$this->_processSubPermutations($combination, $permutationList);
$key = key($combination);
}
return $permutationList;
} | php | private function _findPermutations($combination)
{
// If the combination only has 1 element, then the permutation is the same as the combination
if (count($combination) <= 1) {
return [$combination];
}
$permutationList = [];
$startKey = $this->_processSubPermutations($combination, $permutationList);
// Now that the first element has been rotated to the end, we calculate permutations until
// we reach the first element which is now at the end of the combiatnion.
$key = key($combination);
while ($key != $startKey) {
$this->_processSubPermutations($combination, $permutationList);
$key = key($combination);
}
return $permutationList;
} | [
"private",
"function",
"_findPermutations",
"(",
"$",
"combination",
")",
"{",
"// If the combination only has 1 element, then the permutation is the same as the combination",
"if",
"(",
"count",
"(",
"$",
"combination",
")",
"<=",
"1",
")",
"{",
"return",
"[",
"$",
"co... | Recursive function to find the permutations of the given combination.
@param array $combination Current combination set
@return array Permutations of the current combination | [
"Recursive",
"function",
"to",
"find",
"the",
"permutations",
"of",
"the",
"given",
"combination",
"."
] | 153d096119d21190a32bbe567f1eec367e2f4709 | https://github.com/alphazygma/Combinatorics/blob/153d096119d21190a32bbe567f1eec367e2f4709/src/Math/Combinatorics/Permutation.php#L91-L111 | train |
agoat/contao-customcontentelements-bundle | src/Resources/contao/elements/ContentElement.php | ContentElement.generate | public function generate()
{
// Get the content element object
$this->objElement = \ElementsModel::findPublishedByAlias($this->type);
if ($this->objElement === null)
{
return;
}
// Register the custom template
if (!array_key_exists($this->objElement->template, TemplateLoader::getFiles()))
{
TemplateLoader::addFile($this->objElement->template, $this->objElement->getRelated('pid')->templates);
}
if (TL_MODE == 'BE' && $this->objElement->backendTpl)
{
$this->strTemplate = $this->objElement->backendTpl;
}
else
{
$this->strTemplate = $this->objElement->template;
}
if (TL_MODE == 'FE' && !BE_USER_LOGGED_IN && ($this->invisible || ($this->start != '' && $this->start > time()) || ($this->stop != '' && $this->stop < time())))
{
return '';
}
$this->Template = new Template($this->strTemplate);
// Deliver some general element data
$this->Template->setData(
array (
'id' => $this->id,
'pid' => $this->pid,
'ptable' => $this->ptable,
'element' => $this->type,
'tstamp' => $this->tstamp,
'start' => $this->start,
'stop' => $this->stop,
'protected' => $this->protected,
'inColumn' => $this->strColumn
)
);
// compile pattern to prepare values
$this->compile();
return $this->Template->parse();
} | php | public function generate()
{
// Get the content element object
$this->objElement = \ElementsModel::findPublishedByAlias($this->type);
if ($this->objElement === null)
{
return;
}
// Register the custom template
if (!array_key_exists($this->objElement->template, TemplateLoader::getFiles()))
{
TemplateLoader::addFile($this->objElement->template, $this->objElement->getRelated('pid')->templates);
}
if (TL_MODE == 'BE' && $this->objElement->backendTpl)
{
$this->strTemplate = $this->objElement->backendTpl;
}
else
{
$this->strTemplate = $this->objElement->template;
}
if (TL_MODE == 'FE' && !BE_USER_LOGGED_IN && ($this->invisible || ($this->start != '' && $this->start > time()) || ($this->stop != '' && $this->stop < time())))
{
return '';
}
$this->Template = new Template($this->strTemplate);
// Deliver some general element data
$this->Template->setData(
array (
'id' => $this->id,
'pid' => $this->pid,
'ptable' => $this->ptable,
'element' => $this->type,
'tstamp' => $this->tstamp,
'start' => $this->start,
'stop' => $this->stop,
'protected' => $this->protected,
'inColumn' => $this->strColumn
)
);
// compile pattern to prepare values
$this->compile();
return $this->Template->parse();
} | [
"public",
"function",
"generate",
"(",
")",
"{",
"// Get the content element object",
"$",
"this",
"->",
"objElement",
"=",
"\\",
"ElementsModel",
"::",
"findPublishedByAlias",
"(",
"$",
"this",
"->",
"type",
")",
";",
"if",
"(",
"$",
"this",
"->",
"objElement... | Generate the pattern data and parse the elements template
@return string | [
"Generate",
"the",
"pattern",
"data",
"and",
"parse",
"the",
"elements",
"template"
] | a74d880d74352d2ed887e13f29115bbc48ad84cc | https://github.com/agoat/contao-customcontentelements-bundle/blob/a74d880d74352d2ed887e13f29115bbc48ad84cc/src/Resources/contao/elements/ContentElement.php#L67-L118 | train |
agoat/contao-customcontentelements-bundle | src/Resources/contao/elements/ContentElement.php | ContentElement.compile | protected function compile()
{
// Get the pattern model collection
$colPattern = \PatternModel::findVisibleByPid($this->objElement->id);
if ($colPattern === null)
{
return;
}
// Get correct content element id (included content element) see #37
$intPid = ($this->origId) ? $this->origId : $this->id;
// Get the data
$colData = \DataModel::findByPid($intPid);
if ($colData !== null)
{
foreach ($colData as $objData)
{
$arrData[$objData->pattern] = $objData;
}
}
// Prepare values for every pattern
foreach($colPattern as $objPattern)
{
if (!Pattern::hasOutput($objPattern->type))
{
continue;
}
$strClass = Pattern::findClass($objPattern->type);
if (!class_exists($strClass))
{
System::log('Pattern element class "'.$strClass.'" (pattern element "'.$objPattern->type.'") does not exist', __METHOD__, TL_ERROR);
}
else
{
$objPatternClass = new $strClass($objPattern);
$objPatternClass->pid = $intPid;
$objPatternClass->Template = $this->Template;
$objPatternClass->data = $arrData[$objPattern->alias];
$objPatternClass->compile();
}
}
} | php | protected function compile()
{
// Get the pattern model collection
$colPattern = \PatternModel::findVisibleByPid($this->objElement->id);
if ($colPattern === null)
{
return;
}
// Get correct content element id (included content element) see #37
$intPid = ($this->origId) ? $this->origId : $this->id;
// Get the data
$colData = \DataModel::findByPid($intPid);
if ($colData !== null)
{
foreach ($colData as $objData)
{
$arrData[$objData->pattern] = $objData;
}
}
// Prepare values for every pattern
foreach($colPattern as $objPattern)
{
if (!Pattern::hasOutput($objPattern->type))
{
continue;
}
$strClass = Pattern::findClass($objPattern->type);
if (!class_exists($strClass))
{
System::log('Pattern element class "'.$strClass.'" (pattern element "'.$objPattern->type.'") does not exist', __METHOD__, TL_ERROR);
}
else
{
$objPatternClass = new $strClass($objPattern);
$objPatternClass->pid = $intPid;
$objPatternClass->Template = $this->Template;
$objPatternClass->data = $arrData[$objPattern->alias];
$objPatternClass->compile();
}
}
} | [
"protected",
"function",
"compile",
"(",
")",
"{",
"// Get the pattern model collection",
"$",
"colPattern",
"=",
"\\",
"PatternModel",
"::",
"findVisibleByPid",
"(",
"$",
"this",
"->",
"objElement",
"->",
"id",
")",
";",
"if",
"(",
"$",
"colPattern",
"===",
"... | Compile the pattern | [
"Compile",
"the",
"pattern"
] | a74d880d74352d2ed887e13f29115bbc48ad84cc | https://github.com/agoat/contao-customcontentelements-bundle/blob/a74d880d74352d2ed887e13f29115bbc48ad84cc/src/Resources/contao/elements/ContentElement.php#L124-L172 | train |
Divergence/framework | src/Controllers/RequestHandler.php | RequestHandler.setPath | protected static function setPath($path = null)
{
if (!static::$pathStack) {
$requestURI = parse_url($_SERVER['REQUEST_URI']);
static::$pathStack = static::$requestPath = explode('/', ltrim($requestURI['path'], '/'));
}
static::$_path = isset($path) ? $path : static::$pathStack;
} | php | protected static function setPath($path = null)
{
if (!static::$pathStack) {
$requestURI = parse_url($_SERVER['REQUEST_URI']);
static::$pathStack = static::$requestPath = explode('/', ltrim($requestURI['path'], '/'));
}
static::$_path = isset($path) ? $path : static::$pathStack;
} | [
"protected",
"static",
"function",
"setPath",
"(",
"$",
"path",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"static",
"::",
"$",
"pathStack",
")",
"{",
"$",
"requestURI",
"=",
"parse_url",
"(",
"$",
"_SERVER",
"[",
"'REQUEST_URI'",
"]",
")",
";",
"static",
... | protected static methods | [
"protected",
"static",
"methods"
] | daaf78aa4b10ad59bf52b9e31480c748ad82e8c3 | https://github.com/Divergence/framework/blob/daaf78aa4b10ad59bf52b9e31480c748ad82e8c3/src/Controllers/RequestHandler.php#L81-L89 | train |
IDCI-Consulting/ExtraFormBundle | Form/DataTransformer/IbanToArrayTransformer.php | IbanToArrayTransformer.reverseTransform | public function reverseTransform($out)
{
if (null !== $out && is_array($out)) {
return strtoupper(
sprintf(
'%s%s%s%s%s%s%s%s',
$out['c1'],
$out['c2'],
$out['c3'],
$out['c4'],
$out['c5'],
$out['c6'],
$out['c7'],
$out['c8']
)
);
}
return $out;
} | php | public function reverseTransform($out)
{
if (null !== $out && is_array($out)) {
return strtoupper(
sprintf(
'%s%s%s%s%s%s%s%s',
$out['c1'],
$out['c2'],
$out['c3'],
$out['c4'],
$out['c5'],
$out['c6'],
$out['c7'],
$out['c8']
)
);
}
return $out;
} | [
"public",
"function",
"reverseTransform",
"(",
"$",
"out",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"out",
"&&",
"is_array",
"(",
"$",
"out",
")",
")",
"{",
"return",
"strtoupper",
"(",
"sprintf",
"(",
"'%s%s%s%s%s%s%s%s'",
",",
"$",
"out",
"[",
"'c1'"... | Reverse transforms.
@param array $out
@return string | [
"Reverse",
"transforms",
"."
] | 3481c69fd078754f3d0c5947dd59a5536ed13da0 | https://github.com/IDCI-Consulting/ExtraFormBundle/blob/3481c69fd078754f3d0c5947dd59a5536ed13da0/Form/DataTransformer/IbanToArrayTransformer.php#L48-L67 | train |
agoat/contao-customcontentelements-bundle | src/Resources/contao/dca/tl_elements.php | tl_elements.setDefaultType | public function setDefaultType ($value, DataContainer $dc)
{
$db = Database::getInstance();
if ($value)
{
// There can only be one default element
$db->prepare("UPDATE tl_elements SET defaultType='' WHERE NOT id=? AND pid=?")
->execute($dc->activeRecord->id, $dc->activeRecord->pid);
}
return $value;
} | php | public function setDefaultType ($value, DataContainer $dc)
{
$db = Database::getInstance();
if ($value)
{
// There can only be one default element
$db->prepare("UPDATE tl_elements SET defaultType='' WHERE NOT id=? AND pid=?")
->execute($dc->activeRecord->id, $dc->activeRecord->pid);
}
return $value;
} | [
"public",
"function",
"setDefaultType",
"(",
"$",
"value",
",",
"DataContainer",
"$",
"dc",
")",
"{",
"$",
"db",
"=",
"Database",
"::",
"getInstance",
"(",
")",
";",
"if",
"(",
"$",
"value",
")",
"{",
"// There can only be one default element",
"$",
"db",
... | Reset all other default type settings
@param mixed $value
@param DataContainer $dc
@return mixed | [
"Reset",
"all",
"other",
"default",
"type",
"settings"
] | a74d880d74352d2ed887e13f29115bbc48ad84cc | https://github.com/agoat/contao-customcontentelements-bundle/blob/a74d880d74352d2ed887e13f29115bbc48ad84cc/src/Resources/contao/dca/tl_elements.php#L283-L295 | train |
agoat/contao-customcontentelements-bundle | src/Resources/contao/dca/tl_elements.php | tl_elements.checkTitle | public function checkTitle ($value, DataContainer $dc)
{
$db = Database::getInstance();
$objTitle = $db->prepare("SELECT id FROM tl_elements WHERE NOT id=? AND pid=? AND title=?")
->execute($dc->activeRecord->id, $dc->activeRecord->pid, $value);
if ($objTitle->numRows > 0)
{
throw new Exception(sprintf($GLOBALS['TL_LANG']['ERR']['aliasExists'], $value));
}
return $value;
} | php | public function checkTitle ($value, DataContainer $dc)
{
$db = Database::getInstance();
$objTitle = $db->prepare("SELECT id FROM tl_elements WHERE NOT id=? AND pid=? AND title=?")
->execute($dc->activeRecord->id, $dc->activeRecord->pid, $value);
if ($objTitle->numRows > 0)
{
throw new Exception(sprintf($GLOBALS['TL_LANG']['ERR']['aliasExists'], $value));
}
return $value;
} | [
"public",
"function",
"checkTitle",
"(",
"$",
"value",
",",
"DataContainer",
"$",
"dc",
")",
"{",
"$",
"db",
"=",
"Database",
"::",
"getInstance",
"(",
")",
";",
"$",
"objTitle",
"=",
"$",
"db",
"->",
"prepare",
"(",
"\"SELECT id FROM tl_elements WHERE NOT i... | Check if the title is not already in use
@param mixed $value
@param DataContainer $dc
@return mixed | [
"Check",
"if",
"the",
"title",
"is",
"not",
"already",
"in",
"use"
] | a74d880d74352d2ed887e13f29115bbc48ad84cc | https://github.com/agoat/contao-customcontentelements-bundle/blob/a74d880d74352d2ed887e13f29115bbc48ad84cc/src/Resources/contao/dca/tl_elements.php#L306-L319 | train |
agoat/contao-customcontentelements-bundle | src/Resources/contao/dca/tl_elements.php | tl_elements.generateAlias | public function generateAlias (DataContainer $dc)
{
$db = Database::getInstance();
// Generate alias from theme name and title
$alias = \StringUtil::generateAlias(\ThemeModel::findById($dc->activeRecord->pid)->name . '-' . $dc->activeRecord->title);
if ($alias != $dc->activeRecord->alias)
{
// Save alias to database
$db->prepare("UPDATE tl_elements SET alias=? WHERE id=?")
->execute($alias, $dc->activeRecord->id);
if ($dc->activeRecord->alias)
{
// Also change the type (=alias) in tl_content table
$db->prepare("UPDATE tl_content SET type=? WHERE type=?")
->execute($alias, $dc->activeRecord->alias);
}
}
} | php | public function generateAlias (DataContainer $dc)
{
$db = Database::getInstance();
// Generate alias from theme name and title
$alias = \StringUtil::generateAlias(\ThemeModel::findById($dc->activeRecord->pid)->name . '-' . $dc->activeRecord->title);
if ($alias != $dc->activeRecord->alias)
{
// Save alias to database
$db->prepare("UPDATE tl_elements SET alias=? WHERE id=?")
->execute($alias, $dc->activeRecord->id);
if ($dc->activeRecord->alias)
{
// Also change the type (=alias) in tl_content table
$db->prepare("UPDATE tl_content SET type=? WHERE type=?")
->execute($alias, $dc->activeRecord->alias);
}
}
} | [
"public",
"function",
"generateAlias",
"(",
"DataContainer",
"$",
"dc",
")",
"{",
"$",
"db",
"=",
"Database",
"::",
"getInstance",
"(",
")",
";",
"// Generate alias from theme name and title",
"$",
"alias",
"=",
"\\",
"StringUtil",
"::",
"generateAlias",
"(",
"\... | Auto-generate an element alias and adjust existing content in case the element is renamed
@param DataContainer $dc | [
"Auto",
"-",
"generate",
"an",
"element",
"alias",
"and",
"adjust",
"existing",
"content",
"in",
"case",
"the",
"element",
"is",
"renamed"
] | a74d880d74352d2ed887e13f29115bbc48ad84cc | https://github.com/agoat/contao-customcontentelements-bundle/blob/a74d880d74352d2ed887e13f29115bbc48ad84cc/src/Resources/contao/dca/tl_elements.php#L327-L347 | train |
agoat/contao-customcontentelements-bundle | src/Resources/contao/dca/tl_elements.php | tl_elements.getContentElementTemplates | public function getContentElementTemplates(DataContainer $dc)
{
$arrTemplates = array();
// Get the default templates
foreach (\TemplateLoader::getPrefixedFiles('ce_') as $strTemplate)
{
$arrTemplates[$strTemplate][] = 'root';
}
$arrCustomized = glob(TL_ROOT . '/templates/ce_*');
// Add the customized templates
if (is_array($arrCustomized))
{
foreach ($arrCustomized as $strFile)
{
$strTemplate = basename($strFile, strrchr($strFile, '.'));
$arrTemplates[$strTemplate][] = $GLOBALS['TL_LANG']['MSC']['global'];
}
}
// Add the customized theme templates
$theme = \ThemeModel::findById($dc->activeRecord->pid);
$arrCustomized = glob(TL_ROOT . '/' . $theme->templates . '/' . 'ce_*');
if (is_array($arrCustomized))
{
foreach ($arrCustomized as $strFile)
{
$strTemplate = basename($strFile, strrchr($strFile, '.'));
$arrTemplates[$strTemplate][] = $theme->name;
}
}
// Show the template sources
foreach ($arrTemplates as $k=>$v)
{
$v = array_filter($v, function($a) {
return $a != 'root';
});
if (empty($v))
{
$arrTemplates[$k] = $k;
}
else
{
$arrTemplates[$k] = $k . ' (' . implode(', ', $v) . ')';
}
}
// Sort the template names
ksort($arrTemplates);
return $arrTemplates;
} | php | public function getContentElementTemplates(DataContainer $dc)
{
$arrTemplates = array();
// Get the default templates
foreach (\TemplateLoader::getPrefixedFiles('ce_') as $strTemplate)
{
$arrTemplates[$strTemplate][] = 'root';
}
$arrCustomized = glob(TL_ROOT . '/templates/ce_*');
// Add the customized templates
if (is_array($arrCustomized))
{
foreach ($arrCustomized as $strFile)
{
$strTemplate = basename($strFile, strrchr($strFile, '.'));
$arrTemplates[$strTemplate][] = $GLOBALS['TL_LANG']['MSC']['global'];
}
}
// Add the customized theme templates
$theme = \ThemeModel::findById($dc->activeRecord->pid);
$arrCustomized = glob(TL_ROOT . '/' . $theme->templates . '/' . 'ce_*');
if (is_array($arrCustomized))
{
foreach ($arrCustomized as $strFile)
{
$strTemplate = basename($strFile, strrchr($strFile, '.'));
$arrTemplates[$strTemplate][] = $theme->name;
}
}
// Show the template sources
foreach ($arrTemplates as $k=>$v)
{
$v = array_filter($v, function($a) {
return $a != 'root';
});
if (empty($v))
{
$arrTemplates[$k] = $k;
}
else
{
$arrTemplates[$k] = $k . ' (' . implode(', ', $v) . ')';
}
}
// Sort the template names
ksort($arrTemplates);
return $arrTemplates;
} | [
"public",
"function",
"getContentElementTemplates",
"(",
"DataContainer",
"$",
"dc",
")",
"{",
"$",
"arrTemplates",
"=",
"array",
"(",
")",
";",
"// Get the default templates",
"foreach",
"(",
"\\",
"TemplateLoader",
"::",
"getPrefixedFiles",
"(",
"'ce_'",
")",
"a... | Return content element templates as array
@param DataContainer $dc
@return array | [
"Return",
"content",
"element",
"templates",
"as",
"array"
] | a74d880d74352d2ed887e13f29115bbc48ad84cc | https://github.com/agoat/contao-customcontentelements-bundle/blob/a74d880d74352d2ed887e13f29115bbc48ad84cc/src/Resources/contao/dca/tl_elements.php#L357-L412 | train |
agoat/contao-customcontentelements-bundle | src/Resources/contao/dca/tl_elements.php | tl_elements.editButton | public function editButton($row, $href, $label, $title, $icon, $attributes)
{
switch ($row['type'])
{
case 'group':
return \Image::getHtml(str_replace('.', '_.', $icon), $label) . ' ';
case 'element':
return '<a href="'.$this->addToUrl($href.'&id='.$row['id']).'" title="'.\StringUtil::specialchars($title).'"'.$attributes.'>'.\Image::getHtml($icon, $label).'</a> ';
}
} | php | public function editButton($row, $href, $label, $title, $icon, $attributes)
{
switch ($row['type'])
{
case 'group':
return \Image::getHtml(str_replace('.', '_.', $icon), $label) . ' ';
case 'element':
return '<a href="'.$this->addToUrl($href.'&id='.$row['id']).'" title="'.\StringUtil::specialchars($title).'"'.$attributes.'>'.\Image::getHtml($icon, $label).'</a> ';
}
} | [
"public",
"function",
"editButton",
"(",
"$",
"row",
",",
"$",
"href",
",",
"$",
"label",
",",
"$",
"title",
",",
"$",
"icon",
",",
"$",
"attributes",
")",
"{",
"switch",
"(",
"$",
"row",
"[",
"'type'",
"]",
")",
"{",
"case",
"'group'",
":",
"ret... | Return the pattern edit button
@param array $row
@param string $href
@param string $label
@param string $title
@param string $icon
@param string $attributes
@return string | [
"Return",
"the",
"pattern",
"edit",
"button"
] | a74d880d74352d2ed887e13f29115bbc48ad84cc | https://github.com/agoat/contao-customcontentelements-bundle/blob/a74d880d74352d2ed887e13f29115bbc48ad84cc/src/Resources/contao/dca/tl_elements.php#L455-L465 | train |
IDCI-Consulting/ExtraFormBundle | Repository/ConfiguredTypeRepository.php | ConfiguredTypeRepository.findByTags | public function findByTags(array $tags)
{
$qb = $this->createQueryBuilder('c');
foreach ($tags as $key => $tag) {
$operator = substr($tag, 0, 1);
if ($operator === '+' || $operator === '-') {
$tag = substr($tag, 1);
}
$literalExpr = $qb->expr()->literal('%'.$tag.'%');
if ($operator === '-') {
$qb->andWhere($qb->expr()->notLike('c.tags', $literalExpr));
} elseif ($operator === '+') {
$qb->andWhere($qb->expr()->like('c.tags', $literalExpr));
} elseif ($key === 0) {
$qb->where($qb->expr()->like('c.tags', $literalExpr));
} else {
$qb->orWhere($qb->expr()->like('c.tags', $literalExpr));
}
}
return $qb->getQuery()->getResult();
} | php | public function findByTags(array $tags)
{
$qb = $this->createQueryBuilder('c');
foreach ($tags as $key => $tag) {
$operator = substr($tag, 0, 1);
if ($operator === '+' || $operator === '-') {
$tag = substr($tag, 1);
}
$literalExpr = $qb->expr()->literal('%'.$tag.'%');
if ($operator === '-') {
$qb->andWhere($qb->expr()->notLike('c.tags', $literalExpr));
} elseif ($operator === '+') {
$qb->andWhere($qb->expr()->like('c.tags', $literalExpr));
} elseif ($key === 0) {
$qb->where($qb->expr()->like('c.tags', $literalExpr));
} else {
$qb->orWhere($qb->expr()->like('c.tags', $literalExpr));
}
}
return $qb->getQuery()->getResult();
} | [
"public",
"function",
"findByTags",
"(",
"array",
"$",
"tags",
")",
"{",
"$",
"qb",
"=",
"$",
"this",
"->",
"createQueryBuilder",
"(",
"'c'",
")",
";",
"foreach",
"(",
"$",
"tags",
"as",
"$",
"key",
"=>",
"$",
"tag",
")",
"{",
"$",
"operator",
"=",... | Find configured types by tags.
@return array | [
"Find",
"configured",
"types",
"by",
"tags",
"."
] | 3481c69fd078754f3d0c5947dd59a5536ed13da0 | https://github.com/IDCI-Consulting/ExtraFormBundle/blob/3481c69fd078754f3d0c5947dd59a5536ed13da0/Repository/ConfiguredTypeRepository.php#L22-L47 | train |
IDCI-Consulting/ExtraFormBundle | Repository/ConfiguredTypeRepository.php | ConfiguredTypeRepository.getAllTags | public function getAllTags()
{
$qb = $this->createQueryBuilder('c');
$qb
->select('c.tags')
->where($qb->expr()->isNotNull('c.tags'))
->distinct()
;
$tagStrings = array_map('current', $qb->getQuery()->getScalarResult());
$distinctTags = array();
foreach ($tagStrings as $tagString) {
foreach (explode(',', $tagString) as $tag) {
if (!in_array($tag, $distinctTags)) {
array_push($distinctTags, $tag);
}
}
}
return $distinctTags;
} | php | public function getAllTags()
{
$qb = $this->createQueryBuilder('c');
$qb
->select('c.tags')
->where($qb->expr()->isNotNull('c.tags'))
->distinct()
;
$tagStrings = array_map('current', $qb->getQuery()->getScalarResult());
$distinctTags = array();
foreach ($tagStrings as $tagString) {
foreach (explode(',', $tagString) as $tag) {
if (!in_array($tag, $distinctTags)) {
array_push($distinctTags, $tag);
}
}
}
return $distinctTags;
} | [
"public",
"function",
"getAllTags",
"(",
")",
"{",
"$",
"qb",
"=",
"$",
"this",
"->",
"createQueryBuilder",
"(",
"'c'",
")",
";",
"$",
"qb",
"->",
"select",
"(",
"'c.tags'",
")",
"->",
"where",
"(",
"$",
"qb",
"->",
"expr",
"(",
")",
"->",
"isNotNu... | Get all tags.
@return array | [
"Get",
"all",
"tags",
"."
] | 3481c69fd078754f3d0c5947dd59a5536ed13da0 | https://github.com/IDCI-Consulting/ExtraFormBundle/blob/3481c69fd078754f3d0c5947dd59a5536ed13da0/Repository/ConfiguredTypeRepository.php#L54-L76 | train |
BlueTeaNL/JIRA-Rest-API-PHP | src/Jira/Endpoint/UserEndpoint.php | UserEndpoint.find | public function find($username)
{
$parameters['username'] = $username;
return $this->apiClient->callEndpoint(self::ENDPOINT, $parameters);
} | php | public function find($username)
{
$parameters['username'] = $username;
return $this->apiClient->callEndpoint(self::ENDPOINT, $parameters);
} | [
"public",
"function",
"find",
"(",
"$",
"username",
")",
"{",
"$",
"parameters",
"[",
"'username'",
"]",
"=",
"$",
"username",
";",
"return",
"$",
"this",
"->",
"apiClient",
"->",
"callEndpoint",
"(",
"self",
"::",
"ENDPOINT",
",",
"$",
"parameters",
")"... | Returns a user. This resource cannot be accessed anonymously.
@param $username
@return mixed | [
"Returns",
"a",
"user",
".",
"This",
"resource",
"cannot",
"be",
"accessed",
"anonymously",
"."
] | 56309ee711f86d5bc085f391bba3e50155e14106 | https://github.com/BlueTeaNL/JIRA-Rest-API-PHP/blob/56309ee711f86d5bc085f391bba3e50155e14106/src/Jira/Endpoint/UserEndpoint.php#L19-L23 | train |
BlueTeaNL/JIRA-Rest-API-PHP | src/Jira/Endpoint/UserEndpoint.php | UserEndpoint.update | public function update($username, $parameters = array())
{
$parameters['username'] = $username;
return $this->apiClient->callEndpoint(
self::ENDPOINT,
$parameters,
null,
HttpMethod::REQUEST_PUT
);
} | php | public function update($username, $parameters = array())
{
$parameters['username'] = $username;
return $this->apiClient->callEndpoint(
self::ENDPOINT,
$parameters,
null,
HttpMethod::REQUEST_PUT
);
} | [
"public",
"function",
"update",
"(",
"$",
"username",
",",
"$",
"parameters",
"=",
"array",
"(",
")",
")",
"{",
"$",
"parameters",
"[",
"'username'",
"]",
"=",
"$",
"username",
";",
"return",
"$",
"this",
"->",
"apiClient",
"->",
"callEndpoint",
"(",
"... | Modify user. The "value" fields present will override the existing value. Fields skipped in request will not be changed.
@param $username
@param array $parameters
@return mixed | [
"Modify",
"user",
".",
"The",
"value",
"fields",
"present",
"will",
"override",
"the",
"existing",
"value",
".",
"Fields",
"skipped",
"in",
"request",
"will",
"not",
"be",
"changed",
"."
] | 56309ee711f86d5bc085f391bba3e50155e14106 | https://github.com/BlueTeaNL/JIRA-Rest-API-PHP/blob/56309ee711f86d5bc085f391bba3e50155e14106/src/Jira/Endpoint/UserEndpoint.php#L32-L41 | train |
BlueTeaNL/JIRA-Rest-API-PHP | src/Jira/Endpoint/UserEndpoint.php | UserEndpoint.add | public function add($username, $parameters = array())
{
$parameters['username'] = $username;
return $this->apiClient->callEndpoint(
self::ENDPOINT,
$parameters,
null,
HttpMethod::REQUEST_POST
);
} | php | public function add($username, $parameters = array())
{
$parameters['username'] = $username;
return $this->apiClient->callEndpoint(
self::ENDPOINT,
$parameters,
null,
HttpMethod::REQUEST_POST
);
} | [
"public",
"function",
"add",
"(",
"$",
"username",
",",
"$",
"parameters",
"=",
"array",
"(",
")",
")",
"{",
"$",
"parameters",
"[",
"'username'",
"]",
"=",
"$",
"username",
";",
"return",
"$",
"this",
"->",
"apiClient",
"->",
"callEndpoint",
"(",
"sel... | Create user. By default created user will not be notified with email. If password field is not set then password
will be randomly generated.
@param $username
@param array $parameters
@return mixed | [
"Create",
"user",
".",
"By",
"default",
"created",
"user",
"will",
"not",
"be",
"notified",
"with",
"email",
".",
"If",
"password",
"field",
"is",
"not",
"set",
"then",
"password",
"will",
"be",
"randomly",
"generated",
"."
] | 56309ee711f86d5bc085f391bba3e50155e14106 | https://github.com/BlueTeaNL/JIRA-Rest-API-PHP/blob/56309ee711f86d5bc085f391bba3e50155e14106/src/Jira/Endpoint/UserEndpoint.php#L51-L60 | train |
BlueTeaNL/JIRA-Rest-API-PHP | src/Jira/Endpoint/UserEndpoint.php | UserEndpoint.findAvatars | public function findAvatars($username)
{
$parameters['username'] = $username;
return $this->apiClient->callEndpoint(sprintf('%s/avatars', self::ENDPOINT), $parameters);
} | php | public function findAvatars($username)
{
$parameters['username'] = $username;
return $this->apiClient->callEndpoint(sprintf('%s/avatars', self::ENDPOINT), $parameters);
} | [
"public",
"function",
"findAvatars",
"(",
"$",
"username",
")",
"{",
"$",
"parameters",
"[",
"'username'",
"]",
"=",
"$",
"username",
";",
"return",
"$",
"this",
"->",
"apiClient",
"->",
"callEndpoint",
"(",
"sprintf",
"(",
"'%s/avatars'",
",",
"self",
"::... | Returns all avatars which are visible for the currently logged in user.
@param $username
@return mixed | [
"Returns",
"all",
"avatars",
"which",
"are",
"visible",
"for",
"the",
"currently",
"logged",
"in",
"user",
"."
] | 56309ee711f86d5bc085f391bba3e50155e14106 | https://github.com/BlueTeaNL/JIRA-Rest-API-PHP/blob/56309ee711f86d5bc085f391bba3e50155e14106/src/Jira/Endpoint/UserEndpoint.php#L85-L89 | train |
BlueTeaNL/JIRA-Rest-API-PHP | src/Jira/Endpoint/UserEndpoint.php | UserEndpoint.updatePassword | public function updatePassword($username, $password)
{
$parameters['username'] = $username;
$parameters['password'] = $password;
return $this->apiClient->callEndpoint(
sprintf('%s/avatars', self::ENDPOINT),
$parameters,
null,
HttpMethod::REQUEST_PUT
);
} | php | public function updatePassword($username, $password)
{
$parameters['username'] = $username;
$parameters['password'] = $password;
return $this->apiClient->callEndpoint(
sprintf('%s/avatars', self::ENDPOINT),
$parameters,
null,
HttpMethod::REQUEST_PUT
);
} | [
"public",
"function",
"updatePassword",
"(",
"$",
"username",
",",
"$",
"password",
")",
"{",
"$",
"parameters",
"[",
"'username'",
"]",
"=",
"$",
"username",
";",
"$",
"parameters",
"[",
"'password'",
"]",
"=",
"$",
"password",
";",
"return",
"$",
"this... | Modify user password.
@param $username
@param $password
@return mixed | [
"Modify",
"user",
"password",
"."
] | 56309ee711f86d5bc085f391bba3e50155e14106 | https://github.com/BlueTeaNL/JIRA-Rest-API-PHP/blob/56309ee711f86d5bc085f391bba3e50155e14106/src/Jira/Endpoint/UserEndpoint.php#L98-L108 | train |
BlueTeaNL/JIRA-Rest-API-PHP | src/Jira/Endpoint/UserEndpoint.php | UserEndpoint.picker | public function picker($query, $maxResults = null, $showAvatar = null, $exclude = null)
{
$parameters = array(
'query' => $query,
'maxResults' => $maxResults,
'showAvatar' => $showAvatar,
'exclude' => $exclude
);
return $this->apiClient->callEndpoint(sprintf('%s/picker', self::ENDPOINT), $parameters);
} | php | public function picker($query, $maxResults = null, $showAvatar = null, $exclude = null)
{
$parameters = array(
'query' => $query,
'maxResults' => $maxResults,
'showAvatar' => $showAvatar,
'exclude' => $exclude
);
return $this->apiClient->callEndpoint(sprintf('%s/picker', self::ENDPOINT), $parameters);
} | [
"public",
"function",
"picker",
"(",
"$",
"query",
",",
"$",
"maxResults",
"=",
"null",
",",
"$",
"showAvatar",
"=",
"null",
",",
"$",
"exclude",
"=",
"null",
")",
"{",
"$",
"parameters",
"=",
"array",
"(",
"'query'",
"=>",
"$",
"query",
",",
"'maxRe... | Returns a list of users matching query with highlighting. This resource cannot be accessed anonymously.
@param null|string $query
@param null|int $maxResults
@param bool $showAvatar
@param null|string $exclude
@return mixed | [
"Returns",
"a",
"list",
"of",
"users",
"matching",
"query",
"with",
"highlighting",
".",
"This",
"resource",
"cannot",
"be",
"accessed",
"anonymously",
"."
] | 56309ee711f86d5bc085f391bba3e50155e14106 | https://github.com/BlueTeaNL/JIRA-Rest-API-PHP/blob/56309ee711f86d5bc085f391bba3e50155e14106/src/Jira/Endpoint/UserEndpoint.php#L119-L128 | train |
BlueTeaNL/JIRA-Rest-API-PHP | src/Jira/Endpoint/UserEndpoint.php | UserEndpoint.search | public function search($username, $startAt = null, $maxResults = null, $includeActive = null, $includeInactive = null)
{
$parameters = array(
'username' => $username,
'startAt' => $startAt,
'maxResults' => $maxResults,
'includeActive' => $includeActive,
'includeInactive' => $includeInactive
);
return $this->apiClient->callEndpoint(sprintf('%s/search', self::ENDPOINT), $parameters);
} | php | public function search($username, $startAt = null, $maxResults = null, $includeActive = null, $includeInactive = null)
{
$parameters = array(
'username' => $username,
'startAt' => $startAt,
'maxResults' => $maxResults,
'includeActive' => $includeActive,
'includeInactive' => $includeInactive
);
return $this->apiClient->callEndpoint(sprintf('%s/search', self::ENDPOINT), $parameters);
} | [
"public",
"function",
"search",
"(",
"$",
"username",
",",
"$",
"startAt",
"=",
"null",
",",
"$",
"maxResults",
"=",
"null",
",",
"$",
"includeActive",
"=",
"null",
",",
"$",
"includeInactive",
"=",
"null",
")",
"{",
"$",
"parameters",
"=",
"array",
"(... | Returns a list of users that match the search string. This resource cannot be accessed anonymously.
@param $username
@param int $startAt
@param int $maxResults
@param bool $includeActive
@param bool $includeInactive
@return mixed | [
"Returns",
"a",
"list",
"of",
"users",
"that",
"match",
"the",
"search",
"string",
".",
"This",
"resource",
"cannot",
"be",
"accessed",
"anonymously",
"."
] | 56309ee711f86d5bc085f391bba3e50155e14106 | https://github.com/BlueTeaNL/JIRA-Rest-API-PHP/blob/56309ee711f86d5bc085f391bba3e50155e14106/src/Jira/Endpoint/UserEndpoint.php#L140-L150 | train |
Divergence/framework | src/Models/Versioning.php | Versioning.getRevisionRecords | public static function getRevisionRecords($options = [])
{
$options = Util::prepareOptions($options, [
'indexField' => false,
'conditions' => [],
'order' => false,
'limit' => false,
'offset' => 0,
]);
$query = 'SELECT * FROM `%s` WHERE (%s)';
$params = [
static::getHistoryTable(),
count($options['conditions']) ? join(') AND (', static::_mapConditions($options['conditions'])) : 1,
];
if ($options['order']) {
$query .= ' ORDER BY ' . join(',', static::_mapFieldOrder($options['order']));
}
if ($options['limit']) {
$query .= sprintf(' LIMIT %u,%u', $options['offset'], $options['limit']);
}
if ($options['indexField']) {
return DB::table(static::_cn($options['indexField']), $query, $params);
} else {
return DB::allRecords($query, $params);
}
} | php | public static function getRevisionRecords($options = [])
{
$options = Util::prepareOptions($options, [
'indexField' => false,
'conditions' => [],
'order' => false,
'limit' => false,
'offset' => 0,
]);
$query = 'SELECT * FROM `%s` WHERE (%s)';
$params = [
static::getHistoryTable(),
count($options['conditions']) ? join(') AND (', static::_mapConditions($options['conditions'])) : 1,
];
if ($options['order']) {
$query .= ' ORDER BY ' . join(',', static::_mapFieldOrder($options['order']));
}
if ($options['limit']) {
$query .= sprintf(' LIMIT %u,%u', $options['offset'], $options['limit']);
}
if ($options['indexField']) {
return DB::table(static::_cn($options['indexField']), $query, $params);
} else {
return DB::allRecords($query, $params);
}
} | [
"public",
"static",
"function",
"getRevisionRecords",
"(",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"=",
"Util",
"::",
"prepareOptions",
"(",
"$",
"options",
",",
"[",
"'indexField'",
"=>",
"false",
",",
"'conditions'",
"=>",
"[",
"]",
",... | Gets raw revision data from the database and constructs a query
@param array $options Query options
@return array | [
"Gets",
"raw",
"revision",
"data",
"from",
"the",
"database",
"and",
"constructs",
"a",
"query"
] | daaf78aa4b10ad59bf52b9e31480c748ad82e8c3 | https://github.com/Divergence/framework/blob/daaf78aa4b10ad59bf52b9e31480c748ad82e8c3/src/Models/Versioning.php#L94-L124 | train |
Divergence/framework | src/Models/Versioning.php | Versioning.beforeVersionedSave | public function beforeVersionedSave()
{
$this->wasDirty = false;
if ($this->isDirty && static::$createRevisionOnSave) {
// update creation time
$this->Created = time();
$this->wasDirty = true;
}
} | php | public function beforeVersionedSave()
{
$this->wasDirty = false;
if ($this->isDirty && static::$createRevisionOnSave) {
// update creation time
$this->Created = time();
$this->wasDirty = true;
}
} | [
"public",
"function",
"beforeVersionedSave",
"(",
")",
"{",
"$",
"this",
"->",
"wasDirty",
"=",
"false",
";",
"if",
"(",
"$",
"this",
"->",
"isDirty",
"&&",
"static",
"::",
"$",
"createRevisionOnSave",
")",
"{",
"// update creation time",
"$",
"this",
"->",
... | Sets wasDirty, isDirty, Created for the object before save
@return void | [
"Sets",
"wasDirty",
"isDirty",
"Created",
"for",
"the",
"object",
"before",
"save"
] | daaf78aa4b10ad59bf52b9e31480c748ad82e8c3 | https://github.com/Divergence/framework/blob/daaf78aa4b10ad59bf52b9e31480c748ad82e8c3/src/Models/Versioning.php#L131-L139 | train |
Divergence/framework | src/Models/Versioning.php | Versioning.afterVersionedSave | public function afterVersionedSave()
{
if ($this->wasDirty && static::$createRevisionOnSave) {
// save a copy to history table
$recordValues = $this->_prepareRecordValues();
$set = static::_mapValuesToSet($recordValues);
DB::nonQuery(
'INSERT INTO `%s` SET %s',
[
static::getHistoryTable(),
join(',', $set),
]
);
}
} | php | public function afterVersionedSave()
{
if ($this->wasDirty && static::$createRevisionOnSave) {
// save a copy to history table
$recordValues = $this->_prepareRecordValues();
$set = static::_mapValuesToSet($recordValues);
DB::nonQuery(
'INSERT INTO `%s` SET %s',
[
static::getHistoryTable(),
join(',', $set),
]
);
}
} | [
"public",
"function",
"afterVersionedSave",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"wasDirty",
"&&",
"static",
"::",
"$",
"createRevisionOnSave",
")",
"{",
"// save a copy to history table",
"$",
"recordValues",
"=",
"$",
"this",
"->",
"_prepareRecordValues"... | After save to regular database this saves to the history table
@return void | [
"After",
"save",
"to",
"regular",
"database",
"this",
"saves",
"to",
"the",
"history",
"table"
] | daaf78aa4b10ad59bf52b9e31480c748ad82e8c3 | https://github.com/Divergence/framework/blob/daaf78aa4b10ad59bf52b9e31480c748ad82e8c3/src/Models/Versioning.php#L146-L160 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.