sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
protected static function _determineUniversalImplClass(int $tag): string
{
if (!array_key_exists($tag, self::MAP_TAG_TO_CLASS)) {
throw new \UnexpectedValueException(
"Universal tag $tag not implemented.");
}
return self::MAP_TAG_TO_CLASS[$tag];
} | Determine the class that implements an universal type of the given tag.
@param int $tag
@throws \UnexpectedValueException
@return string Class name | entailment |
protected function _typeDescriptorString(): string
{
if ($this->typeClass() == Identifier::CLASS_UNIVERSAL) {
return self::tagToName($this->_typeTag);
}
return sprintf("%s TAG %d", Identifier::classToName($this->typeClass()),
$this->_typeTag);
} | Get textual description of the type for debugging purposes.
@return string | entailment |
public static function tagToName(int $tag): string
{
if (!array_key_exists($tag, self::MAP_TYPE_TO_NAME)) {
return "TAG $tag";
}
return self::MAP_TYPE_TO_NAME[$tag];
} | Get human readable name for an universal tag.
@param int $tag
@return string | entailment |
public function check($phone, $id = null) {
$params = array('phone' => $phone, 'id' => $id);
return $this->master->call('phones/check', $params);
} | Checking phone in to HLR
@param string $phone
@param string $id Query ID returned if the processing takes longer than 60 seconds
@return object
@option string "phone"
@option string "status"
@option int "imsi"
@option string "network"
@option bool "ported"
@option string "network_ported" | entailment |
public function sendRequest($data)
{
return $this->httpClient->request(
$this->getHttpMethod(),
$this->getEndpoint(),
[
'Accept' => 'application/json',
'Authorization' => $this->getServiceKey(),
'Content-Type' => 'applicatio... | Make the actual request to WorldPay
@param mixed $data The data to encode and send to the API endpoint
@return \Psr\Http\Message\ResponseInterface HTTP response object | entailment |
public function sendData($data)
{
$httpResponse = $this->sendRequest($data);
$responseClass = $this->getResponseClassName();
return $this->response = new $responseClass($this, $httpResponse);
} | Send the request to the API then build the response object
@param mixed $data The data to encode and send to the API endpoint
@return JsonResponse | entailment |
public function handle()
{
$args = [
'name' => $this->argumentName(),
'--type' => strtolower($this->type), // settings type
'--plain' => $this->optionPlain(), // if plain stub
'--force' => $this->optionForce(), // force override
'--stub' => $t... | Execute the console command.
@return void | entailment |
protected function getArgumentNameOnly()
{
$name = $this->argumentName();
if (str_contains($name, '/')) {
$name = str_replace('/', '.', $name);
}
if (str_contains($name, '\\')) {
$name = str_replace('\\', '.', $name);
}
if (str_contains($nam... | Only return the name of the file
Ignore the path / namespace of the file
@return array|mixed|string | entailment |
protected function getArgumentPath($withName = false)
{
$name = $this->argumentName();
if (str_contains($name, '.')) {
$name = str_replace('.', '/', $name);
}
if (str_contains($name, '\\')) {
$name = str_replace('\\', '/', $name);
}
// ucfir... | Return the path of the file
@param bool $withName
@return array|mixed|string | entailment |
protected function getResourceName($name, $format = true)
{
// we assume its already formatted to resource name
if ($name && $format === false) {
return $name;
}
$name = isset($name) ? $name : $this->resource;
$this->resource = lcfirst(str_singular(class_basenam... | Get the resource name
@param $name
@param bool $format
@return string | entailment |
protected function getModelName($name = null)
{
$name = isset($name) ? $name : $this->resource;
//return ucwords(camel_case($this->getResourceName($name)));
return str_singular(ucwords(camel_case(class_basename($name))));
} | Get the name for the model
@param null $name
@return string | entailment |
protected function getSeedName($name = null)
{
return ucwords(camel_case(str_replace($this->settings['postfix'], '',
$this->getResourceName($name))));
} | Get the name for the seed
@param null $name
@return string | entailment |
protected function getCollectionUpperName($name = null)
{
$name = str_plural($this->getResourceName($name));
$pieces = explode('_', $name);
$name = "";
foreach ($pieces as $k => $str) {
$name .= ucfirst($str);
}
return $name;
} | Get the plural uppercase name of the resouce
@param null $name
@return null|string | entailment |
protected function getContractName($name = null)
{
$name = isset($name) ? $name : $this->resource;
$name = str_singular(ucwords(camel_case(class_basename($name))));
return $name . config('generators.settings.contract.postfix');
} | Get the name of the contract
@param null $name
@return string | entailment |
protected function getContractNamespace($withApp = true)
{
// get path from settings
$path = config('generators.settings.contract.namespace') . '\\';
// dont add the default namespace if specified not to in config
$path .= str_replace('/', '\\', $this->getArgumentPath());
$... | Get the namespace of where contract was created
@param bool $withApp
@return string | entailment |
protected function getViewPath($name)
{
$pieces = explode('/', $name);
// dont plural if reserve word
foreach ($pieces as $k => $value) {
if (!in_array($value, config('generators.reserve_words'))) {
$pieces[$k] = str_plural(snake_case($pieces[$k]));
}... | Get the path to the view file
@param $name
@return string | entailment |
protected function getViewPathFormatted($name)
{
$path = $this->getViewPath($name);
if (strpos($path, 'admin.') === 0) {
$path = substr($path, 6);
}
if (strpos($path, 'admins.') === 0) {
$path = substr($path, 7);
}
if (strpos($path, 'website... | Remove 'admin' and 'webiste' if first in path
The Base Controller has it as a 'prefix path'
@param $name
@return string | entailment |
protected function getStub()
{
$key = $this->getOptionStubKey();
// get the stub path
$stub = config('generators.' . $key);
if (is_null($stub)) {
$this->error('The stub does not exist in the config file - "' . $key . '"');
exit;
}
return $st... | Get the stub file for the generator.
@return string | entailment |
protected function getOptionStubKey()
{
$plain = $this->option('plain');
$stub = $this->option('stub') . ($plain ? '_plain' : '') . '_stub';
// if no stub, we assume its the same as the type
if (is_null($this->option('stub'))) {
$stub = $this->option('type') . ($plain ? ... | Get the key where the stub is located
@return string | entailment |
public function isSuccessful()
{
$isHttpSuccess = parent::isSuccessful();
$isPurchaseSuccess = false;
if (isset($this->data['paymentStatus']) && $this->data['paymentStatus'] == $this->successfulPaymentStatus) {
$isPurchaseSuccess = true;
}
return ($isHttpSuccess... | Is the response successful?
@return bool | entailment |
public function getMessage()
{
// check for HTTP failure response first
$httpMessage = parent::getMessage();
if ($httpMessage !== null) {
return $httpMessage;
}
// check if descriptive failure reason is available
if (!$this->isSuccessful() && isset($this-... | What is the relevant description of the transaction response?
@todo Sometimes the 'description' field is more user-friendly (see simulated eror) - how do we decide which one?
@return string|null | entailment |
public function sortedSet(): self
{
$obj = clone $this;
usort($obj->_elements,
function (Element $a, Element $b) {
if ($a->typeClass() != $b->typeClass()) {
return $a->typeClass() < $b->typeClass() ? -1 : 1;
}
if ($a->ta... | Sort by canonical ascending order.
Used for DER encoding of SET type.
@return self | entailment |
public function sortedSetOf(): self
{
$obj = clone $this;
usort($obj->_elements,
function (Element $a, Element $b) {
$a_der = $a->toDER();
$b_der = $b->toDER();
return strcmp($a_der, $b_der);
});
return $obj;
} | Sort by encoding ascending order.
Used for DER encoding of SET OF type.
@return self | entailment |
public function getStatus($ticket)
{
try {
return $this->getStatusInternal($ticket);
} catch (\SoapFault $e) {
$result = new StatusResult();
$result->setError($this->getErrorFromFault($e));
return $result;
}
} | @param string $ticket
@return StatusResult | entailment |
protected static function _explodeDottedOID(string $oid): array
{
$subids = [];
if (strlen($oid)) {
foreach (explode(".", $oid) as $subid) {
$n = @gmp_init($subid, 10);
if (false === $n) {
throw new \UnexpectedValueException(
... | Explode dotted OID to an array of sub ID's.
@param string $oid OID in dotted format
@return \GMP[] Array of GMP numbers | entailment |
protected static function _implodeSubIDs(\GMP ...$subids): string
{
return implode(".",
array_map(function ($num) {
return gmp_strval($num, 10);
}, $subids));
} | Implode an array of sub IDs to dotted OID format.
@param \GMP ...$subids
@return string | entailment |
protected static function _encodeSubIDs(\GMP ...$subids): string
{
$data = "";
foreach ($subids as $subid) {
// if number fits to one base 128 byte
if ($subid < 128) {
$data .= chr(intval($subid));
} else { // encode to multiple bytes
... | Encode sub ID's to DER.
@param \GMP ...$subids
@return string | entailment |
protected static function _decodeSubIDs(string $data): array
{
$subids = [];
$idx = 0;
$end = strlen($data);
while ($idx < $end) {
$num = gmp_init("0", 10);
while (true) {
if ($idx >= $end) {
throw new DecodeException("Unexp... | Decode sub ID's from DER data.
@param string $data
@throws DecodeException
@return \GMP[] Array of GMP numbers | entailment |
public function validateImageSize($attribute, $value, $parameters)
{
$image = $this->getImagePath($value);
// Get the image dimension info, or fail.
$image_size = @getimagesize($image);
if ($image_size === false) {
return false;
}
// If only one dimensi... | Usage: image_size:width[,height]
@param $attribute string
@param $value string|array
@param $parameters array
@return boolean | entailment |
public function replaceImageSize($message, $attribute, $rule, $parameters)
{
$width = $height = $this->checkDimension($parameters[0]);
if (isset($parameters[1])) {
$height = $this->checkDimension($parameters[1]);
}
return str_replace(
[':width', ':height'],
... | Build the error message for validation failures.
@param string $message
@param string $attribute
@param string $rule
@param array $parameters
@return string | entailment |
public function validateImageAspect($attribute, $value, $parameters)
{
$image = $this->getImagePath($value);
// Get the image dimension info, or fail.
$image_size = @getimagesize($image);
if ($image_size === false) {
return false;
}
$image_width = $imag... | Usage: image_aspect:ratio
@param $attribute string
@param $value string|array
@param $parameters array
@return boolean
@throws \RuntimeException | entailment |
protected function checkDimension($rule, $dimension = 0)
{
$dimension = (int) $dimension;
if ($rule === '*') {
$message = $this->translator->trans('image-validator::validation.anysize');
$pass = true;
} else if (preg_match('/^(\d+)\-(\d+)$/', $rule, $matches)) {
... | Parse the dimension rule and check if the dimension passes the rule.
@param string $rule
@param integer $dimension
@return array
@throws \RuntimeException | entailment |
public static function fromString(string $time, string $tz = null): self
{
try {
if (!isset($tz)) {
$tz = date_default_timezone_get();
}
return new static(
new \DateTimeImmutable($time, self::_createTimeZone($tz)));
} catch (\Except... | Initialize from datetime string.
@link http://php.net/manual/en/datetime.formats.php
@param string $time Time string
@param string|null $tz Timezone, if null use default.
@throws \RuntimeException
@return self | entailment |
private static function _decimalToNR3(string $str): string
{
// if number is in exponent form
/** @var $match string[] */
if (preg_match(self::PHP_EXPONENT_DNUM, $str, $match)) {
$parts = explode(".", $match[1]);
$m = ltrim($parts[0], "0");
$e = intval($ma... | Convert decimal number string to NR3 form.
@param string $str
@return string | entailment |
private static function _nr3ToDecimal(string $str): float
{
/** @var $match string[] */
if (!preg_match(self::NR3_REGEX, $str, $match)) {
throw new \UnexpectedValueException(
"'$str' is not a valid NR3 form real.");
}
$m = $match[2];
// if number s... | Convert NR3 form number to decimal.
@param string $str
@throws \UnexpectedValueException
@return float | entailment |
public function unix2DosTime($unixtime = 0)
{
$timearray = (0 == $unixtime) ? getdate() : getdate($unixtime);
if ($timearray['year'] < 1980) {
$timearray['year'] = 1980;
$timearray['mon'] = 1;
$timearray['mday'] = 1;
$timearray['hours'] = 0;
... | Converts an Unix timestamp to a four byte DOS date and time format (date
in high two bytes, time in low two bytes allowing magnitude comparison).
@param int $unixtime the current Unix timestamp
@return int the current date in a four byte DOS format | entailment |
public function addFile($data, $name, $time = 0)
{
$name = str_replace('\\', '/', $name);
$hexdtime = pack('V', $this->unix2DosTime($time));
$frd = "\x50\x4b\x03\x04";
$frd .= "\x14\x00"; // ver needed to extract
$frd .= "\x00\x00"; // gen purpose bit fl... | Adds "file" to archive.
@param string $data file contents
@param string $name name of the file in the archive (may contains the path)
@param int $time the current timestamp | entailment |
public function compress($filename, $content)
{
$this->addFile($content, $filename);
$zip = $this->file();
$this->clear();
return $zip;
} | Comprime el contenido del archivo con el nombre especifico y retorna el contenido del zip.
@param string $filename
@param string $content
@return string | entailment |
public function decompress($content, callable $filter = null)
{
$start = 0;
$result = [];
while (true) {
$dat = substr($content, $start, 30);
if (empty($dat)) {
break;
}
$head = unpack(self::UNZIP_FORMAT, $dat);
$f... | Extract files.
@param string $content
@param callable|null $filter
@return array | entailment |
public function send($filename, $content)
{
$client = $this->getClient();
$result = new SummaryResult();
try {
$zipContent = $this->compress($filename.'.xml', $content);
$params = [
'fileName' => $filename.'.zip',
'contentFile' => $zip... | @param string $filename
@param string $content
@return BaseResult | entailment |
public function handle()
{
$name = $this->parseName($this->getNameInput());
$path = $this->getPath($name);
if ($this->files->exists($path) && $this->optionForce() === false) {
return $this->error($this->type . ' already exists!');
}
// if we need to append the p... | Execute the console command.
@return mixed | entailment |
protected function parseName($name)
{
$tables = array_map('str_singular', $this->getSortedTableNames());
$name = implode('', array_map('ucwords', $tables));
$pieces = explode('_', $name);
$name = implode('', array_map('ucwords', $pieces));
return "Create{$name}PivotTable";
... | Parse the name and format.
@param string $name
@return string | entailment |
protected function replaceSchema(&$stub)
{
$tables = $this->getSortedTableNames();
$stub = str_replace(['{{columnOne}}', '{{columnTwo}}'],
array_merge(array_map('str_singular', $tables), $tables), $stub);
$stub = str_replace(['{{tableOne}}', '{{tableTwo}}'],
array_m... | Apply the correct schema to the stub.
@param string $stub
@return $this | entailment |
protected function getSortedTableNames()
{
$tables = [
strtolower($this->argument('tableOne')),
strtolower($this->argument('tableTwo'))
];
sort($tables);
return $tables;
} | Sort the two tables in alphabetical order.
@return array | entailment |
public function addRelationshipsInParents()
{
$options = config('generators.settings');
if (!$options['model']) {
$this->info('Model files not found.');
return;
}
$modelSettings = $options['model'];
// model names
$modelOne = $this->getModel... | Append Many to Many Relationships in Parent Models | entailment |
private function addRelationshipInModel($modelPath, $relationshipModel, $tableName)
{
// load model
$model = $this->files->get($modelPath);
// get the position where to insert into file
$index = strlen($model) - strpos(strrev($model), '}') - 1;
// load many to many stub
... | Insert the many to many relationship in model
@param $modelPath
@param $relationshipModel
@param $tableName | entailment |
public function humanReadable(bool $short_form = true): string
{
if ($short_form) {
return inet_ntop($this->binary());
}
$octets = explode('.', inet_ntop($this->binary()));
return sprintf('%03d.%03d.%03d.%03d', ...$octets);
} | {@inheritdoc} | entailment |
public static function toNumeric($requestorType)
{
if (!is_string($requestorType)) {
throw new \InvalidArgumentException('The requestor type "' . $requestorType . '" is not a string.');
}
return static::defines(strtoupper($requestorType), true);
} | @param string $requestorType
@return string | entailment |
public static function cleanFields($fields)
{
$fields = parent::cleanFields($fields);
if (('*' !== array_get($fields, 0)) && !in_array('private', $fields)) {
$fields[] = 'private';
}
return $fields;
} | Removes unwanted fields from field list if supplied.
@param mixed $fields
@return array | entailment |
public function attributesToArray()
{
$attributes = parent::attributesToArray();
if (array_get_bool($attributes, 'private') && !is_null(array_get($attributes, 'value'))) {
$attributes['value'] = $this->protectionMask;
}
return $attributes;
} | {@inheritdoc} | entailment |
public function setAttribute($key, $value)
{
// if mask, no need to do anything else.
if (('value' === $key) && ($value === $this->protectionMask)) {
return $this;
}
return parent::setAttribute($key, $value);
} | {@inheritdoc} | entailment |
public static function toString($numericLevel = self::SWAGGER_JSON)
{
if (!is_numeric($numericLevel)) {
throw new \InvalidArgumentException('The format type "' . $numericLevel . '" is not numeric.');
}
return static::nameOf($numericLevel);
} | @param int $numericLevel
@throws NotImplementedException
@throws \InvalidArgumentException
@return string | entailment |
public function addPlugin(Plugin $plugin, $key = null) {
if ($key) {
$this->plugins[$key] = $plugin;
} else {
$this->plugins[] = $plugin;
}
$plugin->configure($this);
return $this;
} | Add a plugin
@param Plugin $plugin the instanciated plugin
@param string $key a key to quickly find the plugin with getPlugin()
@return TcTable | entailment |
public function removePlugin($key) {
if (!isset($this->plugins[$key])) {
return $this;
}
if (method_exists($this->plugins[$key], 'unconfigure')) {
$this->plugins[$key]->unconfigure($this);
}
unset($this->plugins[$key]);
return $this;
} | Remove a plugin and its events by the key
@param string $key the key used in TcTable::addPlugin()
@return TcTable | entailment |
public function getPlugin($key) {
return isset($this->plugins[$key]) ? $this->plugins[$key] : null;
} | Get a plugin
@param mixed $key plugin index (0, 1, 2, etc) or string
@return Plugin | entailment |
public function on($event, callable $fn) {
if (!isset($this->events[$event])) {
$this->events[$event] = [];
}
$this->events[$event][] = $fn;
return $this;
} | Set an action to do on the specified event
@param int $event event code
@param callable $fn function to call when the event is triggered
@return TcTable | entailment |
public function un($event, callable $fn = null) {
if (isset($this->events[$event])) {
if ($fn) {
foreach ($this->events[$event] as $k => $ev) {
if ($ev === $fn) {
unset($this->events[$event][$k]);
break;
... | Remove an action setted for the specified event
@param int $event event code
@param callable|null $fn function to call when the event was triggered
@return TcTable | entailment |
public function trigger($event, array $args = [], $acceptReturn = false) {
if (isset($this->events[$event])) {
array_unshift($args, $this);
foreach ($this->events[$event] as $fn) {
$data = call_user_func_array($fn, $args);
if ($acceptReturn) {
... | Browse registered actions for this event
@param int $event event code
@param array $args arra of arguments to pass to the event function
@param bool $acceptReturn TRUE so a non-null function return can be used
by TcTable
@return mixed desired content or null | entailment |
public function addColumn($column, array $definition) {
// set new column with default definitions. Note that [ln] is always
// set to FALSE. When addBody(), TRUE will be setted for the last
// column.
$this->columnDefinition[$column] = array_merge([
'isMultiLine' => false,
... | Define a column. Config array is mostly what we find in \TCPDF Cell and
MultiCell.
Frequently used Cell and MultiCell options:
<ul>
<li><i>callable</i> <b>renderer</b>: renderer function for datas.
Recieve (TcTable $table, $data, $row, $column, $height). The last
parameter is TRUE when called during height calculation... | entailment |
public function setColumns(array $columns, $add = false) {
if (!$add) {
$this->columnDefinition = [];
}
foreach ($columns as $key => $def) {
$this->addColumn($key, $def);
}
return $this;
} | Add many columns in one shot
@see addColumn
@param array $columns
@param bool $add true to add these columns to existing columns
@return \mangetasoupe\pdf\TcTable | entailment |
public function setColumnDefinition($column, $definition, $value) {
$this->columnDefinition[$column][$definition] = $value;
return $this;
} | Set a specific definition for a column, like the value of border, calign
and so on
@param string $column column string index
@param string $definition definition name (border, calign, etc.)
@param mixed $value definition value ('LTBR', 'T', etc.)
@return TcTable | entailment |
public function getColumnWidthBetween($columnA, $columnB) {
$width = 0;
$check = false;
foreach ($this->columnDefinition as $key => $def) {
// begin sum either from start, or from column A
if ($key == $columnA || !$columnA) {
$check = true;
}
... | Get width between two columns. Widths of these columns are included in
the sum.
Example: $table->getColumnWidthBetween('B', 'D');
<pre>
| A | B | C | D | E |
| |-> | ->| ->| |
</pre>
If column A is empty, behave like {@link TcTable::getColumnWidthUntil()}.
If column B is empty, behave like {@link TcTable::getColu... | entailment |
public function setRowDefinition($column, $definition, $value) {
if ($column === null) {
foreach ($this->columnDefinition as $key => $v) {
$this->rowDefinition[$key][$definition] = $value;
}
} else {
$this->rowDefinition[$column][$definition] = $value;... | Set a custom configuration for one specific cell in the current row.
@param string|null $column column string index. If null, the definition
will be set for all columns
@param string $definition specific configuration (border, etc.)
@param mixed $value value ('LBR' for border, etc.)
@return TcTable | entailment |
public function getCurrentRowHeight($row) {
// get the max height for this row
$h = $this->getColumnHeight();
$this->setRowHeight($h);
if (!isset($this->rowDefinition['_content'])) {
$this->rowDefinition['_content'] = [];
}
foreach ($this->columnDefinition as ... | Browse all cells for this row to find which content has the max height.
Then we can adapt the height of all the other cells of this line.
@param array|object $row
@return float | entailment |
public function addHeader() {
$height = $this->getRowHeight();
$definition = $this->rowDefinition;
$this->copyDefaultColumnDefinitions(null);
if ($this->trigger(self::EV_HEADER_ADD) !== false) {
foreach ($this->columnDefinition as $key => $def) {
$this->addCe... | Add table headers
@return TcTable | entailment |
public function addBody($rows, callable $fn = null) {
// last column will have TRUE for the TCPDF [ln] property
end($this->columnDefinition);
$this->columnDefinition[key($this->columnDefinition)]['ln'] = true;
$auto_pb = $this->pdf->getAutoPageBreak();
$bmargin = $this->pdf->get... | Add content to the table. It launches events at start and end, if we need
to add some custom stuff.
The callable function structure is as follow:
<ul>
<li><i>TcTable</i> <b>$table</b> the TcTable object</li>
<li><i>array|object</i> <b>$row</b> current row</li>
<li><i>int</i> <b>$index</b> current row index</li>
<li><i... | entailment |
private function addRow($row, $index = null) {
$this->copyDefaultColumnDefinitions($row, $index);
if ($this->trigger(self::EV_ROW_ADD, [$row, $index]) === false) {
return $this;
}
$h = $this->getRowHeight();
$page_break_trigger = $this->pdf->getPageHeight() - $this->p... | Add a row
@param array|object $row row data
@param int $index row index
@return TcTable | entailment |
private function addCell($column, $data, $row, $header = false) {
$c = $this->rowDefinition[$column];
$data = $this->fetchDataByUserFunc($c, $data, $column, $row, $header, false);
if ($this->trigger(self::EV_CELL_ADD, [$column, $data, $c, $row, $header]) === false) {
$data = '';
... | Draw a cell
@param string $column column string index
@param mixed $data data to draw inside the cell
@param array|object $row all datas for this line
@param bool $header true if we draw header cell
@return TcTable | entailment |
private function fetchDataByUserFunc($c, $data, $column, $row, $header, $heightc) {
if (!$header && is_callable($c['renderer'])) {
$data = $c['renderer']($this, $data, $row, $column, $heightc);
} elseif ($header && is_callable($c['headerRenderer'])) {
$data = $c['headerRenderer']... | Get data by user function, if it exists
@param array $c the column definition
@param mixed $data data to draw inside the cell
@param string $column column string index
@param array|object $row all datas for this line
@param bool $header true if we draw header cell
@param bool $heightc determine if we are in height cal... | entailment |
private function drawByUserFunc($data, $column, $row, $header) {
$c = $this->rowDefinition[$column];
$result = false;
if (!$header && is_callable($c['drawFn'])) {
$result = $c['drawFn']($this, $data, $c, $column, $row);
} elseif ($header && is_callable($c['drawHeaderFn'])) {
... | Draw cell/image or anything else by user function, if it exists
@param mixed $data data to draw inside the cell
@param string $column column string index
@param array|object $row all datas for this line
@param bool $header true if we draw header cell
@return bool false to execute normal cell drawing | entailment |
private function copyDefaultColumnDefinitions($columns = null, $rowIndex = null) {
$this->rowDefinition = $this->columnDefinition;
$h = $this->trigger(self::EV_ROW_HEIGHT_GET, [$columns, $rowIndex], true);
if ($h === null) {
$h = $columns !== null
? $this->getCurrentR... | Copy column definition inside a new property. It allows us to customize
it only for this row. For the next row, column definition will again be
the default one.
Usefull for plugins that need to temporarily, for one precise row, to
change column information (like background color, border, etc)
@param array|object $col... | entailment |
public function up()
{
$driver = Schema::getConnection()->getDriverName();
// Even though we take care of this scenario in the code,
// SQL Server does not allow potential cascading loops,
// so set the default no action and clear out created/modified by another user when deleting a ... | Run the migrations.
@return void | entailment |
public function up()
{
if (Schema::hasTable('service_type')) {
Schema::table('service', function (Blueprint $t){
$t->dropForeign('service_type_foreign');
});
}
if (Schema::hasTable('script_type')) {
Schema::table('script_config', function (... | Run the migrations.
@return void | entailment |
public function down()
{
if (Schema::hasTable('service_type')) {
Schema::table('service', function (Blueprint $t){
$t->foreign('type')->references('name')->on('service_type')->onDelete('cascade');
});
}
if (Schema::hasTable('script_type')) {
... | Reverse the migrations.
@return void | entailment |
public function setApiVersion($version = null)
{
if (empty($version)) {
$version = \Config::get('df.api_version');
}
$version = strval($version); // if numbers are passed in
if (substr(strtolower($version), 0, 1) === 'v') {
$version = substr($version, 1);
... | {@inheritdoc} | entailment |
public static function fromColumnSchema(ColumnSchema $column)
{
$type = $column->type;
$format = '';
switch ($type) {
case DbSimpleTypes::TYPE_ID:
case DbSimpleTypes::TYPE_REF:
case DbSimpleTypes::TYPE_USER_ID:
case DbSimpleTypes::TYPE_USER_ID_... | @param ColumnSchema $column
@return array | entailment |
public static function fromTableSchema(TableSchema $schema)
{
$properties = [];
$required = [];
foreach ($schema->getColumns() as $column) {
if ($column->getRequired()) {
$required[] = $column->getName();
}
$properties[$column->getName()] ... | @param TableSchema $schema
@return array | entailment |
public function handleRequest(ServiceRequestInterface $request, $resource = null)
{
$this->setRequest($request);
$this->setAction($request->getMethod());
$this->setResourceMembers($resource);
$this->response = null;
$resources = $this->getResourceHandlers();
if (!emp... | @param ServiceRequestInterface $request
@param string|null $resource
@return \DreamFactory\Core\Contracts\ServiceResponseInterface | entailment |
protected function handleResource(array $resources)
{
$found = array_by_key_value($resources, 'name', $this->resource);
if (!isset($found, $found['class_name'])) {
throw new NotFoundException("Resource '{$this->resource}' not found for service '{$this->name}'.");
}
$clas... | @param array $resources
@return bool|mixed
@throws InternalServerErrorException
@throws NotFoundException | entailment |
protected function firePreProcessEvent($name = null, $resource = null)
{
if (empty($name)) {
$name = $this->getEventName();
}
if (empty($resource)) {
$resource = $this->getEventResource();
}
$event = new PreProcessApiEvent($name, $this->request, $this-... | Fires pre process event
@param string|null $name Optional override for name
@param string|null $resource Optional override for resource | entailment |
protected function firePostProcessEvent($name = null, $resource = null)
{
if (empty($name)) {
$name = $this->getEventName();
}
if (empty($resource)) {
$resource = $this->getEventResource();
}
/** @noinspection PhpUnusedLocalVariableInspection */
... | Fires post process event
@param string|null $name Optional name to append
@param string|null $resource Optional override for resource | entailment |
protected function fireFinalEvent($name = null, $resource = null)
{
if (empty($name)) {
$name = $this->getEventName();
}
if (empty($resource)) {
$resource = $this->getEventResource();
}
/** @noinspection PhpUnusedLocalVariableInspection */
$res... | Fires last event before responding
@param string|null $name Optional name to append
@param string|null $resource Optional override for resource | entailment |
protected function setAction($action)
{
$this->action = trim(strtoupper($action));
// Check verb aliases, set correct action allowing for closures
if (null !== ($alias = array_get($this->verbAliases, $this->action))) {
// A closure?
if (in_array($alias, Verbs::getDef... | Sets the HTTP Action verb
@param $action string
@return $this | entailment |
protected function setResourceMembers($resourcePath = null)
{
// remove trailing slash here, override this function if you need it
$this->resourcePath = rtrim($resourcePath, '/');
$this->resourceArray = (!empty($this->resourcePath)) ? explode('/', $this->resourcePath) : [];
if (!emp... | Apply the commonly used REST path members to the class.
@param string $resourcePath
@return $this | entailment |
protected function getPayloadData($key = null, $default = null)
{
$data = $this->request->getPayloadData($key, $default);
return $data;
} | @param null $key
@param null $default
@return mixed | entailment |
protected function handleGET()
{
$resources = $this->getResources();
if (is_array($resources)) {
$includeAccess = $this->request->getParameterAsBool(ApiOptions::INCLUDE_ACCESS);
$asList = $this->request->getParameterAsBool(ApiOptions::AS_LIST);
$idField = $this->r... | Handles GET action
@return mixed
@throws BadRequestException | entailment |
public function humanReadable(bool $short_form = true): string
{
if ($short_form) {
return inet_ntop($this->binary());
}
$hex = str_pad($this->numeric(16), 32, '0', STR_PAD_LEFT);
return implode(':', str_split($hex, 4));
} | {@inheritdoc} | entailment |
public function reversePointer(): string
{
$ip = str_replace(':', '', $this->humanReadable(false));
$ip = strrev($ip);
$ip = implode('.', str_split($ip));
$ip .= '.ip6.arpa.';
return $ip;
} | {@inheritdoc} | entailment |
public function subscribe($events)
{
$events->listen(
[
ApiEvent::class,
],
static::class . '@handleApiEvent'
);
$events->listen(
[
ServiceModifiedEvent::class,
ServiceDeletedEvent::class,
... | Register the listeners for the subscriber.
@param Dispatcher $events | entailment |
public function handleApiEvent($event)
{
$eventName = str_replace('.queued', null, $event->name);
$ckey = 'event:' . $eventName;
$records = Cache::remember($ckey, Config::get('df.default_cache_ttl'), function () use ($eventName) {
return ServiceEventMap::whereEvent($eventName)->g... | Handle API events.
@param ApiEvent $event | entailment |
public static function cleanResources(
$resources,
$as_list = false,
$identifier = null,
$fields = null,
$force_wrap = false
) {
// avoid single resources or already wrapped resources
if ($resources instanceof Collection) {
$resources = $resources-... | @param array $resources
@param boolean $as_list
@param string|array|null $identifier
@param string|array|null $fields
@param boolean $force_wrap
@return array | entailment |
public static function getDefinedConstants($flipped = false, $class = null, $listData = false)
{
$_key = static::introspect($class, [], false, $flipped ? 'flipped' : null);
$_constants = false === $flipped ? static::$_constants[$_key] : array_flip(static::$_constants[$_key]);
if (false === ... | Returns a hash of the called class's constants ( CONSTANT_NAME => value ). Caches for speed
(class cache hash, say that ten times fast!).
@param bool $flipped If true, the array is flipped before return ( value => CONSTANT_NAME )
@param string $class Used internally to cache constants
@param bool $listData If ... | entailment |
public static function toConstant($value)
{
if (false !== ($_index = array_search($value, static::getDefinedConstants()))) {
return $_index;
}
throw new \InvalidArgumentException('The value "' . $value . '" has no associated constant.');
} | Given a VALUE, return the associated CONSTANT
@param string $value
@return string | entailment |
public static function toValue($constant)
{
if (false !== ($_index = array_search($constant, static::getDefinedConstants(true)))) {
return $_index;
}
throw new \InvalidArgumentException('The constant "' . $constant . '" has no associated value.');
} | Given a CONSTANT, return the associated VALUE
@param mixed $constant
@return string | entailment |
public static function resolve($item)
{
try {
return static::toConstant($item);
} catch (\Exception $_ex) {
// Ignored...
}
try {
return static::toValue($item);
} catch (\Exception $_ex) {
// Ignored...
}
// ... | Given a CONSTANT or VALUE, return the VALUE
@param string|int $item
@return mixed | entailment |
public static function contains($value, $returnConstant = false)
{
try {
$_key = static::toConstant($value);
return $returnConstant ? $_key : true;
} catch (\Exception $_ex) {
return false;
}
} | Returns constant name or true/false if class contains a specific constant value.
Use for validity checks:
if ( false === VeryCoolShit::contains( $evenCoolerShit ) ) {
throw new \InvalidArgumentException( 'Sorry, your selection of "' . $evenCoolerShit . '" is invalid.' );
}
@param mixed $value
@param bool $returnCon... | entailment |
public static function defines($constant, $returnValue = false)
{
try {
$_value = static::toValue($constant);
return $returnValue ? $_value : true;
} catch (\InvalidArgumentException $_ex) {
if ($returnValue) {
throw $_ex;
}
}
... | Returns true or false if this class defines a specific constant.
Optionally returns the value of the constant, but throws an
exception if not found.
Use for validity checks:
if ( false === VeryCoolShit::contains( $evenCoolerShit ) ) {
throw new \InvalidArgumentException( 'Sorry, your selection of "' . $evenCoolerShit... | entailment |
public static function nameOf($constant, $flipped = true, $pretty = true)
{
try {
$_name = $flipped ? static::toValue($constant) : static::toConstant($constant);
} catch (\InvalidArgumentException $_ex) {
throw new \InvalidArgumentException('A constant with the value of "' . ... | Returns the constant name as a string
@param string|int $constant The CONSTANT's value that you want the name of
@param bool $flipped If false, $constant should be the CONSTANT's name. The CONSTANT's value will be
returned instead.
@param bool $pretty If true, returned value is prettified (acme.before_e... | entailment |
public static function prettyList($quote = null, $tags = false, $numbers = false, $lastOr = true)
{
$quote != '\'' && $quote != '"' && $quote = null;
$_values = array_values($tags ? static::$tags : static::getDefinedConstants(true));
// Remove unwanted items...
for ($_i = 0, $_max ... | Returns a list of the constants in a comma-separated display manner
@param string|null $quote An optional quote to enrobe the value (' or " only)
@param bool $tags If true, $tags will be used instead of the constants themselves
@param bool $numbers If true, the numeric value of the constant will be ... | entailment |
public static function neutralizeObject($object, $strip = null)
{
$_variables = is_array($object) ? $object : get_object_vars($object);
if (!empty($_variables)) {
foreach ($_variables as $_key => $_value) {
$_originalKey = $_key;
if ($strip) {
... | Given an object, returns an array containing the variables of the object and their values.
The keys for the object have been neutralized for your protection
@param object $object
@param string $strip If provided, it's value is removed from item before it's neutralized.
Example: "REQUEST_URI" would be "URI" with $strip... | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.