_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q23100
jsModal.setOption
train
public function setOption($options, $value = null) { if (is_array($options)) { foreach ($options as $key => $value) { $this->args['arg'][$key] = $value; } } else { $this->args['arg'][$options] = $value; } return $this; }
php
{ "resource": "" }
q23101
ItemShelf.linkCart
train
public function linkCart(Cart $cart, $jsAction = null) { $this->on('click', '.item', function ($a, $b) use ($cart, $jsAction) { $cart->addItem($b); return $jsAction; }, [(new \atk4\ui\jQuery())->text()]); }
php
{ "resource": "" }
q23102
SSE.init
train
public function init() { if ($this->runEvent) { $chain = new jsChain(); $this->app->html->js(true, $chain->atkServerEvent( ['uri' => $this->getUrl()] )); $this->isRunning = true; } $this->_initialized = true; }
php
{ "resource": "" }
q23103
UserController.actionRequestPasswordReset
train
public function actionRequestPasswordReset() { $model = new PasswordResetRequest(); if ($model->load(Yii::$app->getRequest()->post()) && $model->validate()) { if ($model->sendEmail()) { Yii::$app->getSession()->setFlash('success', 'Check your email for further instruction...
php
{ "resource": "" }
q23104
Route.getRoutePrefix
train
public function getRoutePrefix() { if (!$this->_routePrefix) { $this->_routePrefix = Configs::instance()->advanced ? self::PREFIX_ADVANCED : self::PREFIX_BASIC; } return $this->_routePrefix; }
php
{ "resource": "" }
q23105
Route.getPermissionName
train
public function getPermissionName($route) { if (self::PREFIX_BASIC == $this->routePrefix) { return self::PREFIX_BASIC . trim($route, self::PREFIX_BASIC); } else { return self::PREFIX_ADVANCED . ltrim(trim($route, self::PREFIX_BASIC), self::PREFIX_ADVANCED); } }
php
{ "resource": "" }
q23106
Route.getControllerActions
train
protected function getControllerActions($type, $id, $module, &$result) { $token = "Create controller with cofig=" . VarDumper::dumpAsString($type) . " and id='$id'"; Yii::beginProfile($token, __METHOD__); try { /* @var $controller \yii\base\Controller */ $controller =...
php
{ "resource": "" }
q23107
Route.getActionRoutes
train
protected function getActionRoutes($controller, &$result) { $token = "Get actions of controller '" . $controller->uniqueId . "'"; Yii::beginProfile($token, __METHOD__); try { $prefix = '/' . $controller->uniqueId . '/'; foreach ($controller->actions() as $id => $value...
php
{ "resource": "" }
q23108
Module.getMenus
train
public function getMenus() { if ($this->_normalizeMenus === null) { $mid = '/' . $this->getUniqueId() . '/'; // resolve core menus $this->_normalizeMenus = []; $config = components\Configs::instance(); $conditions = [ 'user' => $co...
php
{ "resource": "" }
q23109
Module.setMenus
train
public function setMenus($menus) { $this->_menus = array_merge($this->_menus, $menus); $this->_normalizeMenus = null; }
php
{ "resource": "" }
q23110
Assignment.assign
train
public function assign($items) { $manager = Configs::authManager(); $success = 0; foreach ($items as $name) { try { $item = $manager->getRole($name); $item = $item ?: $manager->getPermission($name); $manager->assign($item, $this->id...
php
{ "resource": "" }
q23111
MenuHelper.requiredParent
train
private static function requiredParent($assigned, &$menus) { $l = count($assigned); for ($i = 0; $i < $l; $i++) { $id = $assigned[$i]; $parent_id = $menus[$id]['parent']; if ($parent_id !== null && !in_array($parent_id, $assigned)) { $assigned[$l++...
php
{ "resource": "" }
q23112
Helper.filter
train
public static function filter($items, $user = null) { if ($user === null) { $user = Yii::$app->getUser(); } return static::filterRecursive($items, $user); }
php
{ "resource": "" }
q23113
AuthItem.getTypeName
train
public static function getTypeName($type = null) { $result = [ Item::TYPE_PERMISSION => 'Permission', Item::TYPE_ROLE => 'Role', ]; if ($type === null) { return $result; } return $result[$type]; }
php
{ "resource": "" }
q23114
Assignment.search
train
public function search($params, $class, $usernameField) { $query = $class::find(); $dataProvider = new ActiveDataProvider([ 'query' => $query, ]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWh...
php
{ "resource": "" }
q23115
HandleFormFields.fields
train
function fields(): array { $this->checkFormIsBuilt(); return collect($this->fields)->map(function($field) { return $field->toArray(); })->keyBy("key")->all(); }
php
{ "resource": "" }
q23116
HandleFormFields.findFieldByKey
train
function findFieldByKey(string $key) { $this->checkFormIsBuilt(); $fields = collect($this->fields); if(strpos($key, ".") !== false) { list($key, $itemKey) = explode(".", $key); $listField = $fields->where("key", $key)->first(); return $listField->findIt...
php
{ "resource": "" }
q23117
WithSharpFormEloquentUpdater.getFormListFieldsConfiguration
train
protected function getFormListFieldsConfiguration() { return collect($this->fields) ->filter(function($field) { return $field instanceof SharpFormListField && $field->isSortable(); })->map(function($listField) { return [ ...
php
{ "resource": "" }
q23118
EntityListController.update
train
public function update($entityKey) { sharp_check_ability("update", $entityKey); $list = $this->getListInstance($entityKey); $list->buildListConfig(); $list->reorderHandler()->reorder( request("instances") ); return response()->json([ "ok" =>...
php
{ "resource": "" }
q23119
ModelWizardCommand.parseClassname
train
protected function parseClassname($class, $additionalNamespace = null) { if (preg_match('([^A-Za-z0-9_/\\\\])', $class)) { throw new InvalidArgumentException('Class name contains invalid characters.'); } $class = trim(str_replace('/', '\\', $class), '\\'); if (! Str::st...
php
{ "resource": "" }
q23120
AssetViewComposer.compose
train
public function compose(View $view) { $strategy = $this->getValidatedStrategyFromConfig(); $output = []; foreach((array)config("sharp.extensions.assets") as $position => $paths) { foreach((array)$paths as $assetPath) { if(!isset($output[$position])) { ...
php
{ "resource": "" }
q23121
AssetViewComposer.getValidatedStrategyFromConfig
train
protected function getValidatedStrategyFromConfig():string { $strategy = config('sharp.extensions.assets.strategy', 'raw'); if(!is_string($strategy)) { throw new SharpInvalidAssetRenderStrategy('The asset strategy defined at sharp.extensions.assets.strategy is not a string'); } ...
php
{ "resource": "" }
q23122
SharpWidget.validate
train
protected function validate(array $properties) { $validator = Validator::make($properties, [ 'key' => 'required', 'type' => 'required', ] + $this->validationRules()); if ($validator->fails()) { throw new SharpWidgetValidationException($validat...
php
{ "resource": "" }
q23123
SharpForm.formLayout
train
function formLayout(): array { if(!$this->layoutBuilt) { $this->buildFormLayout(); $this->layoutBuilt = true; } return [ "tabbed" => $this->tabbed, "tabs" => collect($this->tabs)->map(function($tab) { return $tab->toArray(); ...
php
{ "resource": "" }
q23124
SharpForm.instance
train
function instance($id): array { return collect($this->find($id)) // Filter model attributes on actual form fields ->only($this->getDataKeys()) ->all(); }
php
{ "resource": "" }
q23125
SharpForm.newInstance
train
public function newInstance() { $data = collect($this->create()) // Filter model attributes on actual form fields ->only($this->getDataKeys()) ->all(); return sizeof($data) ? $data : null; }
php
{ "resource": "" }
q23126
SharpForm.create
train
public function create(): array { $attributes = collect($this->getDataKeys()) ->flip() ->map(function() { return null; })->all(); // Build a fake Model class based on attributes return $this->transform(new class($attributes) extends \stdCl...
php
{ "resource": "" }
q23127
SharpEntityList.dataContainers
train
function dataContainers(): array { $this->checkListIsBuilt(); return collect($this->containers)->map(function(EntityListDataContainer $container) { return $container->toArray(); })->keyBy("key")->all(); }
php
{ "resource": "" }
q23128
SharpEntityList.listLayout
train
function listLayout(): array { if(!$this->layoutBuilt) { $this->buildListLayout(); $this->layoutBuilt = true; } return collect($this->columns)->map(function(EntityListLayoutColumn $column) { return $column->toArray(); })->all(); }
php
{ "resource": "" }
q23129
SharpEntityList.listConfig
train
function listConfig(): array { $config = [ "instanceIdAttribute" => $this->instanceIdAttribute, "multiformAttribute" => $this->multiformAttribute, "displayMode" => $this->displayMode, "searchable" => $this->searchable, "paginated" => $this->paginat...
php
{ "resource": "" }
q23130
SharpEntityList.addDataContainer
train
protected function addDataContainer(EntityListDataContainer $container) { $this->containers[] = $container; $this->listBuilt = false; return $this; }
php
{ "resource": "" }
q23131
WithCustomTransformers.transform
train
function transform($models) { if($this instanceof SharpForm || $this instanceof Command) { // It's a Form (full entity or from a Command), there's only one model. // We must add Form Field Formatters in the process return $this->applyFormatters( $this->app...
php
{ "resource": "" }
q23132
MenuViewComposer.compose
train
public function compose(View $view) { $menuItems = new Collection; foreach (config("sharp.menu", []) as $menuItemConfig) { if($menuItem = MenuItem::parse($menuItemConfig)) { $menuItems->push($menuItem); } } $view->with('sharpMenu', (object)[ ...
php
{ "resource": "" }
q23133
Command.validate
train
public function validate(array $params, array $rules, array $messages = []) { $validator = app(Validator::class)->make($params, $rules, $messages); if ($validator->fails()) { throw new ValidationException( $validator, new JsonResponse($validator->errors()->getMessages(),...
php
{ "resource": "" }
q23134
HandleCommands.appendCommandsToConfig
train
protected function appendCommandsToConfig(array &$config) { collect($this->entityCommandHandlers) ->merge(collect($this->instanceCommandHandlers)) ->each(function($handler, $commandName) use(&$config) { $formFields = $handler->form(); $formLayout = $fo...
php
{ "resource": "" }
q23135
SharpDashboard.addWidget
train
protected function addWidget(SharpWidget $widget) { $this->widgets[] = $widget; $this->dashboardBuilt = false; return $this; }
php
{ "resource": "" }
q23136
SharpDashboard.addFullWidthWidget
train
protected function addFullWidthWidget(string $widgetKey) { $this->layoutBuilt = false; $this->addRow(function(DashboardLayoutRow $row) use ($widgetKey) { $row->addWidget(12, $widgetKey); }); return $this; }
php
{ "resource": "" }
q23137
SharpDashboard.addRow
train
protected function addRow(\Closure $callback) { $row = new DashboardLayoutRow(); $callback($row); $this->rows[] = $row; return $this; }
php
{ "resource": "" }
q23138
SharpDashboard.widgetsLayout
train
function widgetsLayout(): array { if(!$this->layoutBuilt) { $this->buildWidgetsLayout(); $this->layoutBuilt = true; } return [ "rows" => collect($this->rows)->map(function(DashboardLayoutRow $row) { return $row->toArray(); })->...
php
{ "resource": "" }
q23139
Client.process_response
train
protected function process_response($response_json) { $response = json_decode($response_json); $this->catch_json_last_error(); $this->last_results_raw = $response; if (isset($response->meta->rc)) { if ($response->meta->rc === 'ok') { $this->last_error_mess...
php
{ "resource": "" }
q23140
Client.check_base_url
train
private function check_base_url() { $url_valid = filter_var($this->baseurl, FILTER_VALIDATE_URL); if (!$url_valid) { trigger_error('The URL provided is incomplete or invalid!'); return false; } $base_url_components = parse_url($this->baseurl); if (em...
php
{ "resource": "" }
q23141
Client.get_curl_obj
train
protected function get_curl_obj() { $ch = curl_init(); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $this->curl_ssl_verify_peer); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, $this->curl_ssl_verify_host); curl_setopt($ch, CURLOPT_RETURNTRANSFER, ...
php
{ "resource": "" }
q23142
RollbackMultiAuthCommand.parseName
train
protected function parseName($name = null) { if (!$name) { $name = $this->name; } return [ '{{pluralCamel}}' => str_plural(camel_case($name)), '{{pluralSlug}}' => str_plural(str_slug($name)), '{{pluralSnake}}' => str_plural(snake_case($...
php
{ "resource": "" }
q23143
FileSystemOptions.setCacheDir
train
public function setCacheDir($cacheDir) { if ($cacheDir !== null) { if (!is_dir($cacheDir)) { throw new Exception\InvalidArgumentException( "Cache directory '{$cacheDir}' not found or not a directory" ); } elseif (!is_writable($cache...
php
{ "resource": "" }
q23144
FileSystemOptions.setDirLevel
train
public function setDirLevel($dirLevel) { $dirLevel = (int)$dirLevel; if ($dirLevel < 0 || $dirLevel > 16) { throw new Exception\InvalidArgumentException( "Directory level '{$dirLevel}' must be between 0 and 16" ); } $this->dirLevel = $dirLevel;...
php
{ "resource": "" }
q23145
FileSystemOptions.setDirPermission
train
public function setDirPermission($dirPermission) { if ($dirPermission !== false) { if (is_string($dirPermission)) { $dirPermission = octdec($dirPermission); } else { $dirPermission = (int)$dirPermission; } // validate ...
php
{ "resource": "" }
q23146
FileSystemOptions.setFilePermission
train
public function setFilePermission($filePermission) { if ($filePermission !== false) { if (is_string($filePermission)) { $filePermission = octdec($filePermission); } else { $filePermission = (int)$filePermission; } // validate ...
php
{ "resource": "" }
q23147
FileSystemOptions.setUmask
train
public function setUmask($umask) { if ($umask !== false) { if (is_string($umask)) { $umask = octdec($umask); } else { $umask = (int)$umask; } // validate if ($umask & 0700) { throw new Exception\Inva...
php
{ "resource": "" }
q23148
AdapterOptions.setKeyPattern
train
public function setKeyPattern($keyPattern) { $keyPattern = (string)$keyPattern; if ($this->keyPattern !== $keyPattern) { // validate pattern if ($keyPattern !== '') { ErrorHandler::start(E_WARNING); $result = preg_match($keyPattern, ''); ...
php
{ "resource": "" }
q23149
AdapterOptions.normalizeTtl
train
protected function normalizeTtl(&$ttl) { if (!is_int($ttl)) { $ttl = (float)$ttl; // convert to int if possible if ($ttl === (float)(int)$ttl) { $ttl = (int)$ttl; } } if ($ttl < 0) { throw new InvalidArgumentExcept...
php
{ "resource": "" }
q23150
ErrorHandler.stop
train
public static function stop($throw = false) { $errorException = null; if (static::$stack) { $errorException = array_pop(static::$stack); if (!static::$stack) { restore_error_handler(); } if ($errorException && $throw) { ...
php
{ "resource": "" }
q23151
ErrorHandler.addError
train
public static function addError($errno, $errstr = '', $errfile = '', $errline = 0) { $stack = & static::$stack[count(static::$stack) - 1]; $stack = new ErrorException($errstr, 0, $errno, $errfile, $errline, $stack); }
php
{ "resource": "" }
q23152
AbstractAdapter.normalizeKey
train
protected function normalizeKey(&$key) { $key = (string)$key; if ($key === '') { throw new InvalidArgumentException("An empty key isn't allowed"); } elseif (($p = $this->getOptions()->getKeyPattern()) && !preg_match($p, $key)) { throw new InvalidArgumentException( ...
php
{ "resource": "" }
q23153
Semacode.makeEncoding
train
function makeEncoding($height = 0, $width = 0, $data = 0, $fw = 0, $bytes = 0, $datablocks = 0, $rsblocks = 0) { $t = array( 'height' => $height, 'width' => $width, 'data' => $data, 'fw' => $fw, 'bytes' => $bytes, 'datablocks' => $datablock...
php
{ "resource": "" }
q23154
Semacode.placeBit
train
function placeBit(&$array, $NR, $NC, $r, $c, $p, $b) { if ($r < 0) { $r += $NR; $c += 4 - (($NR + 4) % 8); } if ($c < 0) { $c += $NC; $r += 4 - (($NC + 4) % 8); } $array[$r * $NC + $c] = ($p << 3) + $b; }
php
{ "resource": "" }
q23155
Semacode.rs
train
function rs(&$binary, $bytes, $datablock, $rsblock) { $blocks = floor(($bytes + 2) / $datablock); $rs = new ReedSolomon($rsblock); for ($b = 0; $b < $blocks; $b++) { $buf = array(); $p = 0; for ($n = $b; $n < $bytes; $n += $blocks) array_push(...
php
{ "resource": "" }
q23156
Semacode.asGDImage
train
function asGDImage($text,$resize=160){ $barcode = $this->encode($text); $w = $barcode['width']; $h = $barcode['height']; $bs = 10; $size = $bs * $w; $img = imagecreatetruecolor($size + 2 * $bs * 2 ,$size + 2 * $bs * 2); $white = imagecolorallocate($img,255,2...
php
{ "resource": "" }
q23157
FileSystem.internalHasItem
train
protected function internalHasItem(& $normalizedKey) { $file = $this->getFileSpec($normalizedKey) . '.dat'; if (!file_exists($file)) { return false; } $ttl = $this->getOptions()->getTtl(); if ($ttl) { ErrorHandler::start(); $mtime = filemt...
php
{ "resource": "" }
q23158
FileSystem.getFileSpec
train
protected function getFileSpec($normalizedKey) { $options = $this->getOptions(); $namespace = $options->getNamespace(); $prefix = ($namespace === '') ? '' : $namespace . $options->getNamespaceSeparator(); $path = $options->getCacheDir() . DIRECTORY_SEPARATOR; $level...
php
{ "resource": "" }
q23159
FileSystem.getFileContent
train
protected function getFileContent($file, $nonBlocking = false, & $wouldblock = null) { $locking = $this->getOptions()->getFileLocking(); $wouldblock = null; ErrorHandler::start(); // if file locking enabled -> file_get_contents can't be used if ($locking) { $...
php
{ "resource": "" }
q23160
Tag.index
train
public function index(string $domain, int $limit = 100) { Assert::stringNotEmpty($domain); Assert::range($limit, 1, 1000); $params = [ 'limit' => $limit, ]; $response = $this->httpGet(sprintf('/v3/%s/tags', $domain), $params); return $this->hydrateRespo...
php
{ "resource": "" }
q23161
Tag.update
train
public function update(string $domain, string $tag, string $description) { Assert::stringNotEmpty($domain); Assert::stringNotEmpty($tag); $params = [ 'description' => $description, ]; $response = $this->httpPut(sprintf('/v3/%s/tags/%s', $domain, $tag), $params);...
php
{ "resource": "" }
q23162
Tag.stats
train
public function stats(string $domain, string $tag, array $params) { Assert::stringNotEmpty($domain); Assert::stringNotEmpty($tag); $response = $this->httpGet(sprintf('/v3/%s/tags/%s/stats', $domain, $tag), $params); return $this->hydrateResponse($response, StatisticsResponse::class...
php
{ "resource": "" }
q23163
Message.show
train
public function show(string $url, bool $rawMessage = false) { Assert::notEmpty($url); $headers = []; if ($rawMessage) { $headers['Accept'] = 'message/rfc2822'; } $response = $this->httpGet($url, [], $headers); return $this->hydrateResponse($response, Sh...
php
{ "resource": "" }
q23164
Message.prepareMultipartParameters
train
private function prepareMultipartParameters(array $params): array { $postDataMultipart = []; foreach ($params as $key => $value) { // If $value is not an array we cast it to an array foreach ((array) $value as $subValue) { $postDataMultipart[] = [ ...
php
{ "resource": "" }
q23165
Message.closeResources
train
private function closeResources(array $params): void { foreach ($params as $param) { if (is_array($param) && array_key_exists('content', $param) && is_resource($param['content'])) { fclose($param['content']); } } }
php
{ "resource": "" }
q23166
Ip.index
train
public function index(bool $dedicated = false) { Assert::boolean($dedicated); $params = [ 'dedicated' => $dedicated, ]; $response = $this->httpGet('/v3/ips', $params); return $this->hydrateResponse($response, IndexResponse::class); }
php
{ "resource": "" }
q23167
Ip.domainIndex
train
public function domainIndex(string $domain) { Assert::stringNotEmpty($domain); $response = $this->httpGet(sprintf('/v3/domains/%s/ip', $domain)); return $this->hydrateResponse($response, IndexResponse::class); }
php
{ "resource": "" }
q23168
Ip.show
train
public function show(string $ip) { Assert::ip($ip); $response = $this->httpGet(sprintf('/v3/ips/%s', $ip)); return $this->hydrateResponse($response, ShowResponse::class); }
php
{ "resource": "" }
q23169
Ip.assign
train
public function assign(string $domain, string $ip) { Assert::stringNotEmpty($domain); Assert::ip($ip); $params = [ 'id' => $ip, ]; $response = $this->httpPost(sprintf('/v3/domains/%s/ips', $domain), $params); return $this->hydrateResponse($response, Upd...
php
{ "resource": "" }
q23170
Ip.unassign
train
public function unassign(string $domain, string $ip) { Assert::stringNotEmpty($domain); Assert::ip($ip); $response = $this->httpDelete(sprintf('/v3/domains/%s/ips/%s', $domain, $ip)); return $this->hydrateResponse($response, UpdateResponse::class); }
php
{ "resource": "" }
q23171
MailingList.pages
train
public function pages(int $limit = 100) { Assert::range($limit, 1, 1000); $params = [ 'limit' => $limit, ]; $response = $this->httpGet('/v3/lists/pages', $params); return $this->hydrateResponse($response, PagesResponse::class); }
php
{ "resource": "" }
q23172
MailingList.create
train
public function create(string $address, string $name = null, string $description = null, string $accessLevel = 'readonly') { Assert::stringNotEmpty($address); Assert::nullOrStringNotEmpty($name); Assert::nullOrStringNotEmpty($description); Assert::oneOf($accessLevel, ['readonly', 'me...
php
{ "resource": "" }
q23173
MailingList.update
train
public function update(string $address, array $parameters = []) { Assert::stringNotEmpty($address); Assert::isArray($parameters); foreach ($parameters as $field => $value) { switch ($field) { case 'address': case 'name': case 'desc...
php
{ "resource": "" }
q23174
EmailValidation.validate
train
public function validate(string $address, bool $mailboxVerification = false) { Assert::stringNotEmpty($address); $params = [ 'address' => $address, 'mailbox_verification' => $mailboxVerification, ]; $response = $this->httpGet('/address/private/validate', $pa...
php
{ "resource": "" }
q23175
Domain.index
train
public function index(int $limit = 100, int $skip = 0) { Assert::range($limit, 1, 1000); $params = [ 'limit' => $limit, 'skip' => $skip, ]; $response = $this->httpGet('/v3/domains', $params); return $this->hydrateResponse($response, IndexResponse::c...
php
{ "resource": "" }
q23176
Domain.credentials
train
public function credentials(string $domain, int $limit = 100, int $skip = 0) { Assert::stringNotEmpty($domain); $params = [ 'limit' => $limit, 'skip' => $skip, ]; $response = $this->httpGet(sprintf('/v3/domains/%s/credentials', $domain), $params); re...
php
{ "resource": "" }
q23177
Domain.createCredential
train
public function createCredential(string $domain, string $login, string $password) { Assert::stringNotEmpty($domain); Assert::stringNotEmpty($login); Assert::stringNotEmpty($password); Assert::lengthBetween($password, 5, 32, 'SMTP password must be between 5 and 32 characters.'); ...
php
{ "resource": "" }
q23178
Domain.updateCredential
train
public function updateCredential(string $domain, string $login, string $pass) { Assert::stringNotEmpty($domain); Assert::stringNotEmpty($login); Assert::stringNotEmpty($pass); Assert::lengthBetween($pass, 5, 32, 'SMTP password must be between 5 and 32 characters.'); $params ...
php
{ "resource": "" }
q23179
Domain.deleteCredential
train
public function deleteCredential(string $domain, string $login) { Assert::stringNotEmpty($domain); Assert::stringNotEmpty($login); $response = $this->httpDelete( sprintf( '/v3/domains/%s/credentials/%s', $domain, $login ...
php
{ "resource": "" }
q23180
Domain.connection
train
public function connection(string $domain) { Assert::stringNotEmpty($domain); $response = $this->httpGet(sprintf('/v3/domains/%s/connection', $domain)); return $this->hydrateResponse($response, ConnectionResponse::class); }
php
{ "resource": "" }
q23181
Domain.updateConnection
train
public function updateConnection(string $domain, ?bool $requireTLS, ?bool $noVerify) { Assert::stringNotEmpty($domain); $params = []; if (null !== $requireTLS) { $params['require_tls'] = $requireTLS ? 'true' : 'false'; } if (null !== $noVerify) { $pa...
php
{ "resource": "" }
q23182
Domain.verify
train
public function verify(string $domain) { Assert::stringNotEmpty($domain); $response = $this->httpPut(sprintf('/v3/domains/%s/verify', $domain)); return $this->hydrateResponse($response, VerifyResponse::class); }
php
{ "resource": "" }
q23183
Member.index
train
public function index(string $address, int $limit = 100, bool $subscribed = null) { Assert::stringNotEmpty($address); Assert::greaterThan($limit, 0); $params = [ 'limit' => $limit, ]; if (true === $subscribed) { $params['subscribed'] = 'yes'; ...
php
{ "resource": "" }
q23184
Route.show
train
public function show(string $routeId) { Assert::stringNotEmpty($routeId); $response = $this->httpGet(sprintf('/v3/routes/%s', $routeId)); return $this->hydrateResponse($response, ShowResponse::class); }
php
{ "resource": "" }
q23185
Route.create
train
public function create(string $expression, array $actions, string $description, int $priority = 0) { Assert::isArray($actions); $params = [ 'priority' => (string) $priority, 'expression' => $expression, 'action' => $actions, 'description' => $descript...
php
{ "resource": "" }
q23186
Route.update
train
public function update( string $routeId, string $expression = null, array $actions = [], string $description = null, int $priority = null ) { Assert::stringNotEmpty($routeId); $params = []; if (!empty($expression)) { $params['expression'] ...
php
{ "resource": "" }
q23187
Route.delete
train
public function delete(string $routeId) { Assert::stringNotEmpty($routeId); $response = $this->httpDelete(sprintf('/v3/routes/%s', $routeId)); return $this->hydrateResponse($response, DeleteResponse::class); }
php
{ "resource": "" }
q23188
Webhook.verifyWebhookSignature
train
public function verifyWebhookSignature(int $timestamp, string $token, string $signature): bool { if (empty($timestamp) || empty($token) || empty($signature)) { return false; } $hmac = hash_hmac('sha256', $timestamp.$token, $this->apiKey); if (function_exists('hash_equal...
php
{ "resource": "" }
q23189
Action.createMultiple
train
public static function createMultiple(array $data) { $items = []; foreach ($data as $action) { $items[] = new self($action); } return $items; }
php
{ "resource": "" }
q23190
HttpApi.handleErrors
train
protected function handleErrors(ResponseInterface $response) { $statusCode = $response->getStatusCode(); switch ($statusCode) { case 400: throw HttpClientException::badRequest($response); case 401: throw HttpClientException::unauthorized($respo...
php
{ "resource": "" }
q23191
HttpApi.httpPost
train
protected function httpPost(string $path, array $parameters = [], array $requestHeaders = []): ResponseInterface { return $this->httpPostRaw($path, $this->createRequestBody($parameters), $requestHeaders); }
php
{ "resource": "" }
q23192
HttpApi.httpPut
train
protected function httpPut(string $path, array $parameters = [], array $requestHeaders = []): ResponseInterface { try { $response = $this->httpClient->sendRequest( $this->requestBuilder->create('PUT', $path, $requestHeaders, $this->createRequestBody($parameters)) ); ...
php
{ "resource": "" }
q23193
ThemeRouteCollection.getThemeByRoute
train
public function getThemeByRoute($path) { $text = new Text(); // there's probably a more efficient way to do this foreach ($this->themePaths as $lp => $layout) { if ($text->fnmatch($lp, $path)) { return $layout; } } return false; }
php
{ "resource": "" }
q23194
BitmapFormat.getAllImageFormats
train
public function getAllImageFormats() { if ($this->allImageFormats === null) { $this->allImageFormats = [ static::FORMAT_PNG, static::FORMAT_JPEG, static::FORMAT_GIF, static::FORMAT_WBMP, static::FORMAT_XBM, ...
php
{ "resource": "" }
q23195
BitmapFormat.getFormatMimeType
train
public function getFormatMimeType($format) { $format = $this->normalizeFormat($format); $result = ''; switch ($format) { case static::FORMAT_PNG: case static::FORMAT_JPEG: case static::FORMAT_GIF: case static::FORMAT_XBM: $resul...
php
{ "resource": "" }
q23196
BitmapFormat.getFormatFromMimeType
train
public function getFormatFromMimeType($mimeType, $fallback = '') { $mimeType = trim(strtolower((string) $mimeType)); switch ($mimeType) { case 'image/png': $result = static::FORMAT_PNG; break; case 'image/jpeg': $result = static...
php
{ "resource": "" }
q23197
BitmapFormat.getFormatImagineSaveOptions
train
public function getFormatImagineSaveOptions($format) { $format = $this->normalizeFormat($format); $result = [ 'format' => $format, ]; switch ($format) { case static::FORMAT_PNG: $result['png_compression_level'] = $this->getDefaultPngCompression...
php
{ "resource": "" }
q23198
BitmapFormat.setDefaultJpegQuality
train
public function setDefaultJpegQuality($value) { if ($this->valn->integer($value, 0, 100)) { $value = (int) $value; $this->config->set('concrete.misc.default_jpeg_image_compression', $value); $this->config->save('concrete.misc.default_jpeg_image_compression', $value); ...
php
{ "resource": "" }
q23199
BitmapFormat.getDefaultJpegQuality
train
public function getDefaultJpegQuality() { $result = $this->config->get('concrete.misc.default_jpeg_image_compression'); if ($this->valn->integer($result, 0, 100)) { $result = (int) $result; } else { $result = static::DEFAULT_JPEG_QUALITY; } return $re...
php
{ "resource": "" }