sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
public function getFromEntityByIds(string $entityFrom, array $entityIds, array $filterParams = []) { $uriAppend = "from/{$entityFrom}"; $params = ['entityIds' => implode(",", $entityIds)]; if ($filterParams) { $params['params'] = json_encode([$filterParams]); } ...
@param string $entityFrom @param array $entityIds @param array $filterParams @return array|int|Entity|Collection @throws \GuzzleHttp\Exception\GuzzleException
entailment
private function prepareElasticSearchBody(array $data, array $params = []): BodyBuilder { $entityWeights = []; $indexes = []; foreach (array_column($data, 'attributes') as $correlation) { $entityCodeInSingular = $correlation['type']; if (substr($entityCodeInSing...
@param array $data @param array $params @return BodyBuilder
entailment
public function next() { $row = $this->getRow($this->pointer); if (!is_null($row)) { $this->pointer++; } }
Move forward to next element @link http://php.net/manual/en/iterator.next.php @return void Any returned value is ignored. @since 5.0.0
entailment
protected function doValidate($input) { if (!$this->isString($input)) { $this->addError('notString'); return false; } $len = strlen($input); if ($len != 15 && $len != 18) { $this->addError('invalid'); return false; } /...
{@inheritdoc}
entailment
public function calcChecksum($input) { $wi = array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2); $sum = 0; for ($i = 16; $i >= 0; $i--) { $sum += $input[$i] * $wi[$i]; } $checksum = (12 - $sum % 11) % 11; return $checksum == 10 ? 'X' : (string)$...
Calculate the final digit of id card @param string $input The 17 or 18-digit code @return string
entailment
protected function doValidate($input) { if (!$this->isString($input)) { $this->addError('notDivisible'); return false; } if (is_float($this->divisor)) { $result = fmod($input, $this->divisor); } else { $result = $input % $this->divisor...
{@inheritdoc}
entailment
public function toArray($returnFields = array()) { if (!$this->isColl) { $data = array_fill_keys($returnFields ?: $this->getFields(), null); if (!$returnFields) { return $this->data + $data; } else { $data = array_fill_keys($returnFields, n...
Returns the record data as array @param array $returnFields A indexed array specified the fields to return @return array
entailment
public function fromArray($data) { foreach ($data as $key => $value) { if (is_int($key) || $this->isFillable($key)) { $this->set($key, $value); } } return $this; }
Import a PHP array in this record @param array|\ArrayAccess $data @return $this
entailment
public function isFillable($field) { return !in_array($field, $this->guarded) && !$this->fillable || in_array($field, $this->fillable); }
Check if the field is assignable through fromArray method @param string $field @return bool
entailment
public function setData($data) { foreach ($data as $field => $value) { $this->set($field, $value); } return $this; }
Import a PHP array in this record @param array|\ArrayAccess $data @return $this
entailment
public function save($data = array()) { // 1. Merges data from parameters $data && $this->fromArray($data); // 2.1 Saves single record if (!$this->isColl) { // 2.1.1 Returns when record has been destroy to avoid store dirty data if ($this->isDestroyed) { ...
Save the record or data to database @param array $data @return $this
entailment
public function destroy($conditions = false) { $this->andWhere($conditions); !$this->loaded && $this->loadData(0); if (!$this->isColl) { $this->triggerCallback('beforeDestroy'); $this->executeDestroy(); $this->isDestroyed = true; $this->trigge...
Delete the current record and trigger the beforeDestroy and afterDestroy callback @param mixed $conditions @return $this
entailment
public function reload() { $this->data = (array)$this->db->select($this->table, array($this->primaryKey => $this->get($this->primaryKey))); $this->changedData = array(); $this->isChanged = false; $this->triggerCallback('afterLoad'); return $this; }
Reload the record data from database @return $this
entailment
public function saveColl($data, $extraData = array(), $sort = false) { if (!is_array($data)) { return $this; } // 1. Uses primary key as data index $newData = array(); foreach ($this->data as $key => $record) { unset($this->data[$key]); //...
Merges data into collection and save to database, including insert, update and delete @param array $data A two-dimensional array @param array $extraData The extra data for new rows @param bool $sort @return $this
entailment
public function get($name) { // Check if field exists when it is not a collection if (!$this->isColl && !in_array($name, $this->getFields())) { throw new \InvalidArgumentException(sprintf( 'Field "%s" not found in record class "%s"', $name, ...
Receives the record field value @param string $name @throws \InvalidArgumentException When field not found @return mixed|$this
entailment
public function set($name, $value = null) { $this->loaded = true; // Set record for collection if (!$this->data && $value instanceof static) { $this->isColl = true; } if (!$this->isColl) { if (in_array($name, $this->getFields())) { $t...
Set the record field value @param string $name @param mixed $value @throws \InvalidArgumentException @return $this
entailment
public function setAll($name, $value) { foreach ($this->data as $record) { $record[$name] = $value; } return $this; }
Set field value for every record in collection @param string $name @param mixed $value @return $this
entailment
public function getAll($name) { $data = array(); foreach ($this->data as $record) { $data[] = $record[$name]; } return $data; }
Return the value of field from every record in collection @param string $name @return array
entailment
public function remove($name) { if (!$this->isColl) { if (array_key_exists($name, $this->data)) { $this->data[$name] = null; } } else { unset($this->data[$name]); } return $this; }
Remove field value @param string $name The name of field @return $this
entailment
public function getFields() { if (empty($this->fields)) { $this->fields = $this->db->getTableFields($this->fullTable, true); } return $this->fields; }
Returns the name of fields of current table @return array
entailment
public function getChangedData($field = null) { if ($field) { return isset($this->changedData[$field]) ? $this->changedData[$field] : null; } return $this->changedData; }
Return the field data before changed @param string $field @return string|array
entailment
public function execute() { if ($this->type == self::SELECT) { $this->loaded = true; if ($this->cacheTime !== false) { return $this->fetchFromCache(); } else { return $this->db->fetchAll($this->getSql(), $this->params, $this->paramTypes); ...
Execute this query using the bound parameters and their types @return mixed
entailment
public function find($conditions = false) { $this->isColl = false; $data = $this->fetch($conditions); if ($data) { $this->data = $data + $this->data; $this->triggerCallback('afterFind'); return $this; } else { return false; } ...
Executes the generated SQL and returns the found record object or false @param mixed $conditions @return $this|false
entailment
public function findOrInit($conditions = false, $data = array()) { if (!$this->find($conditions)) { // Reset status when record not found $this->isNew = true; !is_array($conditions) && $conditions = array($this->primaryKey => $conditions); // Convert to obje...
Find a record by specified conditions and init with the specified data if record not found @param mixed $conditions @param array $data @return $this
entailment
public function findAll($conditions = false) { $this->isColl = true; $data = $this->fetchAll($conditions); $records = array(); foreach ($data as $key => $row) { /** @var $records Record[] */ $records[$key] = $this->db->init($this->table, $row, false); ...
Executes the generated SQL and returns the found record collection object or false @param mixed $conditions @return $this|$this[]
entailment
public function fetch($conditions = false) { $this->andWhere($conditions); $this->limit(1); $data = $this->execute(); return $data ? $data[0] : false; }
Executes the generated query and returns the first array result @param mixed $conditions @return array|false
entailment
public function fetchColumn($conditions = false) { $data = $this->fetch($conditions); return $data ? current($data) : false; }
Executes the generated query and returns a column value of the first row @param mixed $conditions @return array|false
entailment
public function fetchAll($conditions = false) { $this->andWhere($conditions); $data = $this->execute(); if ($this->indexBy) { $data = $this->executeIndexBy($data, $this->indexBy); } return $data; }
Executes the generated query and returns all array results @param mixed $conditions @return array|false
entailment
public function count($conditions = false, $count = '1') { $this->andWhere($conditions); $select = $this->sqlParts['select']; $this->select('COUNT(' . $count . ')'); $count = (int)$this->db->fetchColumn($this->getSqlForSelect(true), $this->params); $this->sqlParts['select'] ...
Executes a COUNT query to receive the rows number @param mixed $conditions @param string $count @return int
entailment
public function countBySubQuery($conditions = false) { $this->andWhere($conditions); return (int)$this->db->fetchColumn($this->getSqlForCount(), $this->params); }
Executes a sub query to receive the rows number @param mixed $conditions @return int
entailment
public function update($set = array()) { if (is_array($set)) { $params = array(); foreach ($set as $field => $param) { $this->add('set', $field . ' = ?', true); $params[] = $param; } $this->params = array_merge($params, $this->p...
Execute a update query with specified data @param array|string $set @return int
entailment
public function delete($conditions = false) { $this->andWhere($conditions); $this->type = self::DELETE; return $this->execute(); }
Execute a delete query with specified conditions @param mixed $conditions @return mixed
entailment
public function offset($offset) { $offset = (int)$offset; $offset < 0 && $offset = 0; return $this->add('offset', $offset); }
Sets the position of the first result to retrieve (the "offset") @param integer $offset The first result to return @return $this
entailment
public function limit($limit) { $limit = (int)$limit; $limit < 1 && $limit = 1; return $this->add('limit', $limit); }
Sets the maximum number of results to retrieve (the "limit") @param integer $limit The maximum number of results to retrieve @return $this
entailment
public function page($page) { $limit = $this->getSqlPart('limit'); if (!$limit) { $limit = 10; $this->add('limit', $limit); } return $this->offset(($page - 1) * $limit); }
Sets the page number, the "OFFSET" value is equals "($page - 1) * LIMIT" @param int $page The page number @return $this
entailment
public function from($from) { $pos = strpos($from, ' '); if (false !== $pos) { $this->table = substr($from, 0, $pos); } else { $this->table = $from; } $this->fullTable = $this->db->getTable($this->table); return $this->add('from', $this->db->ge...
Sets table for FROM query @param string $from The table @return $this
entailment
public function where($conditions, $params = array(), $types = array()) { if ($conditions === false) { return $this; } else { $conditions = $this->processCondition($conditions, $params, $types); return $this->add('where', $conditions); } }
Specifies one or more restrictions to the query result. Replaces any previously specified restrictions, if any. ```php $user = wei()->db('user')->where('id = 1'); $user = wei()->db('user')->where('id = ?', 1); $users = wei()->db('user')->where(array('id' => '1', 'username' => 'twin')); $users = wei()->where(array('id'...
entailment
public function andWhere($conditions, $params = array(), $types = array()) { if ($conditions === false) { return $this; } else { $conditions = $this->processCondition($conditions, $params, $types); return $this->add('where', $conditions, true, 'AND'); } ...
Adds one or more restrictions to the query results, forming a logical conjunction with any previously specified restrictions @param string|array $conditions The WHERE conditions @param array $params The condition parameters @param array $types The parameter types @return $this
entailment
public function orWhere($conditions, $params = array(), $types = array()) { $conditions = $this->processCondition($conditions, $params, $types); return $this->add('where', $conditions, true, 'OR'); }
Adds one or more restrictions to the query results, forming a logical disjunction with any previously specified restrictions. @param string $conditions The WHERE conditions @param array $params The condition parameters @param array $types The parameter types @return $this
entailment
public function having($conditions, $params = array(), $types = array()) { $conditions = $this->processCondition($conditions, $params, $types); return $this->add('having', $conditions); }
Specifies a restriction over the groups of the query. Replaces any previous having restrictions, if any. @param string $conditions The having conditions @param array $params The condition parameters @param array $types The parameter types @return $this
entailment
public function andHaving($conditions, $params = array(), $types = array()) { $conditions = $this->processCondition($conditions, $params, $types); return $this->add('having', $conditions, true, 'AND'); }
Adds a restriction over the groups of the query, forming a logical conjunction with any existing having restrictions. @param string $conditions The HAVING conditions to append @param array $params The condition parameters @param array $types The parameter types @return $this
entailment
public function orHaving($conditions, $params = array(), $types = array()) { $conditions = $this->processCondition($conditions, $params, $types); return $this->add('having', $conditions, true, 'OR'); }
Adds a restriction over the groups of the query, forming a logical disjunction with any existing having restrictions. @param string $conditions The HAVING conditions to add @param array $params The condition parameters @param array $types The parameter types @return $this
entailment
public function indexBy($field) { $this->data = $this->executeIndexBy($this->data, $field); $this->indexBy = $field; return $this; }
Specifies a field to be the key of the fetched array @param string $field @return $this
entailment
public function getSqlPart($name) { return isset($this->sqlParts[$name]) ? $this->sqlParts[$name] : false; }
Returns a SQL query part by its name @param string $name The name of SQL part @return mixed
entailment
public function resetSqlParts($name = null) { if (is_null($name)) { $name = array_keys($this->sqlParts); } foreach ($name as $queryPartName) { $this->resetSqlPart($queryPartName); } return $this; }
Reset all SQL parts @param array $name @return $this
entailment
public function resetSqlPart($name) { $this->sqlParts[$name] = is_array($this->sqlParts[$name]) ? array() : null; $this->state = self::STATE_DIRTY; return $this; }
Reset single SQL part @param string $name @return $this
entailment
public function getParameter($key) { return isset($this->params[$key]) ? $this->params[$key] : null; }
Gets a (previously set) query parameter of the query being constructed @param mixed $key The key (index or name) of the bound parameter @return mixed The value of the bound parameter
entailment
public function getSql() { if ($this->sql !== null && $this->state === self::STATE_CLEAN) { return $this->sql; } switch ($this->type) { case self::DELETE: $this->sql = $this->getSqlForDelete(); break; case self::UPDATE: ...
Get the complete SQL string formed by the current specifications of this QueryBuilder @return string The sql query string
entailment
protected function getSqlForSelect($count = false) { $parts = $this->sqlParts; if (!$parts['select']) { $parts['select'] = array('*'); } $query = 'SELECT ' . implode(', ', $parts['select']) . ' FROM ' . $this->getFrom(); // JOIN foreach ($parts['join'] ...
Converts this instance into an SELECT string in SQL @param bool $count @return string
entailment
protected function getSqlForUpdate() { $query = 'UPDATE ' . $this->getFrom() . ' SET ' . implode(", ", $this->sqlParts['set']) . ($this->sqlParts['where'] !== null ? ' WHERE ' . ((string)$this->sqlParts['where']) : ''); return $query; }
Converts this instance into an UPDATE string in SQL. @return string
entailment
public function offsetSet($offset, $value) { $this->loadData($offset); $this->set($offset, $value); }
Set the offset value @param string $offset @param mixed $value
entailment
protected function add($sqlPartName, $sqlPart, $append = false, $type = null) { $this->isNew = false; if (!$sqlPart) { return $this; } $isArray = is_array($sqlPart); $isMultiple = is_array($this->sqlParts[$sqlPartName]); if ($isMultiple && !$isArray) { ...
Either appends to or replaces a single, generic query part. The available parts are: 'select', 'from', 'set', 'where', 'groupBy', 'having', 'orderBy', 'limit' and 'offset'. @param string $sqlPartName @param string $sqlPart @param boolean $append @param string $type @return $this
entailment
protected function processCondition($conditions, $params, $types) { // Regard numeric and null as primary key value if (is_numeric($conditions) || empty($conditions)) { $conditions = array($this->primaryKey => $conditions); } if (is_array($conditions)) { $whe...
Generate condition string for WHERE or Having statement @param mixed $conditions @param array $params @param array $types @return string
entailment
protected function loadData($offset) { if (!$this->loaded && !$this->isNew) { if (is_numeric($offset) || is_null($offset)) { $this->findAll(); } else { $this->find(); } } }
Load record by array offset @param int|string $offset
entailment
public function filter(\Closure $fn) { $data = array_filter($this->data, $fn); $records = $this->db->init($this->table, array(), $this->isNew); $records->data = $data; $records->isColl = true; $records->loaded = $this->loaded; return $records; }
Filters elements of the collection using a callback function @param \Closure $fn @return $this
entailment
public function cache($seconds = null) { if ($seconds === null) { $this->cacheTime = $this->defaultCacheTime; } elseif ($seconds === false) { $this->cacheTime = false; } else { $this->cacheTime = (int)$seconds; } return $this; }
Set or remove cache time for the query @param int|null|false $seconds @return $this
entailment
public function tags($tags = null) { $this->cacheTags = $tags === false ? false : $tags; return $this; }
Set or remove cache tags @param array|null|false $tags @return $this
entailment
public function getCacheKey() { return $this->cacheKey ?: md5($this->db->getDbname() . $this->getSql() . serialize($this->params) . serialize($this->paramTypes)); }
Generate cache key form query and params @return string
entailment
protected function doValidate($input) { if (!$this->isString($input)) { $this->addError('notString'); return false; } if (8 != strlen($input)) { $this->addError('invalid'); return false; } $input = strtoupper($input); ...
{@inheritdoc}
entailment
public function buildForm(FormBuilderInterface $builder, array $options) { foreach ($options['button_groups'] as $name => $config) { $builder->add($name, ButtonGroupType::class, $config); } }
Pull all group of button into the form. {@inheritdoc}
entailment
public function execute() { try { // Note that when provided a non-existing WSDL, PHP will still generate an error in error_get_last() // https://github.com/bcosca/fatfree/issues/404 // https://bugs.php.net/bug.php?id=65779 // Prepare request $soa...
Execute the request, parse the response data and trigger relative callbacks
entailment
public function loadFromFile($pattern) { if (isset($this->files[$pattern])) { return $this; } $file = sprintf($pattern, $this->locale); if (!is_file($file)) { $defaultFile = sprintf($pattern, $this->defaultLocale); if (!is_file($defaultFile)) { ...
Loads translator messages from file @param string $pattern The file path, which can contains %s that would be convert the current locale or fallback locale @return $this @throws \InvalidArgumentException When file not found or not readable
entailment
protected function doValidate($input) { if (!is_array($input) && !$input instanceof \Traversable) { $this->addError('notArray'); return false; } $index = 1; $validator = null; foreach ($input as $item) { foreach ($this->rules as $rule => $...
{@inheritdoc}
entailment
public function getMessages($name = null) { $this->loadTranslationMessages(); $translator = $this->t; // Firstly, translates the item name (%name%'s %index% item) // Secondly, translates "%name%" in the item name $name = $translator($translator($this->itemName), array( ...
{@inheritdoc}
entailment
public function assign($name, $value = null) { if (is_array($name)) { foreach ($name as $key => $value) { $this->object->addGlobal($key, $value); } } else { $this->object->addGlobal($name, $value); } return $this; }
{@inheritdoc}
entailment
public function onAfterLoadIntoFile($file) { // return if not an image if (!$file->getIsImage()) { return; } // get parent folder path $folder = rtrim($file->Parent()->getFilename(), '/'); $custom_folders = $this->config()->get('custom_folders'); ...
Post data manupulation @param File @return Null
entailment
private function scaleUploadedImage($file) { $backend = $file->getImageBackend(); // temporary location for image manipulation $tmp_image = TEMP_FOLDER . '/resampled-' . mt_rand(100000, 999999) . '.' . $file->getExtension(); $tmp_contents = $file->getString(); // write to ...
Scale an image @param File @return Null
entailment
private function exifRotation($file) { if (!function_exists('exif_read_data')) { return false; } $exif = @exif_read_data($file); if (!$exif) { return false; } $ort = @$exif['IFD0']['Orientation']; if (!$ort) { $ort = @$e...
exifRotation - return the exif rotation @param String $FileName @return Int false|angle
entailment
protected function doValidate($input) { if (!$this->isString($input)) { $this->addError('notString'); return false; } if (10 != strlen($input)) { $this->addError('invalid'); return false; } $input = strtoupper($input); ...
{@inheritdoc}
entailment
protected function doValidate($input) { $this->count = 0; foreach ($this->fields as $field) { if ($this->validator->getFieldData($field)) { $this->count++; } } if (!is_null($this->length) && $this->count != $this->length) { $this->...
{@inheritdoc}
entailment
public function build() { return [ 'offset' => $this->getOffset(), 'limit' => $this->getLimit(), 'orderBy' => $this->getOrderBy(), 'orderDirection' => $this->getOrderDirection(), 'withFeedbackOnly' => $this->isWithFe...
{@inheritdoc}
entailment
protected function doValidate($input) { if (false === ($len = $this->getLength($input))) { $this->addError('notDetected'); return false; } if ($this->max < $len) { $this->addError(is_scalar($input) ? 'tooLong' : 'tooMany'); return false; ...
{@inheritdoc}
entailment
protected function doCreateObject(array $array) { $this->data = $array; $this->category = new Category($this->data); $this->setMedia() ->setAttributes(); return $this->category; }
@param array $array @return Category
entailment
public function full($url, $argsOrParams = array(), $params = array()) { return $this->request->getUrlFor($this->__invoke($url, $argsOrParams, $params)); }
Generate the absolute URL path by specified URL and parameters @param string $url @param string|array $argsOrParams @param string|array $params @return string
entailment
public function query($url = '', $argsOrParams = array(), $params = array()) { if (strpos($url, '%s') === false) { $argsOrParams = $argsOrParams + $this->request->getQueries(); } else { $params += $this->request->getQueries(); } return $this->__invoke($url, $a...
Generate the URL path with current query parameters and specified parameters @param string $url @param string|array $argsOrParams @param string|array $params @return string
entailment
public function append($url = '', $argsOrParams = array(), $params = array()) { if (strpos($url, '%s') !== false) { $url = vsprintf($url, (array)$argsOrParams); } else { $params = $argsOrParams; } if ($params) { $url .= (false === strpos($url, '?')...
Append parameters to specified URL @param string $url @param string|array $argsOrParams The arguments to replace in URL or the parameters append to the URL @param string|array $params The parameters append to the URL @return string
entailment
private function getPart($key) { if (\array_key_exists($key, $this->content) === false) { $this->content[$key]=new HtmlTableContent("", $key); if ($key !== "tbody") { $this->content[$key]->setRowCount(1, $this->_colCount); } } return $this->content[$key]; }
Returns/create eventually a part of the table corresponding to the $key : thead, tbody or tfoot @param string $key @return HtmlTableContent
entailment
public function addRow($values=array()) { $row=$this->getBody()->addRow($this->_colCount); $row->setValues(\array_values($values)); return $this; }
Adds a new row and sets $values to his cols @param array $values @return \Ajax\semantic\html\collections\HtmlTable
entailment
protected function readAndVerify($handle, $file) { $content = $this->getContent($file); // Check if content is valid if ($content && is_array($content) && time() < $content[0]) { return $content; } else { return false; } }
{@inheritdoc}
entailment
protected function prepareContent($content, $expire) { $time = time(); $content = var_export(array($expire ? $time + $expire : 2147483647, $content), true); return "<?php\n\nreturn " . $content . ';'; }
{@inheritdoc}
entailment
public function ap(Monadic $app) : Monadic { $list = $this->extract(); $result = compose( partialLeft(\Chemem\Bingo\Functional\Algorithms\filter, function ($val) { return is_callable($val); }), partialLeft( \Chemem\Bingo\Functional...
ap method. @param object ListMonad @return object ListMonad
entailment
public function bind(callable $function) : Monadic { $concat = compose( function (array $list) use ($function) { return fold( function ($acc, $item) use ($function) { $acc[] = $function($item)->extract(); return...
bind method. @param callable $function @return object ListMonad
entailment
public function getHistoryByEntityAndId(string $entity, int $objectId) { $params = $this->getQueryParams(); $uriAppend = "$entity/$objectId"; $response = $this->handler->handle('GET', false, $uriAppend, $params); if (!$response->getSuccess()) { throw new EntityNotFoundEx...
@param string $entity @param int $objectId @return array|int|\SphereMall\MS\Entities\Entity|\SphereMall\MS\Lib\Collection @throws EntityNotFoundException @throws \GuzzleHttp\Exception\GuzzleException
entailment
public function addHistory(string $entity, int $entityId, array $params = []) { $uriAppend = "$entity/$entityId"; $response = $this->handler->handle('POST', $params, $uriAppend); if (!$response->getSuccess()) { throw new EntityNotFoundException($response->getErrorMessage()); ...
@param string $entity @param int $entityId @param array $params @return array|int|\SphereMall\MS\Entities\Entity|\SphereMall\MS\Lib\Collection @throws EntityNotFoundException @throws \GuzzleHttp\Exception\GuzzleException
entailment
public final function setOrderData(Order $order) { if (get_called_class() != self::class) { throw new \InvalidArgumentException("Method can be call only by OrderFinalized entity"); } $this->id = $order->id; $this->setProperties($order); }
#region [Setter]
entailment
public function update(array $params = []) { $params = array_intersect_key( $params, array_flip([ 'statusId', 'orderId', 'paymentStatusId', 'additionalInfo', 'paymentStatusDescription' ]) ...
@param array $params @throws \SphereMall\MS\Exceptions\EntityNotFoundException
entailment
protected function doValidate($input) { parent::doValidate($input); if ($this->hasError('notString') || $this->hasError('notFound')) { return false; } // Receive the real file path resolved by parent class $file = $this->file; $size = @getimagesize($file...
{@inheritdoc}
entailment
private function getParamsFromFilter() { if (!$this->body['filter']) { return []; } $result = []; $must = []; $mustNot = []; $params = $this->body['filter']->getParams(); if (isset($params['groupBy']) && $params['groupBy']) { $re...
@param $filter @return array
entailment
private function initGroupBy($factorValues = []) { $this->groupBy = true; $params['body']['size'] = 0; $size = $this->body['size'] ? $this->body['size'] : self::DEFAULT_SIZE; $from = $this->body['from'] ? $this->body['from'] : 0; $terms = new TermsAggregation("variantsCo...
@param array $factorValues @return mixed
entailment
public function orElse(Maybe $maybe) : Maybe { return !isset($this->value) ? $maybe : new static($this->value); }
{@inheritdoc}
entailment
public function get($key, $expire = null, $fn = null) { $result = $this->master->get($key); if (false === $result) { $result = $this->slave->get($key); } return $this->processGetResult($key, $result, $expire, $fn); }
{@inheritdoc}
entailment
public function remove($key) { $result1 = $this->master->remove($key); $result2 = $this->slave->remove($key); return $result1 && $result2; }
{@inheritdoc}
entailment
public function exists($key) { return $this->master->exists($key) || $this->slave->exists($key); }
{@inheritdoc}
entailment
public function add($key, $value, $expire = 0) { $result = $this->master->add($key, $value, $expire); // The cache can be added only one time, when added success, set it to the slave cache if ($result) { // $result is true, so return the slave cache result only retur...
{@inheritdoc}
entailment
public function incr($key, $offset = 1) { $result = $this->master->incr($key, $offset); if (false !== $result && $this->needUpdate($key)) { return $this->slave->set($key, $result) ? $result : false; } return $result; }
{@inheritdoc}
entailment
public function clear() { $result1 = $this->master->clear(); $result2 = $this->slave->clear(); return $result1 && $result2; }
{@inheritdoc}
entailment
public function endTiming($key, $sampleRate = 1) { $end = gettimeofday(true); if (isset($this->timings[$key])) { $timing = ($end - $this->timings[$key]) * 1000; $this->timing($key, $timing, $sampleRate); unset($this->timings[$key]); return $timing; ...
Ends the timing for a key and sends it to StatsD @param string $key @param int|float $sampleRate the rate (0-1) for sampling. @return float|null
entailment
public function time($key, \Closure $fn, $sampleRate = 1) { $this->startTiming($key); $return = $fn(); $this->endTiming($key, $sampleRate); return $return; }
Executes a Closure and records it's execution time and sends it to StatsD returns the value the Closure returned @param string $key @param \Closure $fn @param int|float $sampleRate the rate (0-1) for sampling. @return mixed
entailment
public function endMemoryProfile($key, $sampleRate = 1) { $end = memory_get_usage(); if (array_key_exists($key, $this->memoryProfiles)) { $memory = ($end - $this->memoryProfiles[$key]); $this->memory($key, $memory, $sampleRate); unset($this->memoryProfiles[$key]);...
Ends the memory profiling and sends the value to the server @param string $key @param int|float $sampleRate the rate (0-1) for sampling.
entailment
public function memory($key, $memory = null, $sampleRate = 1) { if (null === $memory) { $memory = memory_get_peak_usage(); } $this->count($key, $memory, $sampleRate); }
Report memory usage to StatsD. if memory was not given report peak usage @param string $key @param int $memory @param int|float $sampleRate the rate (0-1) for sampling.
entailment