_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q200
Term.getOneWhere
train
public static function getOneWhere($args = array()) { $args['number'] = 1; $result = static::getWhere($args); return (count($result)) ? current($result) : null; }
php
{ "resource": "" }
q201
Term.find
train
public static function find($term_id) { $instance = Post\Factory::create(get_called_class()); $instance->load($term_id); return $instance; }
php
{ "resource": "" }
q202
Loader.loadAll
train
public static function loadAll() { global $taxonomies_infos; // Classes $subclasses = self::getSubclasses(); foreach ($subclasses as $class) { $instance = new $class; $taxonomies_infos = array_merge( $taxonomies_infos, ...
php
{ "resource": "" }
q203
Loader.load
train
public static function load($class) { $instance = new $class; $post_type = $instance->getPostType(); // WordPress has a limit of 20 characters per if (strlen($post_type) > 20) { throw new \Exception('Post Type name exceeds maximum 20 characters: '.$post_type); } ...
php
{ "resource": "" }
q204
Loader.getSubclasses
train
public static function getSubclasses() { $subclasses = array(); foreach (get_declared_classes() as $class) { if (method_exists($class, 'isLoadable') && $class::isLoadable() === false) { continue; } if (is_subclass_of($class, 'Taco\Post')) { ...
php
{ "resource": "" }
q205
Haversine.calculate
train
public function calculate(N\LatLong $point1, N\LatLong $point2) { $celestialBody = $this->getCelestialBody(); $deltaLat = $point2->getLatitude()->get() - $point1->getLatitude()->get(); $deltaLong = $point2->getLongitude()->get() - $point1->getLongitude()->get(); $a = sin($deltaLat / 2) *...
php
{ "resource": "" }
q206
Participant.update
train
public function update($params = []) { $response = Guzzle::put("tournaments/{$this->tournament_slug}/participants/{$this->id}", $params); return $this->updateModel($response->participant); }
php
{ "resource": "" }
q207
Transformer.transform
train
public function transform($object) { if (($collection = $this->normalize($object)) instanceof Collection) { return $this->transformCollection($collection); } // If there are relations setup, transform it along with the object. if ($this->relatedCount) { retur...
php
{ "resource": "" }
q208
Transformer.normalize
train
protected function normalize($object) { // If its a paginator instance, create a collection with its items. if ($object instanceof Paginator) { return collect($object->items()); } elseif (is_array($object)) { // If its an array, package it in a collection. ...
php
{ "resource": "" }
q209
Transformer.transformWithRelated
train
public function transformWithRelated($item) { $transformedItem = $this->getTransformation($item); return $this->transformRelated($transformedItem, $item); }
php
{ "resource": "" }
q210
Transformer.with
train
public function with($relation) { $this->reset(); if (func_num_args() > 1) { return $this->with(func_get_args()); } if (is_array($relation)) { $this->related = array_merge($this->related, $relation); } else { $this->related[] = $relation;...
php
{ "resource": "" }
q211
Transformer.setTransformation
train
public function setTransformation($transformation) { if (is_callable($transformation)) { $this->transformationMethod = $transformation; return $this; } // replace just to avoid wrongly passing the name containing "Transformation". $methodName = str_replace('...
php
{ "resource": "" }
q212
Transformer.transformRelated
train
protected function transformRelated($itemTransformation, $item) { foreach ($this->related as $relation) { // get direct relation name. $relationName = explode('.', $relation, 2)[0]; $itemTransformation[$relationName] = $this->getRelatedTransformation($item, $relation); ...
php
{ "resource": "" }
q213
Transformer.getRelatedTransformation
train
protected function getRelatedTransformation($item, $relation) { // get nested relations separated by the dot notation. // we only get one relation at a time because recursion handles the remaining relations. $nestedRelations = explode('.', $relation, 2); $relation = $nestedRelations[...
php
{ "resource": "" }
q214
GreatCircle.calculate
train
public function calculate(N\LatLong $point1, N\LatLong $point2) { $celestialBody = $this->getCelestialBody(); $degrees = acos(sin($point1->getLatitude()->get()) * sin($point2->getLatitude()->get()) + cos($point1->getLatitude()->get()) * cos($point2->getLatitude()->get...
php
{ "resource": "" }
q215
Gravatar.image
train
public static function image($sEmail, $iSize = null, $sDefaultImage = null, $sRating = null, $sExtension = null, $bForceDefault = false) { $gravatarImage = (new Image()) ->setEmail($sEmail) ->setSize($iSize) ->setDefaultImage($sDefaultImage, $bForceDefault) ->...
php
{ "resource": "" }
q216
Gravatar.images
train
public static function images(array $aEmail, $iSize = null, $sDefaultImage = null, $sRating = null, $sExtension = null, $bForceDefault = false) { $aImages = []; foreach ($aEmail as $sEmail) { $gravatarImage = (new Image()) ->setEmail($sEmail) ->setSize($i...
php
{ "resource": "" }
q217
Gravatar.profiles
train
public static function profiles(array $aEmail, $sFormat = null) { $aProfils = []; foreach ($aEmail as $sEmail) { $gravatarProfil = (new Profile()) ->setEmail($sEmail) ->setFormat($sFormat); $aProfils[$sEmail] = $gravatarProfil; } ...
php
{ "resource": "" }
q218
Gravatar.email
train
public function email($sEmail = null) { if (null === $sEmail) { return $this->getEmail(); } return $this->setEmail($sEmail); }
php
{ "resource": "" }
q219
Factory.create
train
public static function create($post, $load_terms = true) { // Ex: Taco\Post\Factory::create('Video') if (is_string($post) && class_exists($post)) { return new $post; } $original_post = $post; if (!is_object($post)) { $post = get_post($post); }...
php
{ "resource": "" }
q220
Factory.createMultiple
train
public static function createMultiple($posts, $load_terms = true) { if (!Arr::iterable($posts)) { return $posts; } $out = array(); foreach ($posts as $k => $post) { if (!get_post_status($post)) { continue; } $re...
php
{ "resource": "" }
q221
Dm_Image.draw
train
public function draw(Dm_Image $image,$x=0,$y=0,$width=null,$height=null) { $srcImageResource = $image->getImageResource(); if (is_null($width)) $width = $image->getWidth(); if (is_null($height)) $height = $image->getHeight(); return imagecopy( $this->getImageResource(), $srcImageResource, $x, $y, ...
php
{ "resource": "" }
q222
Dm_Image.saveTo
train
public function saveTo($path , $type='png', $quality=null) { if (!$path) return false; return $this->outputTo($path, $type, $quality); }
php
{ "resource": "" }
q223
Dm_Image.destroy
train
public function destroy() { imagedestroy($this->_imageResource); $this->graphics->destroy(); $this->graphics = null; $this->textGraphics->destroy(); $this->textGraphics = null; }
php
{ "resource": "" }
q224
Dm_Image.toDataSchemeURI
train
public function toDataSchemeURI() { $md5 = md5(microtime(1).rand(10000, 99999)); $filePath = $this->tempDirPath() . DIRECTORY_SEPARATOR . "temp".$md5.".png"; $this->saveTo($filePath); $uri = 'data:' . mime_content_type($filePath) . ';base64,'; $uri .= base64_encode(file_get_contents($filePath)); unli...
php
{ "resource": "" }
q225
Server.serve
train
public function serve($salt = '') { $protocol = isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0'; if ($input = $this->findInput()) { $output = $this->cacheName($salt . $input); $etag = $noneMatch = trim($this->getIfNoneMat...
php
{ "resource": "" }
q226
Base.getPrefixGroupedMetaBoxes
train
public function getPrefixGroupedMetaBoxes() { $fields = $this->getFields(); // Just group by the field key prefix // Ex: home_foo would go in the Home section by default $groups = array(); foreach ($fields as $k => $field) { $prefix = current(explode('_', $k)); ...
php
{ "resource": "" }
q227
Base.replaceMetaBoxGroupMatches
train
public function replaceMetaBoxGroupMatches($meta_boxes) { if (!Arr::iterable($meta_boxes)) { return $meta_boxes; } foreach ($meta_boxes as $k => $group) { $group = (is_array($group)) ? $group : array($group); if (array_key_exists('fields', $group)) { ...
php
{ "resource": "" }
q228
Base.getMetaBoxConfig
train
public function getMetaBoxConfig($config, $key = null) { // allow shorthand if (!array_key_exists('fields', $config)) { $fields = array(); foreach ($config as $field) { // Arbitrary HTML is allowed if (preg_match('/^\</', $field) && preg_match(...
php
{ "resource": "" }
q229
Base.assign
train
public function assign($vals) { if (count($vals) === 0) { return 0; } $n = 0; foreach ($vals as $k => $v) { if ($this->set($k, $v)) { $n++; } } return $n; }
php
{ "resource": "" }
q230
Base.isValid
train
public function isValid($vals) { $fields = $this->getFields(); if (!Arr::iterable($fields)) { return true; } $result = true; // validate each field foreach ($fields as $k => $field) { // check if required if ($this->isRequired($fi...
php
{ "resource": "" }
q231
Base.getMetaBoxTitle
train
public function getMetaBoxTitle($key = null) { return ($key) ? Str::human($key) : sprintf('%s', $this->getSingular()); }
php
{ "resource": "" }
q232
Base.scrubAttributes
train
private static function scrubAttributes($field, $type = null) { $invalid_keys = [ 'default', 'description', 'label', 'options', ]; if ($type && $type ==='textarea') { $invalid_keys[] = 'value'; } foreach ($invalid_...
php
{ "resource": "" }
q233
Base.getCheckboxDisplay
train
public function getCheckboxDisplay($column_name) { $displays = $this->getCheckboxDisplays(); if (array_key_exists($column_name, $displays)) { return $displays[$column_name]; } if (array_key_exists('default', $displays)) { return $displays['default']; }...
php
{ "resource": "" }
q234
Base.renderAdminColumn
train
public function renderAdminColumn($column_name, $item_id) { $columns = $this->getAdminColumns(); if (!in_array($column_name, $columns)) { return; } $field = $this->getField($column_name); if (is_array($field)) { $class = get_called_class(); ...
php
{ "resource": "" }
q235
Base.makeAdminColumnsSortable
train
public function makeAdminColumnsSortable($columns) { $admin_columns = $this->getAdminColumns(); if (!Arr::iterable($admin_columns)) { return $columns; } foreach ($admin_columns as $k) { $columns[$k] = $k; } return $columns; }
php
{ "resource": "" }
q236
Base.getPlural
train
public function getPlural() { $singular = $this->getSingular(); if (preg_match('/y$/', $singular)) { return preg_replace('/y$/', 'ies', $singular); } return (is_null($this->plural)) ? Str::human($singular) . 's' : $this->plural; }
php
{ "resource": "" }
q237
Base.getThe
train
public function getThe($key, $convert_value = false, $return_wrapped = true) { if ($return_wrapped) { return apply_filters('the_content', $this->get($key, $convert_value)); } // Apply the_content filter without wrapping lines in <p> tags remove_filter('the_conten...
php
{ "resource": "" }
q238
Base.getLabelText
train
public function getLabelText($field_key) { $field = $this->getField($field_key); if (!is_array($field)) { return null; } return (array_key_exists('label', $field)) ? $field['label'] : Str::human(str_replace('-', ' ', preg_replace('/_id$/i', '', $f...
php
{ "resource": "" }
q239
Base.getRenderLabel
train
public function getRenderLabel($field_key, $required_mark = ' <span class="required">*</span>') { return sprintf( '<label for="%s">%s%s</label>', $field_key, $this->getLabelText($field_key), ($required_mark && $this->isRequired($field_key)) ? $required_mark : ...
php
{ "resource": "" }
q240
Base.isRequired
train
public function isRequired($field_key) { $field = (is_array($field_key)) ? $field_key : $this->getField($field_key); return (is_array($field) && array_key_exists('required', $field) && $field['required']); }
php
{ "resource": "" }
q241
DmsParser.parse
train
public function parse($coord) { $coordinate = null; $matches = array(); preg_match($this->input_format, $coord, $matches); if (count($matches) == 5) { $degrees = $matches[1]; $minutes = $matches[2] * (1 / 60); $seconds = $matches[3] * (1 / 60 * 1 / 60)...
php
{ "resource": "" }
q242
DmsParser.get
train
public function get($coord) { $coord = rad2deg($coord); $degrees = (integer) $coord; $compass = ''; if ($this->direction == N::LAT) { if ($degrees < 0) $compass = 'S'; elseif ($degrees > 0) $compass = 'N'; }elseif ($this->di...
php
{ "resource": "" }
q243
SqlTable.convertRow
train
protected function convertRow(array $row, Connection $connection, Table $table) { $result = []; foreach ($row as $key => $value) { $type = $table->getColumn($key)->getType(); $val = $type->convertToPHPValue($value, $connection->getDatabasePlatform()); if ($type ...
php
{ "resource": "" }
q244
LoadRegisterViewHelper.renderStatic
train
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { $key = $arguments['key']; $value = $arguments['value']; array_push($GLOBALS['TSFE']->registerStack, $GLOBALS['TSFE']->register); $GLOBALS['TS...
php
{ "resource": "" }
q245
Coordinate.guessParser
train
public function guessParser($coord) { if (!is_numeric($coord) and !is_null($coord)) { return new C\DmsParser; } return new C\DecimalParser; }
php
{ "resource": "" }
q246
TranslatableUtility.Master
train
public function Master() { if (Translatable::get_current_locale() != Translatable::default_locale()) { if ($master = $this->owner->getTranslation(Translatable::default_locale())) { return $master; } } return $this->owner; }
php
{ "resource": "" }
q247
Factory.create
train
public static function create($term, $taxonomy = null) { // Ex: Taco\Term\Factory::create('Keyword') if (is_string($term) && class_exists($term)) { return new $term; } if (!is_object($term)) { $term = get_term($term, $taxonomy); } // ...
php
{ "resource": "" }
q248
Factory.createMultiple
train
public static function createMultiple($terms, $taxonomy = null) { if (!Arr::iterable($terms)) { return $terms; } $out = array(); foreach ($terms as $term) { $instance = self::create($term, $taxonomy); $out[$instance->get('term_id')] = $ins...
php
{ "resource": "" }
q249
RegistersUsers.signupUpdate
train
public function signupUpdate(Request $request) { $this->middleware('auth:api'); $data = $request->all(); $validator = Validator::make($data, [ 'firstname' => 'sometimes|required|max:255', 'surname' => 'sometimes|required|max:255', 'email' ...
php
{ "resource": "" }
q250
JSON.encode
train
public static function encode($value, $options = 0, $depth = 512) { // multi-characters supported by default $options |= JSON_UNESCAPED_UNICODE; $data = version_compare(PHP_VERSION, '5.5.0', '>=') ? json_encode($value, $options, $depth) : json_encode($value, $options...
php
{ "resource": "" }
q251
ConfigurationUtility.getExtensionConfig
train
public static function getExtensionConfig(): array { $supportedMimeTypes = self::DEFAULT_SUPPORTED_MIME_TYPES; $desktopWidth = self::DEFAULT_DESKTOP_WIDTH; $tabletWidth = self::DEFAULT_TABLET_WIDTH; $smartphoneWidth = self::DEFAULT_SMARTPHONE_WIDTH; if (isset($GLOBALS['TYPO3...
php
{ "resource": "" }
q252
Loader.load
train
public static function load($class) { $instance = new $class; $taxonomy_key = $instance->getTaxonomyKey(); if (is_admin()) { add_action(sprintf('created_%s', $taxonomy_key), array($instance, 'addSaveHooks')); add_action(sprintf('edited_%s', $taxonomy_key), array($ins...
php
{ "resource": "" }
q253
CompletePurchaseResponse.calculateHash
train
private function calculateHash() { $hashType = $this->getHashType(); if ($hashType == 'sign') { throw new InvalidResponseException('Control sign forming method "SIGN" is not supported'); } elseif ($hashType == null) { throw new InvalidResponseException('Invalid signa...
php
{ "resource": "" }
q254
Post.load
train
public function load($id, $load_terms = true) { $info = (is_object($id)) ? $id : get_post($id); if (!is_object($info)) { return false; } // Handle how WordPress converts special chars out of the DB // b/c even when you pass 'raw' as the 3rd partam to get_post, ...
php
{ "resource": "" }
q255
Post.loadTerms
train
public function loadTerms() { $taxonomy_keys = $this->getTaxonomyKeys(); if (!Arr::iterable($taxonomy_keys)) { return false; } // TODO Move this to somewhere more efficient // Check if this should be an instance of TacoTerm. // If not, the object ...
php
{ "resource": "" }
q256
Post.getDefaults
train
public function getDefaults() { global $user; return array( 'post_type' => $this->getPostType(), 'post_author' => (is_object($user)) ? $user->ID : null, 'post_date' => current_time('mysql'), 'post_category' => array(0), 'post_stat...
php
{ "resource": "" }
q257
Post.registerPostType
train
public function registerPostType() { $config = $this->getPostTypeConfig(); if (empty($config)) { return; } register_post_type($this->getPostType(), $config); }
php
{ "resource": "" }
q258
Post.getTaxonomy
train
public function getTaxonomy($key) { $taxonomies = $this->getTaxonomies(); if (!Arr::iterable($taxonomies)) { return false; } $taxonomy = (array_key_exists($key, $taxonomies)) ? $taxonomies[$key] : false; if (!$taxonomy) { return false; ...
php
{ "resource": "" }
q259
Post.getTaxonomyKeys
train
public function getTaxonomyKeys() { $taxonomies = $this->getTaxonomies(); if (!Arr::iterable($taxonomies)) { return array(); } $out = array(); foreach ($taxonomies as $k => $taxonomy) { $taxonomy = $this->getTaxonomy($k); $out[] = $this->g...
php
{ "resource": "" }
q260
Post.getTaxonomyKey
train
public function getTaxonomyKey($key, $taxonomy = array()) { if (is_string($key)) { return $key; } if (is_array($taxonomy) && array_key_exists('label', $taxonomy)) { return Str::machine($taxonomy['label'], Base::SEPARATOR); } return $key; }
php
{ "resource": "" }
q261
Post.getTaxonomiesInfo
train
public function getTaxonomiesInfo() { $taxonomies = $this->getTaxonomies(); if (!Arr::iterable($taxonomies)) { return array(); } $out = array(); foreach ($taxonomies as $k => $taxonomy) { $taxonomy = $this->getTaxonomy($k); $key = $this->g...
php
{ "resource": "" }
q262
Post.getPostTypeConfig
train
public function getPostTypeConfig() { if (in_array($this->getPostType(), array('post', 'page'))) { return null; } return array( 'labels' => array( 'name' => _x($this->getPlural(), 'post type general name'), 'singul...
php
{ "resource": "" }
q263
Post.getMenuIcon
train
public function getMenuIcon() { // Look for these files by default // If your plugin directory contains an [post-type].png file, that will by default be the icon // Ex: hot-sauce.png $reflector = new \ReflectionClass(get_called_class()); $dir = basename(dirname($reflector->ge...
php
{ "resource": "" }
q264
Post.sortAdminColumns
train
public function sortAdminColumns($vars) { if (!isset($vars['orderby'])) { return $vars; } $admin_columns = $this->getAdminColumns(); if (!Arr::iterable($admin_columns)) { return $vars; } foreach ($admin_columns as $k) { if ($vars[...
php
{ "resource": "" }
q265
Post.makeAdminTaxonomyColumnsSortable
train
public function makeAdminTaxonomyColumnsSortable($clauses, $wp_query) { global $wpdb; // Not sorting at all? Get out. if (!array_key_exists('orderby', $wp_query->query)) { return $clauses; } if ($wp_query->query['orderby'] !== 'meta_value') { ...
php
{ "resource": "" }
q266
Post.getHideTitleFromAdminColumns
train
public function getHideTitleFromAdminColumns() { if (in_array('title', $this->getAdminColumns())) { return false; } $supports = $this->getSupports(); if (is_array($supports) && in_array('title', $supports)) { return false; } r...
php
{ "resource": "" }
q267
Post.getPostType
train
public function getPostType() { $called_class_segments = explode('\\', get_called_class()); $class_name = end($called_class_segments); return (is_null($this->post_type)) ? Str::machine(Str::camelToHuman($class_name), Base::SEPARATOR) : $this->post_type; }
php
{ "resource": "" }
q268
Post.getPairs
train
public static function getPairs($args = array()) { $called_class = get_called_class(); $instance = Post\Factory::create($called_class); // Optimize the query if no args // Unfortunately, WP doesn't provide a clean way to specify which columns to select // If WP allowed that,...
php
{ "resource": "" }
q269
Post.getWhere
train
public static function getWhere($args = array(), $load_terms = true) { $instance = Post\Factory::create(get_called_class()); // Allow sorting both by core fields and custom fields // See: http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters $default_order...
php
{ "resource": "" }
q270
Post.getByTerm
train
public static function getByTerm($taxonomy, $terms, $field = 'slug', $args = array(), $load_terms = true) { $args = array_merge($args, array( 'tax_query'=>array( array( 'taxonomy'=>$taxonomy, 'terms'=>$terms, 'field'=>$f...
php
{ "resource": "" }
q271
Post.getOneByTerm
train
public static function getOneByTerm($taxonomy, $terms, $field = 'slug', $args = array(), $load_terms = true) { $args['numberposts'] = 1; $result = static::getByTerm($taxonomy, $terms, $field, $args, $load_terms); return (count($result)) ? current($result) : null; }
php
{ "resource": "" }
q272
Post.getPage
train
public static function getPage($page = 1, $args = array(), $load_terms = true) { $instance = Post\Factory::create(get_called_class()); $criteria = array( 'post_type' => $instance->getPostType(), 'orderby' => 'date', 'order' => 'DESC', 'posts_per_page'...
php
{ "resource": "" }
q273
Post.setTerms
train
public function setTerms($term_ids, $taxonomy = null, $append = false) { $taxonomy = ($taxonomy) ? $taxonomy : 'post_tag'; if (!is_array($this->_terms)) { $this->_terms = array(); } if (!array_key_exists($taxonomy, $this->_terms)) { $this->_terms[$taxonomy] = ...
php
{ "resource": "" }
q274
Post.getTerms
train
public function getTerms($taxonomy = null) { if ($taxonomy) { return (array_key_exists($taxonomy, $this->_terms)) ? $this->_terms[$taxonomy] : array(); } return $this->_terms; }
php
{ "resource": "" }
q275
Post.hasTerm
train
public function hasTerm($term_id) { $taxonomy_terms = $this->getTerms(); if (!Arr::iterable($taxonomy_terms)) { return false; } foreach ($taxonomy_terms as $taxonomy_key => $terms) { if (!Arr::iterable($terms)) { continue; } ...
php
{ "resource": "" }
q276
Post.getPostAttachment
train
public function getPostAttachment($size = 'full', $property = null) { $post_id = $this->get('ID'); if (!has_post_thumbnail($post_id)) { return false; } $attachment_id = get_post_thumbnail_id($post_id); $image_properties = array( 'url', ...
php
{ "resource": "" }
q277
Post.getRenderPublicField
train
public function getRenderPublicField($key, $field = null, $load_value = true) { $class = get_called_class(); if ($key === self::KEY_CLASS) { $attribs = array('type'=>'hidden', 'name'=>$key, 'value'=>$class); return Html::tag('input', null, $attribs); } if ($ke...
php
{ "resource": "" }
q278
Post.getPublicFormKey
train
public function getPublicFormKey($suffix = null) { $val = sprintf('%s_public_form', $this->getPostType()); return ($suffix) ? sprintf('%s_%s', $val, $suffix) : $val; }
php
{ "resource": "" }
q279
Post.find
train
public static function find($post_id, $load_terms = true) { $instance = Post\Factory::create(get_called_class()); $instance->load($post_id, $load_terms); return $instance; }
php
{ "resource": "" }
q280
Post.getLinkURL
train
public function getLinkURL($field) { $link_attr = self::decodeLinkObject($this->get($field)); if(!is_object($link_attr)) { return $this->get($field); } if(!(strlen($link_attr->href) && strlen($link_attr->title) && strlen($link_attr->target))) { $field_attribs...
php
{ "resource": "" }
q281
Post.linkAttribsToHTMLString
train
public function linkAttribsToHTMLString($link_attr, $body = '', $classes = '', $id = '', $styles = '') { $link_text = null; if (strlen($link_attr->title)) { $link_text = $link_attr->title; } elseif (strlen($body)) { $link_text = $body; } else { $li...
php
{ "resource": "" }
q282
Post.getLinkHTMLFromObject
train
public static function getLinkHTMLFromObject($object_string, $body = '', $classes = '', $id = '', $styles = '') { return self::linkAttribsToHTMLString( self::decodeLinkObject($object_string), $body, $classes, $id, $styles ); }
php
{ "resource": "" }
q283
Passwordless.generateToken
train
public function generateToken($save = false) { $attributes = [ 'token' => str_random(16), 'is_used' => false, 'user_id' => $this->id, 'created_at' => time() ]; $token = App::make(Token::class); $token->fill($attributes); ...
php
{ "resource": "" }
q284
QueryBuilderVisitor.enterExpression
train
public function enterExpression(Expression $expr) { $hash = spl_object_hash($expr); if ($expr instanceof Key) { if (!count($this->hashes)) { $this->qb->andWhere($this->toExpr($expr)); } else { $lastHash = end($this->hashes); $...
php
{ "resource": "" }
q285
QueryBuilderVisitor.leaveExpression
train
public function leaveExpression(Expression $expr) { if ($expr instanceof OrX || $expr instanceof AndX) { $hash = spl_object_hash($expr); if ($expr instanceof OrX) { $composite = $this->qb->expr()->orX(); $composite->addMultiple($this->map[$hash]); ...
php
{ "resource": "" }
q286
QueryBuilderVisitor.shouldJoin
train
public function shouldJoin($key, $prefix = null) { $parts = explode('.', $key); if (!$prefix) { $prefix = $this->getRootAlias(); } if (!in_array($parts[0], $this->qb->getAllAliases())) { $this->qb->leftJoin($prefix.'.'.$parts[0], $parts[0]); } ...
php
{ "resource": "" }
q287
Rsa.validateKey
train
private function validateKey($key) { $details = openssl_pkey_get_details($key); if (!isset($details['key']) || $details['type'] !== OPENSSL_KEYTYPE_RSA) { throw new \InvalidArgumentException('This key is not compatible with RSA signatures'); } }
php
{ "resource": "" }
q288
DownloadsBlockService.downloadMediaAction
train
public function downloadMediaAction($filename) { $media = $this->mediaManager->getRepository()->findOneByReference($filename); $provider = $this->container->get('opifer.media.provider.pool')->getProvider($media->getProvider()); $mediaUrl = $provider->getUrl($media); $fileSystem = $...
php
{ "resource": "" }
q289
DisplayLogicType.getDisplayLogicPrototypes
train
protected function getDisplayLogicPrototypes(BlockInterface $block) { $collection = new PrototypeCollection([ new OrXPrototype(), new AndXPrototype(), new EventPrototype('click_event', 'Click Event', 'event.type.click'), new TextPrototype('dom_node_id', 'DOM N...
php
{ "resource": "" }
q290
AuthenticationSuccessHandler.onAuthenticationSuccess
train
public function onAuthenticationSuccess(Request $request, TokenInterface $token) { if ($user = $token->getUser()) { if (!$user->getFirstName() || !$user->getLastName()) { return new RedirectResponse($this->router->generate('opifer_cms_user_profile')); } } ...
php
{ "resource": "" }
q291
Deserializer.fromBase64URL
train
public function fromBase64URL($data) { if ($remainder = strlen($data) % 4) { $data .= str_repeat('=', 4 - $remainder); } return base64_decode(strtr($data, '-_', '+/')); }
php
{ "resource": "" }
q292
MailPlusProvider.synchronise
train
public function synchronise(Subscription $subscription) { try { $contact = [ 'update' => true, 'purge' => false, 'contact' => [ 'externalId' => $subscription->getId(), 'properties' => [ ...
php
{ "resource": "" }
q293
Token.getHeader
train
public function getHeader($name, $default = null) { if ($this->hasHeader($name)) { return $this->getHeaderValue($name); } if ($default === null) { throw new \OutOfBoundsException('Requested header is not configured'); } return $default; }
php
{ "resource": "" }
q294
Token.getHeaderValue
train
private function getHeaderValue($name) { $header = $this->headers[$name]; if ($header instanceof Claim) { return $header->getValue(); } return $header; }
php
{ "resource": "" }
q295
Token.getClaim
train
public function getClaim($name, $default = null) { if ($this->hasClaim($name)) { return $this->claims[$name]->getValue(); } if ($default === null) { throw new \OutOfBoundsException('Requested claim is not configured'); } return $default; }
php
{ "resource": "" }
q296
Token.verify
train
public function verify(Signer $signer, $key) { if ($this->signature === null) { throw new \BadMethodCallException('This token is not signed'); } if ($this->headers['alg'] !== $signer->getAlgorithmId()) { return false; } return $this->signature->verif...
php
{ "resource": "" }
q297
Token.validate
train
public function validate(ValidationData $data) { foreach ($this->getValidatableClaims() as $claim) { if (!$claim->validate($data)) { return false; } } return true; }
php
{ "resource": "" }
q298
Token.getValidatableClaims
train
private function getValidatableClaims() { $claims = array(); foreach ($this->claims as $claim) { if ($claim instanceof Validatable) { $cliams[] = $claim; } } return $claims; }
php
{ "resource": "" }
q299
Issue.create
train
public function create($projectKey, $issueTypeName) { $fieldsMetadata = $this->getCreateMetadataFields($projectKey, $issueTypeName); $fluentIssueCreate = new FluentIssueCreate($this->client, $fieldsMetadata); return $fluentIssueCreate->field(Field::PROJECT, $projectKey) ...
php
{ "resource": "" }