sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
private function createWorker() { $worker = $this->factory->create(); $worker->start(); $this->workers->attach($worker, 0); return $worker; }
Creates a worker and adds them to the pool. @return Worker The worker created.
entailment
public function get(): Worker { if (!$this->isRunning()) { throw new StatusError('The queue is not running.'); } do { if ($this->idleWorkers->isEmpty()) { if ($this->getWorkerCount() >= $this->maxSize) { // All possible workers bus...
{@inheritdoc}
entailment
private function push(Worker $worker) { if (!$this->workers->contains($worker)) { throw new InvalidArgumentError( 'The provided worker was not part of this queue.' ); } if (0 === ($this->workers[$worker] -= 1)) { // Worker is completely id...
Pushes the worker back into the queue. @param \Icicle\Concurrent\Worker\Worker $worker @throws \Icicle\Exception\InvalidArgumentError If the worker was not part of this queue.
entailment
public function acquire(): \Generator { $tsl = function () { // If there are no locks available or the wait queue is not empty, // we need to wait our turn to acquire a lock. if ($this->locks > 0) { --$this->locks; return false; ...
Uses a double locking mechanism to acquire a lock without blocking. A synchronous mutex is used to make sure that the semaphore is queried one at a time to preserve the integrity of the semaphore itself. Then a lock count is used to check if a lock is available without blocking. If a lock is not available, we add the ...
entailment
public function run(): \Generator { $task = yield from $this->channel->receive(); while ($task instanceof Task) { $this->idle = false; try { $result = yield $task->run($this->environment); } catch (\Throwable $exception) { $result...
@coroutine @return \Generator
entailment
public function getResult() { throw new PanicError( sprintf( 'Uncaught exception in execution context of type "%s" with message "%s"', $this->type, $this->message ), $this->code, $this->trace ); }
{@inheritdoc}
entailment
public function getElementName(string $text = null): string { if ($text) { $text = str_replace('.', '_', $text); return '_' . $text; } return 'js_amiGridList_' . $this->id; }
@param string|null $text @return string
entailment
public function setColumn(\Assurrussa\GridView\Interfaces\ColumnInterface $column): ColumnsInterface { $this->_columns[] = $column; return $this; }
@param ColumnInterface $column @return ColumnInterface
entailment
public function filterActions(\Illuminate\Database\Eloquent\Model $instance): array { $listButtons = []; if ($this->count()) { $buttons = $this->getActions(); foreach ($buttons as &$button) { if ($button->getValues($instance)) { $listButton...
The method gets the buttons for the grid table @param \Illuminate\Database\Eloquent\Model $instance @return array
entailment
public function getInstance($provider) { $result = null; if ($this->container->has('port1_hybrid_auth.' . strtolower($provider) . '_authentication_service')) { $result = $this->container ->get('port1_hybrid_auth.' . strtolower($provider) . '_authentication_service'); ...
@param string $provider @return AuthenticationServiceInterface|null @throws \Exception
entailment
public function handle() { try { $options = array( 'server' => $this->option('server'), 'repo' => $this->option('repo') ); $maneuver = new Maneuver($options); $maneuver->mode(Maneuver::MODE_LIST); $maneuver->start()...
Execute the console command. @return mixed
entailment
public function add_entry_or_merge($entry) { if (is_array($entry)) { $entry = new EntryTranslations($entry); } $key = $entry->key(); if (false === $key) { return false; } if (isset($this->entries[$key])) { $this->entries[$key]->merg...
@param array|EntryTranslations $entry @return bool
entailment
public function set($key, $value) { $this->cacheIsFresh = false; $this->store->set($key, $value); }
{@inheritdoc}
entailment
public function count() { if (!$this->cacheIsFresh) { $this->cache = count($this->store->keys()); $this->cacheIsFresh = true; } return $this->cache; }
{@inheritdoc}
entailment
public function import_from_file($filename) { $reader = new FileReader($filename); if (!$reader->is_resource()) { return false; } $this->filename = (string) $filename; return $this->import_from_reader($reader); }
Fills up with the entries from MO file $filename. @param string $filename MO file to load @return bool Success
entailment
public function export_to_file($filename) { $fh = fopen($filename, 'wb'); if (!$fh) { return false; } $res = $this->export_to_file_handle($fh); fclose($fh); return $res; }
@param string $filename @return bool
entailment
public function is_entry_good_for_export(EntryTranslations $entry) { if (empty($entry->translations)) { return false; } if (!array_filter($entry->translations)) { return false; } return true; }
@param EntryTranslations $entry @return bool
entailment
public function export_to_file_handle($fh) { $entries = array_filter( $this->entries, array($this, 'is_entry_good_for_export') ); ksort($entries); $magic = 0x950412de; $revision = 0; $total = count($entries) + 1; // all the headers are one entr...
@param resource $fh @return true
entailment
public function export_original(EntryTranslations $entry) { //TODO: warnings for control characters $exported = $entry->singular; if ($entry->is_plural) { $exported .= chr(0) . $entry->plural; } if (!is_null($entry->context)) { $exported = $entry->cont...
@param EntryTranslations $entry @return string
entailment
public function export_translations(EntryTranslations $entry) { //TODO: warnings for control characters return $entry->is_plural ? implode(chr(0), $entry->translations) : $entry->translations[0]; }
@param EntryTranslations $entry @return string
entailment
public function get_byteorder($magic) { // The magic is 0x950412de $magic_little = (int) - 1794895138; $magic_little_64 = (int) 2500072158; // 0xde120495 $magic_big = ((int) - 569244523) & 0xFFFFFFFF; if ($magic_little == $magic || $magic_little_64 == $magic) { ...
@param int $magic @return string|false
entailment
public function import_from_reader(FileReader $reader) { $endian_string = $this->get_byteorder($reader->readint32()); if (false === $endian_string) { return false; } $reader->setEndian($endian_string); $endian = ('big' == $endian_string) ? 'N' : 'V'; $he...
@param FileReader $reader @return bool
entailment
public static function &make_entry($original, $translation) { $entry = new EntryTranslations(); // look for context $parts = explode(chr(4), $original); if (isset($parts[1])) { $original = $parts[1]; $entry->context = $parts[0]; } // look for p...
Build a from original string and translation strings, found in a MO file. @param string $original original string to translate from MO file. Might contain 0x04 as context separator or 0x00 as singular/plural separator @param string $translation translation string from MO file.Might contain 0x00 as a plural transla...
entailment
public static function forValue($value, $reason = '', $code = 0, Exception $cause = null) { return self::forType(is_object($value) ? get_class($value) : gettype($value), $reason, $code, $cause); }
Creates a new exception for the given value. @param mixed $value The value that could not be unserialized. @param string $reason The reason why the value could not be unserialized. @param int $code The exception code. @param Exception $cause The exception that caused this exception. @return static Th...
entailment
public function loginUser($customer) { $this->front->Request()->setPost('email', $customer->getEmail()); $this->front->Request()->setPost('passwordMD5', $customer->getPassword()); return $this->admin->sLogin(true); }
Logs in the user for the given customer object @param Customer $customer @return array|bool @throws \Exception
entailment
public static function hasColumn(\Illuminate\Database\Eloquent\Model $model, string $column): bool { $table = $model->getTable(); $columns = app('cache')->remember('amigrid.columns.' . $table, 60, function () use ($table) { return \Schema::getColumnListing($table); }); re...
Check if model's table has column @param \Illuminate\Database\Eloquent\Model $model @param string $column @return bool
entailment
public function set($key, $value) { KeyUtil::validate($key); $serialized = $this->serialize->__invoke($value); try { $this->collection->replaceOne( array('_id' => $key), array('_id' => $key, 'value' => $serialized), array('upsert'...
{@inheritdoc}
entailment
public function get($key, $default = null) { KeyUtil::validate($key); try { $document = $this->collection->findOne( array('_id' => $key), array('typeMap' => self::$typeMap) ); } catch (Exception $e) { throw ReadException::f...
{@inheritdoc}
entailment
public function getMultiple(array $keys, $default = null) { KeyUtil::validateMultiple($keys); $values = array_fill_keys($keys, $default); try { $cursor = $this->collection->find( array('_id' => array('$in' => array_values($keys))), array('typeMap...
{@inheritdoc}
entailment
public function getMultipleOrFail(array $keys) { KeyUtil::validateMultiple($keys); $values = array(); try { $cursor = $this->collection->find( array('_id' => array('$in' => array_values($keys))), array('typeMap' => self::$typeMap) ); ...
{@inheritdoc}
entailment
public function remove($key) { KeyUtil::validate($key); try { $result = $this->collection->deleteOne(array('_id' => $key)); $deletedCount = $result->getDeletedCount(); } catch (Exception $e) { throw WriteException::forException($e); } ret...
{@inheritdoc}
entailment
public function exists($key) { KeyUtil::validate($key); try { $count = $this->collection->count(array('_id' => $key)); } catch (Exception $e) { throw ReadException::forException($e); } return $count > 0; }
{@inheritdoc}
entailment
public function keys() { try { $cursor = $this->collection->find(array(), array( 'projection' => array('_id' => 1), )); $keys = array(); foreach ($cursor as $document) { $keys[] = $document['_id']; } } catc...
{@inheritdoc}
entailment
public function onCollectLessFiles (\Enlight_Event_EventArgs $args) { $lessDef = new LessDefinition( [], [ sprintf( '%1$s%2$sResources%2$sviews%2$sfrontend%2$s_public%2$ssrc%2$sless%2$shybrid_auth.less', $this->getPath(), ...
@param \Enlight_Event_EventArgs $args @return ArrayCollection
entailment
public function set($key, $value) { $this->flags = null; $this->store->set($key, $value); }
{@inheritdoc}
entailment
public function keys() { $keys = $this->store->keys(); if (null !== $this->flags) { sort($keys, $this->flags); } return $keys; }
{@inheritdoc}
entailment
public function set($key, $value) { KeyUtil::validate($key); try { $existing = $this->exists($key); } catch (Exception $e) { throw WriteException::forException($e); } if (false === $existing) { $this->doInsert($key, $value); } els...
{@inheritdoc}
entailment
public function get($key, $default = null) { KeyUtil::validate($key); $dbResult = $this->getDbRow($key); if (null === $dbResult) { return $default; } return Serializer::unserialize($dbResult['meta_value']); }
{@inheritdoc}
entailment
public function getOrFail($key) { KeyUtil::validate($key); $dbResult = $this->getDbRow($key); if (null === $dbResult) { throw NoSuchKeyException::forKey($key); } return Serializer::unserialize($dbResult['meta_value']); }
{@inheritdoc}
entailment
public function getMultiple(array $keys, $default = null) { KeyUtil::validateMultiple($keys); // Normalize indices of the array $keys = array_values($keys); $data = $this->doGetMultiple($keys); $results = array(); $resolved = array(); foreach ($data as $row)...
{@inheritdoc}
entailment
public function getMultipleOrFail(array $keys) { KeyUtil::validateMultiple($keys); // Normalize indices of the array $keys = array_values($keys); $data = $this->doGetMultiple($keys); $results = array(); $resolved = array(); foreach ($data as $row) { ...
{@inheritdoc}
entailment
public function remove($key) { KeyUtil::validate($key); try { $result = $this->connection->delete($this->tableName, array('meta_key' => $key)); } catch (Exception $e) { throw WriteException::forException($e); } return $result === 1; }
{@inheritdoc}
entailment
public function exists($key) { KeyUtil::validate($key); try { $result = $this->connection->fetchAssoc('SELECT * FROM '.$this->tableName.' WHERE meta_key = ?', array($key)); } catch (Exception $e) { throw ReadException::forException($e); } return $res...
{@inheritdoc}
entailment
public function clear() { try { $stmt = $this->connection->query('DELETE FROM '.$this->tableName); $stmt->execute(); } catch (Exception $e) { throw WriteException::forException($e); } }
{@inheritdoc}
entailment
public function keys() { try { $stmt = $this->connection->query('SELECT meta_key FROM '.$this->tableName); $result = $stmt->fetchAll(PDO::FETCH_COLUMN); } catch (Exception $e) { throw ReadException::forException($e); } return $result; }
{@inheritdoc}
entailment
public function getTableForCreate() { $schema = new Schema(); $table = $schema->createTable($this->getTableName()); $table->addColumn('id', 'integer', array('autoincrement' => true)); $table->addColumn('meta_key', 'string', array('length' => 255)); $table->addColumn('meta_v...
Object Representation of the table used in this class. @return Table
entailment
public function setActionDelete( string $route = null, array $params = [], string $label = '', string $title = 'Deleted', string $class = 'btn btn-danger btn-sm flat', string $icon = 'fa fa-times' ): ButtonInterface { $this->setAction(self::TYPE_ACTION_DELETE)...
@param string|null $route @param array $params @param string $label @param string $title @param string $class @param string $icon @return ButtonInterface
entailment
public function setActionEdit( string $route = null, array $params = [], string $label = '', string $title = 'Edit', string $class = '', string $icon = 'fa fa-pencil' ): ButtonInterface { $this->setAction(self::TYPE_ACTION_EDIT) ->setRoute($route, ...
@param string|null $route @param array $params @param string $label @param string $title @param string $class @param string $icon @return ButtonInterface
entailment
public function setActionCustom( string $url = null, string $label = '', string $class = 'btn btn-primary btn-outline-primary btn-sm flat', string $icon = 'fa fa-paw' ): ButtonInterface { if (!$url) { $url = '#'; } $this->setAction(self::TYPE_ACTIO...
@param string|null $url @param string $label @param string $class @param string $icon @return ButtonInterface
entailment
public function setButtonExport(string $url = null): ButtonInterface { $addUrl = 'export=1'; if (!$url) { $url = url()->current(); } if ($array = request()->except('export')) { $url .= '?' . http_build_query($array); } $addUrl = \Illuminate\Sup...
@param string|null $url @return ButtonInterface
entailment
public function setButtonCreate(string $url): ButtonInterface { $text = GridView::trans('grid.create'); return $this->setActionCustom($url, $text, 'btn btn-primary btn-outline-primary', 'fa fa-plus') ->setAction(self::TYPE_ACTION_CREATE); }
@param string $url @return ButtonInterface
entailment
public function setButtonCheckboxAction( string $url = null, string $addPostUrl = null, string $text = null, string $confirmText = null, string $class = null, string $icon = '' ): ButtonInterface { $addPostUrl = $addPostUrl ?: '?deleted='; $class = $cl...
@param string|null $url @param string|null $addPostUrl @param string|null $view @param string|null $text @param string|null $confirmText @param string|null $class @param string|null $icon @return \Illuminate\Contracts\Support\Renderable
entailment
public function setMethod(string $method = 'POST'): ButtonInterface { if ($this->isVisibility()) { $this->method = $method; } return $this; }
@param string $method @return ButtonInterface
entailment
public function setAction(string $action = ''): ButtonInterface { if ($this->isVisibility()) { $this->action = $action; } return $this; }
@param string $action @return ButtonInterface
entailment
public function setLabel(string $label = null): ButtonInterface { if ($this->isVisibility()) { $this->label = $label; } return $this; }
@param string|null $label @return ButtonInterface
entailment
public function setIcon(string $icon = null): ButtonInterface { if ($this->isVisibility()) { $this->icon = $icon; } return $this; }
@param string|null $icon @return ButtonInterface
entailment
public function setTitle(string $text = null): ButtonInterface { if ($this->isVisibility()) { $this->title = $text; } return $this; }
@param string|null $text @return ButtonInterface
entailment
public function setId(string $id = null): ButtonInterface { if ($this->isVisibility()) { $this->id = $id; } return $this; }
@param string|null $id @return ButtonInterface
entailment
public function setAddString(string $string): ButtonInterface { if ($this->isVisibility()) { $this->strings[] = $string; } return $this; }
@param string $string @return ButtonInterface
entailment
public function setConfirmText( string $text = null, string $colorOk = null, string $colorCancel = null, string $textOk = null, string $textCancel = null ): ButtonInterface { if ($this->isVisibility()) { if ($text) { $this->confirmText = $t...
@param string|null $text @param string|null $colorOk @param string|null $colorCancel @param string|null $textOk @param string|null $textCancel @return ButtonInterface
entailment
public function setUrl(string $url = '#'): ButtonInterface { if ($this->isVisibility()) { // if($this->url !== null) { // if(strpos($this->url, '://') !== false) { // return $this; // } //...
@param string $url @return ButtonInterface
entailment
public function setRoute(string $route = null, array $params = []): ButtonInterface { if ($this->isVisibility()) { if ($route === null) { $url = '#'; } else { $url = '#'; if (app('router')->has($route)) { $url = rout...
If not found route, the button is not visible automatically @param string|null $route @param array $params @return ButtonInterface
entailment
public function setType(string $type): ButtonInterface { if ($this->isVisibility()) { $this->type = $type; } return $this; }
@param string $type @return ButtonInterface
entailment
public function getValues(\Illuminate\Database\Eloquent\Model $instance = null): bool { $this->_instance = $instance; if ($this->isHandler()) { return $this->getHandler(); } return true; }
@param \Illuminate\Database\Eloquent\Model|null $instance @return bool
entailment
public function render(string $view = null, array $params = null): \Illuminate\Contracts\Support\Renderable { $view = $view ? $view : 'column.treeControl'; $params = $params ? $params : $this->toArray(); return GridView::view($view, $params); }
@param string $view @param array|null $params @return Renderable
entailment
protected function parse($str) { $pos = 0; $len = strlen($str); // Convert infix operators to postfix using the shunting-yard algorithm. $output = array(); $stack = array(); while ($pos < $len) { $next = substr($str, $pos, 1); switch ($next) ...
Parse a Plural-Forms string into tokens. Uses the shunting-yard algorithm to convert the string to Reverse Polish Notation tokens. @param string $str String to parse. @throws Exception
entailment
public function get($num) { if (isset($this->cache[$num])) { return $this->cache[$num]; } return $this->cache[$num] = $this->execute($num); }
Get the plural form for a number. Caches the value for repeated calls. @param int $num Number to get plural form for. @return int PluralForms form value. @throws Exception
entailment
public function execute($n) { $stack = array(); $i = 0; $total = count($this->tokens); while ($i < $total) { $next = $this->tokens[$i]; $i++; if ($next[0] === 'var') { $stack[] = $n; continue; } elseif ($...
Execute the plural form function. @param int $n Variable "n" to substitute. @throws Exception @return int PluralForms form value.
entailment
public static function forType($type, $reason = '', $code = 0, Exception $cause = null) { return new static(sprintf( 'Could not serialize value of type %s%s', $type, $reason ? ': '.$reason : '.' ), $code, $cause); }
Creates a new exception for the given value type. @param string $type The type that could not be serialized. @param string $reason The reason why the value could not be unserialized. @param int $code The exception code. @param Exception $cause The exception that caused this exception. @return static ...
entailment
public function fetch( \Illuminate\Database\Eloquent\Builder $query, array $fields = null, string $filename = null, int $cacheSecond = 60, string $format = 'csv', string $contentType = 'text/csv' ): bool { $keyCache = class_basename($query->getModel()); ...
Создаем текст для экспорта данных и выдаем в браузер для скачивания пример array $fields = [ 'ID' => 'id', 'Время звонка' => 'setup_at', 0 => 'brand.name', 'Гости' => function() {return 'name';}, ]; @param \Illuminate\Database\Eloquent\Builder $query модель с критериями для получен...
entailment
protected function isInt($value): bool { // При преобразовании в int игнорируются все окружающие пробелы, но is_numeric допускает только пробелы в начале return is_bool($value) ? false : filter_var($value, FILTER_VALIDATE_INT) !== false; }
Проверяет содержит ли переменная целое значение. Возвращает true если типа integer или содержит только допустимые символы без учета начальных и конечных пробелов Не обрабатывает неопределенные значения! Для безопасной проверки элемента массива или свойства объекта используйте вместе с value(). @param integer|string $v...
entailment
public function compare() { $remoteRevision = null; $filesToUpload = array(); $filesToDelete = array(); // The revision file goes inside the submodule. if ($this->isSubmodule) { $this->revisionFile = $this->isSubmodule . '/' . $this->revisionFile; } ...
Compares local revision to the remote one and builds files to upload and delete @throws Exception if unknown git diff status @return string
entailment
public function upload($file) { if ($this->isSubmodule) { $file = $this->isSubmodule.'/'.$file; } $dir = explode('/', dirname($file)); $path = ''; $pathThatExists = null; $output = array(); // Skip basedir or parent. if ($dir[0] != '.' an...
Uploads file @param string $file @return array
entailment
public function writeRevision() { if ($this->syncCommit) { $localRevision = $this->syncCommit; } else { $localRevision = $this->git->localRevision()[0]; } try { $this->bridge->put($localRevision, $this->revisionFile); } catch (Exce...
Writes latest revision to the remote revision file @throws Exception if can't update revision file
entailment
public function setButton(\Assurrussa\GridView\Interfaces\ButtonInterface $button): ButtonsInterface { $this->_buttons[] = $button; return $this; }
@param ButtonInterface $button @return ButtonsInterface
entailment
public static function forKey($key, Exception $cause = null) { return new static(sprintf( 'Expected a key of type integer or string. Got: %s', is_object($key) ? get_class($key) : gettype($key) ), 0, $cause); }
Creates an exception for an invalid key. @param mixed $key The invalid key. @param Exception|null $cause The exception that caused this exception. @return static The created exception.
entailment
public function setQuery(\Illuminate\Database\Eloquent\Builder $query): GridInterface { $this->_query = $query; $this->_model = $this->_query->getModel(); $this->pagination->setQuery($this->_query); return $this; }
@param \Illuminate\Database\Eloquent\Builder $query @return GridInterface
entailment
public function column(string $name = null, string $title = null): Column { $column = new Column(); $this->columns->setColumn($column); if ($name) { $column->setKey($name); } if ($title) { $column->setValue($title); } return $column; ...
@param string $name @param string $title @return Column
entailment
public function columnActions(Callable $action, string $value = null): ColumnInterface { return $this->column(Column::ACTION_NAME, $value)->setActions($action); }
@param callable $action @param string|null $value @return ColumnInterface
entailment
public function render(array $data = [], string $path = 'gridView', array $mergeData = []): string { if (request()->ajax() || request()->wantsJson()) { $path = $path === 'gridView' ? 'part.grid' : $path; } return static::view($path, $data, $mergeData)->render(); }
@param array $data @param string $path @param array $mergeData @return string @throws \Throwable
entailment
public function renderFirst(array $data = [], string $path = 'gridView', array $mergeData = []): string { $path = $path === 'gridView' ? 'part.tableTrItem' : $path; $headers = $data['data']->headers; $item = (array)$data['data']->data; return static::view($path, [ 'head...
@param array $data @param string $path @param array $mergeData @return string @throws \Throwable
entailment
public static function view(string $view = null, array $data = [], array $mergeData = []): Renderable { return view(self::NAME . '::' . $view, $data, $mergeData); }
Get the evaluated view contents for the given view. @param string|null $view @param array $data @param array $mergeData @return Renderable
entailment
public static function trans(string $id = null, array $parameters = [], string $locale = null): string { return (string)trans(self::NAME . '::' . $id, $parameters, $locale); }
Translate the given message. @param string|null $id @param array $parameters @param string|null $locale @return string
entailment
public function get(): \Assurrussa\GridView\Helpers\GridViewResult { $gridViewResult = $this->_getGridView(); $gridViewResult->data = $this->pagination->get($this->page, $this->limit); $gridViewResult->pagination = $this->_getPaginationRender(); $gridViewResult->simple = false; ...
Return get result @return \Assurrussa\GridView\Helpers\GridViewResult @throws ColumnsException @throws QueryException
entailment
public function getSimple(bool $isCount = false): \Assurrussa\GridView\Helpers\GridViewResult { $gridViewResult = $this->_getGridView($isCount); $gridViewResult->data = $this->pagination->getSimple($this->page, $this->limit, $isCount); $gridViewResult->pagination = $this->_getPaginationRende...
@param bool $isCount @return Helpers\GridViewResult @throws ColumnsException @throws QueryException
entailment
private function _getGridView(bool $isCount = false): \Assurrussa\GridView\Helpers\GridViewResult { $this->_fetch(); $gridViewResult = new \Assurrussa\GridView\Helpers\GridViewResult(); $gridViewResult->id = $this->getId(); $gridViewResult->ajax = $this->ajax; $gridViewResul...
@param bool $isCount @return Helpers\GridViewResult @throws ColumnsException @throws QueryException
entailment
private function _getConfig(string $key, $default = null) { if (isset($this->_config[$key])) { return $this->_config[$key]; } return $default; }
@param string $key @param mixed|null $default @return mixed|null
entailment
private function _filterScopes(): \Illuminate\Support\Collection { if (count($this->_request) > 0) { foreach ($this->_request as $scope => $value) { if (!empty($value) || $value === 0 || $value === '0') { $value = (string)$value; //checked ...
Very simple filtration scopes.<br><br> Example: * method - `public function scopeCatalogId($int) {}` @return \Illuminate\Support\Collection
entailment
private function _filterSearch( string $search = null, string $value = null, string $operator = '=', string $beforeValue = '', string $afterValue = '' ): void { if ($search) { if ($value) { $value = trim($value); } $...
The method filters the data according @param string|int|null $search @param mixed|null $value word @param string $operator equal sign - '=', 'like' ... @param string $beforeValue First sign before value @param string $afterValue Last sign after value
entailment
private function _hasFilterExecuteForCyrillicColumn(string $search, string $column): bool { if (!preg_match("/[\w]+/i", $search) && \Assurrussa\GridView\Enums\FilterEnum::hasFilterExecuteForCyrillicColumn($column)) { return true; } return false; }
Because of problems with the search Cyrillic, crutch.<br><br> Из-за проблем поиска с кириллицей, костыль. @param string $search @param string $column @return bool
entailment
private function _prepareColumns(): void { if (method_exists($this->_model, 'toFieldsAmiGrid')) { $lists = $this->_model->toFieldsAmiGrid(); } else { $lists = \Schema::getColumnListing($this->_model->getTable()); } if ($this->isVisibleColumn()) { $...
The method takes the default column for any model<br><br> Метод получает колонки по умолчанию для любой модели
entailment
public static function serialize($value) { if (is_resource($value)) { throw SerializationFailedException::forValue($value); } try { $serialized = serialize($value); } catch (Exception $e) { throw SerializationFailedException::forValue($value, $e->...
Serializes a value. @param mixed $value The value to serialize. @return string The serialized value. @throws SerializationFailedException If the value cannot be serialized.
entailment
public static function unserialize($serialized) { if (!is_string($serialized)) { throw UnserializationFailedException::forValue($serialized); } $errorMessage = null; $errorCode = 0; set_error_handler(function ($errno, $errstr) use (&$errorMessage, &$errorCode) {...
Unserializes a value. @param mixed $serialized The serialized value. @return string The unserialized value. @throws UnserializationFailedException If the value cannot be unserialized.
entailment
public function key() { if (null === $this->singular || '' === $this->singular) { return false; } // Prepend context and EOT, like in MO files $key = !$this->context ? $this->singular : $this->context . chr(4) . $this->singular; // Standardize on \n line endings ...
Generates a unique key for this entry. @return string|bool the key or false if the entry is empty
entailment
public function export_headers() { $header_string = ''; foreach ($this->headers as $header => $value) { $header_string .= "$header: $value\n"; } $poified = self::poify($header_string); if ($this->comments_before_headers) { $before_headers = self::prepe...
Exports headers to a PO entry. @return string msgid/msgstr PO entry for this PO file headers, doesn't contain newline at the end
entailment
public function export($include_headers = true) { $res = ''; if ($include_headers) { $res .= $this->export_headers(); $res .= "\n\n"; } $res .= $this->export_entries(); return $res; }
Exports the whole PO file as a string. @param bool $include_headers whether to include the headers in the export @return string ready for inclusion in PO file string for headers and all the enrtries
entailment
public function export_to_file($filename, $include_headers = true) { $fh = fopen($filename, 'w'); if (false === $fh) { return false; } $export = $this->export($include_headers); $res = fwrite($fh, $export); if (false === $res) { return false; ...
Same as {@link export}, but writes the result to a file. @param string $filename where to write the PO string @param bool $include_headers whether to include tje headers in the export @return bool true on success, false on error
entailment
public static function poify($string) { $quote = '"'; $slash = '\\'; $newline = "\n"; $replaces = array( "$slash" => "$slash$slash", "$quote" => "$slash$quote", "\t" => '\t', ); $string = str_replace( arra...
Formats a string in PO-style. @param string $string the string to format @return string the poified string
entailment
public static function unpoify($string) { $escapes = array('t' => "\t", 'n' => "\n", 'r' => "\r", '\\' => '\\'); $lines = array_map('trim', explode("\n", $string)); $lines = array_map(array(__NAMESPACE__ . '\PO', 'trim_quotes'), $lines); $unpoified = ''; $previous_is_backslas...
Gives back the original string from a PO-formatted string. @param string $string PO-formatted string @return string enascaped string
entailment
public static function prepend_each_line($string, $with) { $lines = explode("\n", $string); $append = ''; if ("\n" === substr($string, -1) && '' === end($lines)) { // Last line might be empty because $string was terminated // with a newline, remove it from the $lines ...
Inserts $with in the beginning of every new line of $string and returns the modified string. @param string $string prepend lines in this string @param string $with prepend lines with this string @return string The modified string
entailment