_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q246500
ElasticsearchModel.all
validation
public static function all($query = []) { if ($query instanceof QueryBuilder) { $query = $query->build(); } $collection = collect(); static::map($query, function (ElasticsearchModel $document) use ($collection) { $collection->put($document->getId(), $document); }); return $collection; }
php
{ "resource": "" }
q246501
Filter.setOptions
validation
public function setOptions($mode = null, $logicalOperator = null, array $linkedFilters = []) { $this->mode = is_null($mode) ? Filter::MODE_INCLUDE : $mode; $this->logicalOperator = is_null($logicalOperator) ? Filter::MERGE_OR : $logicalOperator; $this->linkedFilters = $linkedFilters; return $this; }
php
{ "resource": "" }
q246502
Filter.mergeQuery
validation
public function mergeQuery(array $query) { $types = [ Filter::MERGE_AND => 'must', Filter::MERGE_OR => 'should' ]; $type = $this->getMergeType(); $query['body']['filter']['bool'][$types[$type]][] = $this->makeQuery(); return $query; }
php
{ "resource": "" }
q246503
Filter.mergeBoolQuery
validation
protected function mergeBoolQuery(array $query1, array $query2, $type) { if (empty($query2['bool'][$type])) { return $query1; } else { if (empty($query1['bool'][$type])) { $query1['bool'][$type] = []; } } $query1['bool'][$type] = array_merge($query1['bool'][$type], $query2['bool'][$type]); return $query1; }
php
{ "resource": "" }
q246504
QueryBuilder.fields
validation
public function fields($fields = false) { if ($fields === false) { $this->query['body']['_source'] = false; } elseif ((array)$fields == ['*']) { unset($this->query['body']['_source']); } else { $this->query['body']['_source'] = $fields; } return $this; }
php
{ "resource": "" }
q246505
RuntimeCache.put
validation
public function put($key, Model $instance, array $attributes = ['*']) { if ($attributes != ['*'] && $this->has($key)) { $instance = Model::merge($this->cache[$key]['instance'], $instance, $attributes); $attributes = array_merge($this->cache[$key]['attributes'], $attributes); } $this->cache[$key] = [ 'instance' => $instance, 'attributes' => $attributes ]; return $instance; }
php
{ "resource": "" }
q246506
RuntimeCache.getNotCachedAttributes
validation
public function getNotCachedAttributes($key, array $attributes = ['*']) { if (!$this->has($key)) { return $attributes; } $cachedAttributes = $this->cache[$key]['attributes']; return $cachedAttributes == ['*'] ? [] : array_diff($attributes, $cachedAttributes); }
php
{ "resource": "" }
q246507
Mergeable.merge
validation
public static function merge(Model $model1, Model $model2, array $attributes) { foreach ($attributes as $attribute) { $model1->$attribute = $model2->$attribute; } return $model1; }
php
{ "resource": "" }
q246508
Escape.esc_value
validation
public function esc_value( $value ) { global $wpdb; if ( is_int( $value ) ) { return $wpdb->prepare( '%d', $value ); } if ( is_float( $value ) ) { return $wpdb->prepare( '%f', $value ); } if ( is_string( $value ) ) { return 'null' === $value ? $value : $wpdb->prepare( '%s', $value ); } return $value; }
php
{ "resource": "" }
q246509
Escape.esc_like
validation
public function esc_like( $value, $start = '%', $end = '%' ) { global $wpdb; return $start . $wpdb->esc_like( $value ) . $end; }
php
{ "resource": "" }
q246510
Translate.translateSelect
validation
private function translateSelect() { // @codingStandardsIgnoreLine $build = array( 'select' ); if ( $this->found_rows ) { $build[] = 'SQL_CALC_FOUND_ROWS'; } if ( $this->distinct ) { $build[] = 'distinct'; } // Build the selected fields. $build[] = ! empty( $this->statements['select'] ) && is_array( $this->statements['select'] ) ? join( ', ', $this->statements['select'] ) : '*'; // Append the table. $build[] = 'from ' . $this->table; // Build the where statements. if ( ! empty( $this->statements['wheres'] ) ) { $build[] = join( ' ', $this->statements['wheres'] ); } // Build the group by statements. if ( ! empty( $this->statements['groups'] ) ) { $build[] = 'group by ' . join( ', ', $this->statements['groups'] ); if ( ! empty( $this->statements['having'] ) ) { $build[] = $this->statements['having']; } } // Build the order statement. if ( ! empty( $this->statements['orders'] ) ) { $build[] = $this->translateOrderBy(); } // Build offset and limit. if ( ! empty( $this->limit ) ) { $build[] = $this->limit; } return join( ' ', $build ); }
php
{ "resource": "" }
q246511
Translate.translateUpdate
validation
private function translateUpdate() { // @codingStandardsIgnoreLine $build = array( "update {$this->table} set" ); // Add the values. $values = array(); foreach ( $this->statements['values'] as $key => $value ) { $values[] = $key . ' = ' . $this->esc_value( $value ); } if ( ! empty( $values ) ) { $build[] = join( ', ', $values ); } // Build the where statements. if ( ! empty( $this->statements['wheres'] ) ) { $build[] = join( ' ', $this->statements['wheres'] ); } // Build offset and limit. if ( ! empty( $this->limit ) ) { $build[] = $this->limit; } return join( ' ', $build ); }
php
{ "resource": "" }
q246512
Translate.translateDelete
validation
private function translateDelete() { // @codingStandardsIgnoreLine $build = array( "delete from {$this->table}" ); // Build the where statements. if ( ! empty( $this->statements['wheres'] ) ) { $build[] = join( ' ', $this->statements['wheres'] ); } // Build offset and limit. if ( ! empty( $this->limit ) ) { $build[] = $this->limit; } return join( ' ', $build ); }
php
{ "resource": "" }
q246513
Translate.translateOrderBy
validation
protected function translateOrderBy() { // @codingStandardsIgnoreLine $build = array(); foreach ( $this->statements['orders'] as $column => $direction ) { // in case a raw value is given we had to // put the column / raw value an direction inside another // array because we cannot make objects to array keys. if ( is_array( $direction ) ) { list( $column, $direction ) = $direction; } if ( ! is_null( $direction ) ) { $column .= ' ' . $direction; } $build[] = $column; } return 'order by ' . join( ', ', $build ); }
php
{ "resource": "" }
q246514
Database.table
validation
public static function table( $table_name ) { global $wpdb; if ( empty( self::$instances ) || empty( self::$instances[ $table_name ] ) ) { self::$instances[ $table_name ] = new Query_Builder( $wpdb->prefix . $table_name ); } return self::$instances[ $table_name ]; }
php
{ "resource": "" }
q246515
GroupBy.groupBy
validation
public function groupBy( $columns ) { // @codingStandardsIgnoreLine if ( is_string( $columns ) ) { $columns = $this->argument_to_array( $columns ); } $this->statements['groups'] = $this->statements['groups'] + $columns; return $this; }
php
{ "resource": "" }
q246516
GroupBy.having
validation
public function having( $column, $param1 = null, $param2 = null ) { $this->statements['having'] = $this->generateWhere( $column, $param1, $param2, 'having' ); return $this; }
php
{ "resource": "" }
q246517
OrderBy.orderBy
validation
public function orderBy( $columns, $direction = 'asc' ) { // @codingStandardsIgnoreLine if ( is_string( $columns ) ) { $columns = $this->argument_to_array( $columns ); } foreach ( $columns as $key => $column ) { if ( is_numeric( $key ) ) { $this->statements['orders'][ $column ] = $direction; } else { $this->statements['orders'][ $key ] = $column; } } return $this; }
php
{ "resource": "" }
q246518
Where.where
validation
public function where( $column, $param1 = null, $param2 = null, $type = 'and' ) { // Check if the where type is valid. if ( ! in_array( $type, array( 'and', 'or', 'where' ) ) ) { throw new \Exception( 'Invalid where type "' . $type . '"' ); } $sub_type = is_null( $param1 ) ? $type : $param1; if ( empty( $this->statements['wheres'] ) ) { $type = 'where'; } // When column is an array we assume to make a bulk and where. if ( is_array( $column ) ) { $subquery = array(); foreach ( $column as $value ) { if ( ! isset( $value[2] ) ) { $value[2] = $value[1]; $value[1] = '='; } $subquery[] = $this->generateWhere( $value[0], $value[1], $value[2], empty( $subquery ) ? '' : $sub_type ); } $this->statements['wheres'][] = $type . ' ( ' . trim( join( ' ', $subquery ) ) . ' )'; return $this; } $this->statements['wheres'][] = $this->generateWhere( $column, $param1, $param2, $type ); return $this; }
php
{ "resource": "" }
q246519
Where.orWhere
validation
public function orWhere( $column, $param1 = null, $param2 = null ) { // @codingStandardsIgnoreLine return $this->where( $column, $param1, $param2, 'or' ); }
php
{ "resource": "" }
q246520
Where.generateWhere
validation
protected function generateWhere( $column, $param1 = null, $param2 = null, $type = 'and' ) { // @codingStandardsIgnoreLine // when param2 is null we replace param2 with param one as the // value holder and make param1 to the = operator. if ( is_null( $param2 ) ) { $param2 = $param1; $param1 = '='; } // When param2 is an array we probably // have an "in" or "between" statement which has no need for duplicates. if ( is_array( $param2 ) ) { $param2 = $this->esc_array( array_unique( $param2 ) ); if ( in_array( $param1, array( 'between', 'not between' ) ) ) { $param2 = join( ' and ', $param2 ); } else { $param2 = '(' . join( ', ', $param2 ) . ')'; } } elseif ( is_scalar( $param2 ) ) { $param2 = $this->esc_value( $param2 ); } return join( ' ', array( $type, $column, $param1, $param2 ) ); }
php
{ "resource": "" }
q246521
Select.select
validation
public function select( $fields = '' ) { if ( empty( $fields ) ) { return $this; } if ( is_string( $fields ) ) { $this->statements['select'][] = $fields; return $this; } foreach ( $fields as $key => $field ) { if ( is_string( $key ) ) { $this->statements['select'][] = "$key as $field"; } else { $this->statements['select'][] = $field; } } return $this; }
php
{ "resource": "" }
q246522
Select.selectFunc
validation
public function selectFunc( $func, $field, $alias = null ) { // @codingStandardsIgnoreLine $field = "$func({$field})"; if ( ! is_null( $alias ) ) { $field .= " as {$alias}"; } $this->statements['select'][] = $field; return $this; }
php
{ "resource": "" }
q246523
Query_Builder.getVar
validation
public function getVar() { // @codingStandardsIgnoreLine $row = $this->one( \ARRAY_A ); return is_null( $row ) ? false : current( $row ); }
php
{ "resource": "" }
q246524
Query_Builder.insert
validation
public function insert( $data, $format = null ) { global $wpdb; $wpdb->insert( $this->table, $data, $format ); return $wpdb->insert_id; }
php
{ "resource": "" }
q246525
Query_Builder.limit
validation
public function limit( $limit, $offset = 0 ) { global $wpdb; $limit = \absint( $limit ); $offset = \absint( $offset ); $this->limit = $wpdb->prepare( 'limit %d, %d', $offset, $limit ); return $this; }
php
{ "resource": "" }
q246526
Query_Builder.page
validation
public function page( $page, $size = 25 ) { $size = \absint( $size ); $offset = $size * \absint( $page ); $this->limit( $size, $offset ); return $this; }
php
{ "resource": "" }
q246527
Query_Builder.reset
validation
private function reset() { $this->distinct = false; $this->found_rows = false; $this->limit = null; $this->statements = [ 'select' => [], 'wheres' => [], 'orders' => [], 'values' => [], 'groups' => [], 'having' => '', ]; return $this; }
php
{ "resource": "" }
q246528
Client.request
validation
public static function request($method, $params = null) { $url = self::getUrl($method); $request_method = self::getRequestMethodName(); $response_body = self::$request_method($url, $params); $response = json_decode($response_body); if (!is_object($response)) throw new Error("Invalid server response: $response_body"); if (isset($response->error)) throw new Error($response->error->message); return $response; }
php
{ "resource": "" }
q246529
Client.getRequestMethodName
validation
protected static function getRequestMethodName() { $request_engine = self::$requestEngine; if ($request_engine == 'curl' && !function_exists('curl_init')) { trigger_error("DetectLanguage::Client - CURL not found, switching to stream"); $request_engine = self::$requestEngine = 'stream'; } switch ($request_engine) { case 'curl': return 'requestCurl'; case 'stream': return 'requestStream'; default: throw new Error("Invalid request engine: " . $request_engine); } }
php
{ "resource": "" }
q246530
Client.requestStream
validation
protected static function requestStream($url, $params) { $opts = array('http' => array( 'method' => 'POST', 'header' => implode("\n", self::getHeaders()), 'content' => json_encode($params), 'timeout' => self::$requestTimeout, 'ignore_errors' => true, ) ); $context = stream_context_create($opts); return file_get_contents($url, false, $context); }
php
{ "resource": "" }
q246531
Client.requestCurl
validation
protected static function requestCurl($url, $params) { $ch = curl_init(); $options = array( CURLOPT_URL => $url, CURLOPT_HTTPHEADER => self::getHeaders(), CURLOPT_POSTFIELDS => json_encode($params), CURLOPT_CONNECTTIMEOUT => self::$connectTimeout, CURLOPT_TIMEOUT => self::$requestTimeout, CURLOPT_USERAGENT => self::getUserAgent(), CURLOPT_RETURNTRANSFER => true ); curl_setopt_array($ch, $options); $result = curl_exec($ch); if ($result === false) { $e = new Error(curl_error($ch)); curl_close($ch); throw $e; } curl_close($ch); return $result; }
php
{ "resource": "" }
q246532
DetectLanguage.simpleDetect
validation
public static function simpleDetect($text) { $detections = self::detect($text); if (count($detections) > 0) return $detections[0]->language; else return null; }
php
{ "resource": "" }
q246533
Gravatar.buildGravatarURL
validation
public function buildGravatarURL($email, $hash_email = true) { // Start building the URL, and deciding if we're doing this via HTTPS or HTTP. if($this->usingSecureImages()) { $url = static::HTTPS_URL; } else { $url = static::HTTP_URL; } // Tack the email hash onto the end. if($hash_email == true && !empty($email)) { $url .= $this->getEmailHash($email); } elseif(!empty($email)) { $url .= $email; } else { $url .= str_repeat('0', 32); } // Check to see if the param_cache property has been populated yet if($this->param_cache === NULL) { // Time to figure out our request params $params = array(); $params[] = 's=' . $this->getAvatarSize(); $params[] = 'r=' . $this->getMaxRating(); if($this->getDefaultImage()) { $params[] = 'd=' . $this->getDefaultImage(); } // Stuff the request params into the param_cache property for later reuse $this->params_cache = (!empty($params)) ? '?' . implode('&', $params) : ''; } // Handle "null" gravatar requests. $tail = ''; if(empty($email)) { $tail = !empty($this->params_cache) ? '&f=y' : '?f=y'; } // And we're done. return $url . $this->params_cache . $tail; }
php
{ "resource": "" }
q246534
CreateFontCommand.execute
validation
protected function execute(InputInterface $input, OutputInterface $output){ $directory = $input->getArgument('directory'); $outputFile = $input->getArgument('output-file'); $generator = new IconFontGenerator; $output->writeln('reading files from "'.$directory.'" ...'); $generator->generateFromDir($directory, array( 'id' => $input->getOption('name') ?: 'SVGFont', ), $input->getOption('rename-files')); $output->writeln('writing font to "'.$outputFile.'" ...'); file_put_contents($outputFile, $generator->getFont()->getXML()); $output->getFormatter()->setStyle('success', new OutputFormatterStyle(null, null, array('bold', 'reverse'))); $output->writeln('<success>created '.$outputFile.' successfully</success>'); }
php
{ "resource": "" }
q246535
CreateCssCommand.execute
validation
protected function execute(InputInterface $input, OutputInterface $output){ $fontFile = realpath($input->getArgument('font-file')); if($fontFile === false || !file_exists($fontFile)){ throw new \InvalidArgumentException('"'.$input->getArgument('font-file').'" does not exist'); } $outputFile = $input->getArgument('output-file'); $generator = new IconFontGenerator; $output->writeln('reading font file from "'.$fontFile.'" ...'); $generator->generateFromFont(new Font(array(), file_get_contents($fontFile))); $output->writeln('writing CSS file to "'.$outputFile.'" ...'); file_put_contents($outputFile, $generator->getCss()); $output->getFormatter()->setStyle('success', new OutputFormatterStyle(null, null, array('bold', 'reverse'))); $output->writeln('<success>created CSS file successfully</success>'); }
php
{ "resource": "" }
q246536
CreateFilesCommand.execute
validation
protected function execute(InputInterface $input, OutputInterface $output){ $fontFile = realpath($input->getArgument('font-file')); if($fontFile === false || !file_exists($fontFile)){ throw new \InvalidArgumentException('"'.$input->getArgument('font-file').'" does not exist'); } $outputDirectory = realpath($input->getArgument('output-directory')); if($outputDirectory === false || !file_exists($outputDirectory) || !is_dir($outputDirectory)){ throw new \InvalidArgumentException('"'.$input->getArgument('output-directory').'" is no directory'); } $generator = new IconFontGenerator; $output->writeln('reading font file from "'.$fontFile.'" ...'); $generator->generateFromFont(new Font(array(), file_get_contents($fontFile))); $output->writeln('writing SVG files to "'.$outputDirectory.'" ...'); $generator->saveGlyphsToDir($outputDirectory); $output->getFormatter()->setStyle('success', new OutputFormatterStyle(null, null, array('bold', 'reverse'))); $output->writeln('<success>created SVG files successfully</success>'); }
php
{ "resource": "" }
q246537
Font.setOptions
validation
public function setOptions($options = array()){ $this->options = array_merge($this->options, $options); $this->xmlDocument->defs[0]->font[0]['id'] = $this->options['id']; $this->xmlDocument->defs[0]->font[0]['horiz-adv-x'] = $this->options['horiz-adv-x']; $this->xmlDocument->defs[0]->font[0]->{'font-face'}[0]['units-per-em'] = $this->options['units-per-em']; $this->xmlDocument->defs[0]->font[0]->{'font-face'}[0]['ascent'] = $this->options['ascent']; $this->xmlDocument->defs[0]->font[0]->{'font-face'}[0]['descent'] = $this->options['descent']; $this->xmlDocument->defs[0]->font[0]->{'font-face'}[0]['x-height'] = $this->options['x-height']; $this->xmlDocument->defs[0]->font[0]->{'font-face'}[0]['cap-height'] = $this->options['cap-height']; $this->xmlDocument->defs[0]->font[0]->{'missing-glyph'}[0]['horiz-adv-x'] = $this->options['horiz-adv-x']; }
php
{ "resource": "" }
q246538
Font.getOptionsFromXML
validation
protected function getOptionsFromXML(){ $options = array(); foreach(array('id', 'horiz-adv-x') as $key){ if(isset($this->xmlDocument->defs[0]->font[0][$key])){ $options[$key] = (string)$this->xmlDocument->defs[0]->font[0][$key]; } } foreach(array('units-per-em', 'ascent', 'descent', 'x-height', 'cap-height') as $key){ if(isset($this->xmlDocument->defs[0]->font[0]->{'font-face'}[0][$key])){ $options[$key] = (string)$this->xmlDocument->defs[0]->font[0]->{'font-face'}[0][$key]; } } return $options; }
php
{ "resource": "" }
q246539
Font.addGlyph
validation
public function addGlyph($char, $path, $name = null, $width = null){ $glyph = $this->xmlDocument->defs[0]->font[0]->addChild('glyph'); $glyph->addAttribute('unicode', $char); if($name !== null){ $glyph->addAttribute('glyph-name', $name); } if($width !== null){ $glyph->addAttribute('horiz-adv-x', $width); } $glyph->addAttribute('d', $path); }
php
{ "resource": "" }
q246540
Font.getGlyphs
validation
public function getGlyphs(){ if( !isset($this->xmlDocument->defs[0]->font[0]->glyph) || !count($this->xmlDocument->defs[0]->font[0]->glyph) ){ return array(); } $glyphs = array(); foreach($this->xmlDocument->defs[0]->font[0]->glyph as $xmlGlyph){ if(isset($xmlGlyph['unicode']) && isset($xmlGlyph['d'])){ $glyph = array( 'char' => (string)$xmlGlyph['unicode'], 'path' => (string)$xmlGlyph['d'], ); if(isset($xmlGlyph['glyph-name'])){ $glyph['name'] = (string)$xmlGlyph['glyph-name']; } if(isset($xmlGlyph['horiz-adv-x'])){ $glyph['width'] = (string)$xmlGlyph['horiz-adv-x']; } $glyphs[] = $glyph; } } return $glyphs; }
php
{ "resource": "" }
q246541
IconFontGenerator.getGlyphNames
validation
public function getGlyphNames(){ $glyphNames = array(); foreach($this->font->getGlyphs() as $glyph){ $glyphNames[static::unicodeToHex($glyph['char'])] = empty($glyph['name']) ? null : $glyph['name']; } return $glyphNames; }
php
{ "resource": "" }
q246542
IconFontGenerator.getCss
validation
public function getCss(){ $css = ''; foreach($this->getGlyphNames() as $unicode => $name){ $css .= ".icon-".$name.":before {"."\n"; $css .= "\tcontent: \"\\".$unicode."\";\n"; $css .= "}\n"; } return $css; }
php
{ "resource": "" }
q246543
IconFontGenerator.unicodeToHex
validation
public static function unicodeToHex($char){ if(!is_string($char) || mb_strlen($char, 'utf-8') !== 1){ throw new \InvalidArgumentException('$char must be one single character'); } $unicode = unpack('N', mb_convert_encoding($char, 'UCS-4BE', 'UTF-8')); return dechex($unicode[1]); }
php
{ "resource": "" }
q246544
IconFontGenerator.hexToUnicode
validation
protected static function hexToUnicode($char){ if(!is_string($char) || !preg_match('(^[0-9a-f]{2,6}$)i', $char)){ throw new \InvalidArgumentException('$char must be one single unicode character as hex string'); } return mb_convert_encoding('&#x'.strtolower($char).';', 'UTF-8', 'HTML-ENTITIES'); }
php
{ "resource": "" }
q246545
Document.getPath
validation
public function getPath($scale = 1, $roundPrecision = null, $flip = 'none', $onlyFilled = true, $xOffset = 0, $yOffset = 0){ $path = $this->getPathPart($this->xmlDocument, $onlyFilled); if($scale !== 1 || $roundPrecision !== null || $flip !== 'none' || $xOffset !== 0 || $yOffset !== 0){ $path = $this->transformPath($path, $scale, $roundPrecision, $flip, $xOffset / $scale, $yOffset / $scale); } return trim($path); }
php
{ "resource": "" }
q246546
Document.getPathPart
validation
protected function getPathPart(SimpleXMLElement $xmlElement, $onlyFilled){ $path = ''; if($xmlElement === null){ $xmlElement = $this->xmlDocument; } foreach($xmlElement->children() as $child){ $childName = $child->getName(); if(!empty($child['transform'])){ throw new \Exception('Transforms are currently not supported!'); } if($childName === 'g'){ $path .= ' '.$this->getPathPart($child, $onlyFilled); } else{ if($onlyFilled && (string)$child['fill'] === 'none'){ continue; } if($childName === 'polygon'){ $path .= ' '.$this->getPathFromPolygon($child); } elseif($childName === 'rect'){ $path .= ' '.$this->getPathFromRect($child); } elseif($childName === 'circle'){ $path .= ' '.$this->getPathFromCircle($child); } elseif($childName === 'ellipse'){ $path .= ' '.$this->getPathFromEllipse($child); } elseif($childName === 'path'){ $pathPart = trim($child['d']); if(substr($pathPart, 0, 1) === 'm'){ $pathPart = 'M'.substr($pathPart, 1); } $path .= ' '.$pathPart; } } } return trim($path); }
php
{ "resource": "" }
q246547
Document.transformPath
validation
protected function transformPath($path, $scale, $roundPrecision, $flip, $xOffset, $yOffset){ if($flip === 'horizontal' || $flip === 'vertical'){ $viewBox = $this->getViewBox(); } return preg_replace_callback('([m,l,h,v,c,s,q,t,a,z](?:[\\s,]*-?(?=\\.?\\d)\\d*(?:\\.\\d+)?)*)i', function($maches) use ($scale, $roundPrecision, $flip, $xOffset, $yOffset, $viewBox){ $command = substr($maches[0], 0, 1); $absoluteCommand = strtoupper($command) === $command; $xyCommand = in_array(strtolower($command), array('m','l','c','s','q','t')); $xCommand = strtolower($command) === 'h'; $yCommand = strtolower($command) === 'v'; if(strtolower($command) === 'z'){ return $command; } if(strtolower($command) === 'a'){ throw new \Exception('Path command "A" is currently not supportet!'); } $values = $this->getValuesFromList(substr($maches[0], 1)); foreach($values as $key => $value) { if( $flip === 'horizontal' && ((!($key%2) && $xyCommand) || $xCommand) ){ $values[$key] *= -1; if($absoluteCommand){ $values[$key] += $viewBox['width']; } } if( $flip === 'vertical' && (($key%2 && $xyCommand) || $yCommand) ){ $values[$key] *= -1; if($absoluteCommand){ $values[$key] += $viewBox['height']; } } if( $absoluteCommand && ((!($key%2) && $xyCommand) || $xCommand) ){ $values[$key] += $xOffset; } if( $absoluteCommand && (($key%2 && $xyCommand) || $yCommand) ){ $values[$key] += $yOffset; } $values[$key] *= $scale; if($roundPrecision !== null){ $values[$key] = round($values[$key], $roundPrecision); } } return $command.implode(' ', $values); }, $path); }
php
{ "resource": "" }
q246548
Document.getPathFromPolygon
validation
protected function getPathFromPolygon(SimpleXMLElement $polygon){ $points = $this->getValuesFromList($polygon['points']); $path = 'M'.array_shift($points).' '.array_shift($points); while(count($points)){ $path .= 'L'.array_shift($points).' '.array_shift($points); } return $path.'Z'; }
php
{ "resource": "" }
q246549
Document.getPathFromRect
validation
protected function getPathFromRect(SimpleXMLElement $rect){ if(empty($rect['width']) || $rect['width'] < 0 || empty($rect['height']) || $rect['height'] < 0){ return ''; } if(empty($rect['x'])){ $rect['x'] = 0; } if(empty($rect['y'])){ $rect['y'] = 0; } return 'M'.$rect['x'].' '.$rect['y'].'l'.$rect['width'].' 0l0 '.$rect['height'].'l'.(-$rect['width']).' 0Z'; }
php
{ "resource": "" }
q246550
Document.getPathFromCircle
validation
protected function getPathFromCircle(SimpleXMLElement $circle){ $mult = 0.55228475; return 'M'.($circle['cx']-$circle['r']).' '.$circle['cy']. 'C'.($circle['cx']-$circle['r']).' '.($circle['cy']-$circle['r']*$mult).' '.($circle['cx']-$circle['r']*$mult).' '.($circle['cy']-$circle['r']).' '.$circle['cx'].' '.($circle['cy']-$circle['r']). 'C'.($circle['cx']+$circle['r']*$mult).' '.($circle['cy']-$circle['r']).' '.($circle['cx']+$circle['r']).' '.($circle['cy']-$circle['r']*$mult).' '.($circle['cx']+$circle['r']).' '.$circle['cy']. 'C'.($circle['cx']+$circle['r']).' '.($circle['cy']+$circle['r']*$mult).' '.($circle['cx']+$circle['r']*$mult).' '.($circle['cy']+$circle['r']).' '.$circle['cx'].' '.($circle['cy']+$circle['r']). 'C'.($circle['cx']-$circle['r']*$mult).' '.($circle['cy']+$circle['r']).' '.($circle['cx']-$circle['r']).' '.($circle['cy']+$circle['r']*$mult).' '.($circle['cx']-$circle['r']).' '.$circle['cy']. 'Z'; }
php
{ "resource": "" }
q246551
Document.getPathFromEllipse
validation
protected function getPathFromEllipse(SimpleXMLElement $ellipse){ $mult = 0.55228475; return 'M'.($ellipse['cx']-$ellipse['rx']).' '.$ellipse['cy']. 'C'.($ellipse['cx']-$ellipse['rx']).' '.($ellipse['cy']-$ellipse['ry']*$mult).' '.($ellipse['cx']-$ellipse['rx']*$mult).' '.($ellipse['cy']-$ellipse['ry']).' '.$ellipse['cx'].' '.($ellipse['cy']-$ellipse['ry']). 'C'.($ellipse['cx']+$ellipse['rx']*$mult).' '.($ellipse['cy']-$ellipse['ry']).' '.($ellipse['cx']+$ellipse['rx']).' '.($ellipse['cy']-$ellipse['ry']*$mult).' '.($ellipse['cx']+$ellipse['rx']).' '.$ellipse['cy']. 'C'.($ellipse['cx']+$ellipse['rx']).' '.($ellipse['cy']+$ellipse['ry']*$mult).' '.($ellipse['cx']+$ellipse['rx']*$mult).' '.($ellipse['cy']+$ellipse['ry']).' '.$ellipse['cx'].' '.($ellipse['cy']+$ellipse['ry']). 'C'.($ellipse['cx']-$ellipse['rx']*$mult).' '.($ellipse['cy']+$ellipse['ry']).' '.($ellipse['cx']-$ellipse['rx']).' '.($ellipse['cy']+$ellipse['ry']*$mult).' '.($ellipse['cx']-$ellipse['rx']).' '.$ellipse['cy']. 'Z'; }
php
{ "resource": "" }
q246552
CreateInfoCommand.execute
validation
protected function execute(InputInterface $input, OutputInterface $output){ $fontFile = realpath($input->getArgument('font-file')); if($fontFile === false || !file_exists($fontFile)){ throw new \InvalidArgumentException('"'.$input->getArgument('font-file').'" does not exist'); } $outputFile = $input->getArgument('output-file'); $generator = new IconFontGenerator; $output->writeln('reading font file from "'.$fontFile.'" ...'); $generator->generateFromFont(new Font(array(), file_get_contents($fontFile))); $output->writeln('writing HTML file to "'.$outputFile.'" ...'); if ($input->getOption('as-list')) { $html = $this->getHTMLListFromGenerator($generator, basename($fontFile)); } else { $html = $this->getHTMLFromGenerator($generator, basename($fontFile)); } file_put_contents($outputFile, $html); $output->getFormatter()->setStyle('success', new OutputFormatterStyle(null, null, array('bold', 'reverse'))); $output->writeln('<success>created HTML info page successfully</success>'); }
php
{ "resource": "" }
q246553
CreateInfoCommand.getHTMLFromGenerator
validation
protected function getHTMLFromGenerator(IconFontGenerator $generator, $fontFile){ $fontOptions = $generator->getFont()->getOptions(); $html = '<!doctype html> <html> <head> <title>'.htmlspecialchars($fontOptions['id']).'</title> <style> @font-face { font-family: "'.$fontOptions['id'].'"; src: url("'.$fontFile.'") format("svg"), url("'.substr($fontFile, 0, -4).'.woff") format("woff"), url("'.substr($fontFile, 0, -4).'.ttf") format("truetype"); font-weight: normal; font-style: normal; } body { font-family: sans-serif; color: #444; line-height: 1.5; font-size: 16px; padding: 20px; } * { -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; margin: 0; paddin: 0; } .glyph{ display: inline-block; width: 120px; margin: 10px; text-align: center; vertical-align: top; background: #eee; border-radius: 10px; box-shadow: 1px 1px 5px rgba(0, 0, 0, .2); } .glyph-icon{ padding: 10px; display: block; font-family: "'.$fontOptions['id'].'"; font-size: 64px; line-height: 1; } .glyph-icon:before{ content: attr(data-icon); } .class-name{ font-size: 12px; } .glyph > input{ display: block; width: 100px; margin: 5px auto; text-align: center; font-size: 12px; cursor: text; } .glyph > input.icon-input{ font-family: "'.$fontOptions['id'].'"; font-size: 16px; margin-bottom: 10px; } </style> </head> <body> <section id="glyphs">'; $glyphNames = $generator->getGlyphNames(); asort($glyphNames); foreach($glyphNames as $unicode => $glyph){ $html .= '<div class="glyph"> <div class="glyph-icon" data-icon="&#x'.$unicode.';"></div> <div class="class-name">icon-'.$glyph.'</div> <input type="text" readonly="readonly" value="&amp;#x'.$unicode.';" /> <input type="text" readonly="readonly" value="\\'.$unicode.'" /> <input type="text" readonly="readonly" value="&#x'.$unicode.';" class="icon-input" /> </div>'; } $html .= '</section> </body> </html>'; return $html; }
php
{ "resource": "" }
q246554
CreateInfoCommand.getHTMLListFromGenerator
validation
protected function getHTMLListFromGenerator(IconFontGenerator $generator, $fontFile){ $fontOptions = $generator->getFont()->getOptions(); $html = '<ul>'; $glyphNames = $generator->getGlyphNames(); asort($glyphNames); foreach($glyphNames as $unicode => $glyph){ $html .= "\n\t" . '<li data-icon="&#x'.$unicode.';" title="' . htmlspecialchars($glyph) . '">' . htmlspecialchars($glyph) . '</li>'; } $html .= "\n" . '</ul>' . "\n"; return $html; }
php
{ "resource": "" }
q246555
Recovery.generate
validation
protected function generate() { $this->reset(); foreach (range(1, $this->getCount()) as $counter) { $this->codes[] = $this->generateBlocks(); } return $this->codes; }
php
{ "resource": "" }
q246556
Recovery.generateBlocks
validation
protected function generateBlocks() { $blocks = []; foreach (range(1, $this->getBlocks()) as $counter) { $blocks[] = $this->generateChars(); } return implode($this->blockSeparator, $blocks); }
php
{ "resource": "" }
q246557
Recovery.toCollection
validation
public function toCollection() { if (function_exists($this->collectionFunction)) { return call_user_func($this->collectionFunction, $this->toArray()); } throw new \Exception( "Function {$this->collectionFunction}() was not found. " . "You probably need to install a suggested package?" ); }
php
{ "resource": "" }
q246558
Process.run
validation
public function run() { $signalHandler = $this->getSignalHandler(); $signalHandler->registerHandler(SIGTERM, function () { $this->shouldShutdown = true; }); $this->sharedMemory[self::STARTED_MARKER] = true; /** @var callable $callable */ $callable = $this->callable; $callable($this); }
php
{ "resource": "" }
q246559
Process.wait
validation
public function wait() { $this->internalWait(); $event = $this->isSuccessExit() ? 'success' : 'error'; $this->internalEmit('exit', $this->pid); $this->internalEmit($event); return $this; }
php
{ "resource": "" }
q246560
Process.isSuccessExit
validation
public function isSuccessExit() { $this->exitCode = pcntl_wexitstatus($this->status); return (pcntl_wifexited($this->status) && ($this->exitCode === 0)); }
php
{ "resource": "" }
q246561
Process.waitReady
validation
public function waitReady() { $x = 0; while ($x++ < 100) { usleep(self::WAIT_IDLE); if ($this[self::STARTED_MARKER] === true) { return $this; } } throw new \RuntimeException('Wait process running timeout for child pid ' . $this->getPid()); }
php
{ "resource": "" }
q246562
Semaphore.remove
validation
public function remove() { if (is_resource($this->mutex)) { sem_remove($this->mutex); } if (file_exists($this->file)) { unlink($this->file); } }
php
{ "resource": "" }
q246563
Semaphore.lockExecute
validation
public function lockExecute(callable $callable) { $this->isAcquired = $this->acquire(); $result = $callable(); $this->isAcquired = $this->release(); return $result; }
php
{ "resource": "" }
q246564
SignalHandler.registerHandler
validation
public function registerHandler($signal, $handler) { if (!is_callable($handler)) { throw new \InvalidArgumentException('The handler is not callable'); } if (!isset($this->handlers[$signal])) { $this->handlers[$signal] = []; if (!pcntl_signal($signal, [$this, 'handleSignal'])) { throw new \RuntimeException(sprintf('Could not register signal %d with pcntl_signal', $signal)); }; }; $this->handlers[$signal][] = $handler; return $this; }
php
{ "resource": "" }
q246565
SignalHandler.dispatch
validation
public function dispatch() { pcntl_signal_dispatch(); foreach ($this->signalQueue as $signal) { foreach ($this->handlers[$signal] as &$callable) { call_user_func($callable, $signal); } } return $this; }
php
{ "resource": "" }
q246566
SharedMemory.lockExecute
validation
protected function lockExecute(callable $task) { if($this->mutex->isAcquired()) { return $task(); } return $this->mutex->lockExecute($task); }
php
{ "resource": "" }
q246567
Profile.begin
validation
public function begin(string $profile) { Craft::beginProfile( $profile, Craft::t('twig-profiler', self::CATEGORY_PREFIX) .TwigProfiler::$renderingTemplate ); }
php
{ "resource": "" }
q246568
Profile.end
validation
public function end(string $profile) { Craft::endProfile( $profile, Craft::t('twig-profiler', self::CATEGORY_PREFIX) .TwigProfiler::$renderingTemplate ); }
php
{ "resource": "" }
q246569
LinuxProvider.getCpuinfoByLsCpu
validation
public function getCpuinfoByLsCpu() { if (!$this->cpuInfoByLsCpu) { $lscpu = shell_exec('lscpu'); $lscpu = explode("\n", $lscpu); $values = []; foreach ($lscpu as $v) { $v = array_map('trim', explode(':', $v)); if (isset($v[0], $v[1])) { $values[$v[0]] = $v[1]; } } $this->cpuInfoByLsCpu = $values; } return $this->cpuInfoByLsCpu; }
php
{ "resource": "" }
q246570
Parser.push
validation
final public function push(string $data) { if ($this->generator === null) { throw new \Error("The parser is no longer writable"); } $this->buffer .= $data; $end = false; try { while ($this->buffer !== "") { if (\is_int($this->delimiter)) { if (\strlen($this->buffer) < $this->delimiter) { break; // Too few bytes in buffer. } $send = \substr($this->buffer, 0, $this->delimiter); $this->buffer = \substr($this->buffer, $this->delimiter); } elseif (\is_string($this->delimiter)) { if (($position = \strpos($this->buffer, $this->delimiter)) === false) { break; } $send = \substr($this->buffer, 0, $position); $this->buffer = \substr($this->buffer, $position + \strlen($this->delimiter)); } else { $send = $this->buffer; $this->buffer = ""; } $this->delimiter = $this->generator->send($send); if (!$this->generator->valid()) { $end = true; break; } if ($this->delimiter !== null && (!\is_int($this->delimiter) || $this->delimiter <= 0) && (!\is_string($this->delimiter) || !\strlen($this->delimiter)) ) { throw new InvalidDelimiterError( $this->generator, \sprintf( "Invalid value yielded: Expected NULL, an int greater than 0, or a non-empty string; %s given", \is_object($this->delimiter) ? \sprintf("instance of %s", \get_class($this->delimiter)) : \gettype($this->delimiter) ) ); } } } catch (\Throwable $exception) { $end = true; throw $exception; } finally { if ($end) { $this->generator = null; } } }
php
{ "resource": "" }
q246571
Detector.getEmojiPattern
validation
public function getEmojiPattern() { if (null === self::$emojiPattern) { $codeString = ''; foreach ($this->getEmojiCodeList() as $code) { if (is_array($code)) { $first = dechex(array_shift($code)); $last = dechex(array_pop($code)); $codeString .= '\x{' . $first . '}-\x{' . $last . '}'; } else { $codeString .= '\x{' . dechex($code) . '}'; } } self::$emojiPattern = "/[$codeString]/u"; } return self::$emojiPattern; }
php
{ "resource": "" }
q246572
Detector.getEmojiCodeList
validation
public function getEmojiCodeList() { return [ // Various 'older' charactes, dingbats etc. which over time have // received an additional emoji representation. 0x203c, 0x2049, 0x2122, 0x2139, range(0x2194, 0x2199), range(0x21a9, 0x21aa), range(0x231a, 0x231b), 0x2328, range(0x23ce, 0x23cf), range(0x23e9, 0x23f3), range(0x23f8, 0x23fa), 0x24c2, range(0x25aa, 0x25ab), 0x25b6, 0x25c0, range(0x25fb, 0x25fe), range(0x2600, 0x2604), 0x260e, 0x2611, range(0x2614, 0x2615), 0x2618, 0x261d, 0x2620, range(0x2622, 0x2623), 0x2626, 0x262a, range(0x262e, 0x262f), range(0x2638, 0x263a), 0x2640, 0x2642, range(0x2648, 0x2653), 0x2660, 0x2663, range(0x2665, 0x2666), 0x2668, 0x267b, 0x267f, range(0x2692, 0x2697), 0x2699, range(0x269b, 0x269c), range(0x26a0, 0x26a1), range(0x26aa, 0x26ab), range(0x26b0, 0x26b1), range(0x26bd, 0x26be), range(0x26c4, 0x26c5), 0x26c8, range(0x26ce, 0x26cf), 0x26d1, range(0x26d3, 0x26d4), range(0x26e9, 0x26ea), range(0x26f0, 0x26f5), range(0x26f7, 0x26fa), 0x26fd, 0x2702, 0x2705, range(0x2708, 0x270d), 0x270f, 0x2712, 0x2714, 0x2716, 0x271d, 0x2721, 0x2728, range(0x2733, 0x2734), 0x2744, 0x2747, 0x274c, 0x274e, range(0x2753, 0x2755), 0x2757, range(0x2763, 0x2764), range(0x2795, 0x2797), 0x27a1, 0x27b0, 0x27bf, range(0x2934, 0x2935), range(0x2b05, 0x2b07), range(0x2b1b, 0x2b1c), 0x2b50, 0x2b55, 0x3030, 0x303d, 0x3297, 0x3299, // Modifier for emoji sequences. 0x200d, 0x20e3, 0xfe0f, // 'Regular' emoji unicode space, containing the bulk of them. range(0x1f000, 0x1f9cf) ]; }
php
{ "resource": "" }
q246573
Haikunator.haikunate
validation
public static function haikunate(array $params = []) { $defaults = [ "delimiter" => "-", "tokenLength" => 4, "tokenHex" => false, "tokenChars" => "0123456789", ]; $params = array_merge($defaults, $params); if ($params["tokenHex"] == true) { $params["tokenChars"] = "0123456789abcdef"; } $adjective = self::$ADJECTIVES[mt_rand(0, count(self::$ADJECTIVES) - 1)]; $noun = self::$NOUNS[mt_rand(0, count(self::$NOUNS) - 1)]; $token = ""; for ($i = 0; $i < $params["tokenLength"]; $i++) { $token .= $params["tokenChars"][mt_rand(0, strlen($params["tokenChars"]) - 1)]; } $sections = [$adjective, $noun, $token]; return implode($params["delimiter"], array_filter($sections)); }
php
{ "resource": "" }
q246574
SoapClient.setSignature
validation
public function setSignature($parameters, $privateKey, $service, $endpoint, $timestamp, $nonce) { $this->__setCookie('signature', rawurlencode($this->sign($privateKey, array_merge($parameters, [ '__service' => $service, '__hostname' => $endpoint, '__timestamp' => $timestamp, '__nonce' => $nonce, ])))); }
php
{ "resource": "" }
q246575
SoapClient.sign
validation
protected function sign($privateKey, $parameters) { if (preg_match('/-----BEGIN (RSA )?PRIVATE KEY-----(.*)-----END (RSA )?PRIVATE KEY-----/si', $privateKey, $matches)) { $key = $matches[2]; $key = preg_replace('/\s*/s', '', $key); $key = chunk_split($key, 64, "\n"); $key = "-----BEGIN PRIVATE KEY-----\n".$key.'-----END PRIVATE KEY-----'; $digest = $this->sha512Asn1($this->encodeParameters($parameters)); if (@openssl_private_encrypt($digest, $signature, $key)) { return base64_encode($signature); } throw new \InvalidArgumentException('Unable to sign the request, this has to do with the provided (invalid) private key.'); } throw new \InvalidArgumentException('Invalid private key.'); }
php
{ "resource": "" }
q246576
SoapClient.sha512Asn1
validation
protected function sha512Asn1($data) { $digest = hash('sha512', $data, true); // this ASN1 header is sha512 specific $asn1 = chr(0x30).chr(0x51); $asn1 .= chr(0x30).chr(0x0d); $asn1 .= chr(0x06).chr(0x09); $asn1 .= chr(0x60).chr(0x86).chr(0x48).chr(0x01).chr(0x65); $asn1 .= chr(0x03).chr(0x04); $asn1 .= chr(0x02).chr(0x03); $asn1 .= chr(0x05).chr(0x00); $asn1 .= chr(0x04).chr(0x40); $asn1 .= $digest; return $asn1; }
php
{ "resource": "" }
q246577
SoapClient.encodeParameters
validation
protected function encodeParameters($parameters, $keyPrefix = null) { if (!is_array($parameters) && !is_object($parameters)) { return rawurlencode($parameters); } $encodedData = []; foreach ($parameters as $key => $value) { $encodedKey = is_null($keyPrefix) ? rawurlencode($key) : $keyPrefix.'['.rawurlencode($key).']'; if (is_array($value) || is_object($value)) { $encodedData[] = $this->encodeParameters($value, $encodedKey); } else { $encodedData[] = $encodedKey.'='.rawurlencode($value); } } return implode('&', $encodedData); }
php
{ "resource": "" }
q246578
Client.api
validation
public function api($name) { switch ($name) { case 'domain': case 'domain_service': case 'domainService': return new Api\Domain($this); case 'colocation': case 'colocation_service': case 'colocationService': return new Api\Colocation($this); case 'forward': case 'forward_service': case 'forwardService': return new Api\Forward($this); case 'vps': case 'vps_service': case 'vpsService': return new Api\Vps($this); case 'hosting': case 'web_hosting': case 'webHosting': case 'web_hosting_service': case 'webHostingService': return new Api\WebHosting($this); case 'haip': case 'ha_ip': case 'ha_ip_service': case 'haip_service': case 'haipService': return new Api\Haip($this); default: throw new \InvalidArgumentException(sprintf('Undefined api instance called: [%s]', $name)); } }
php
{ "resource": "" }
q246579
Client.buildSoapClient
validation
public function buildSoapClient($service) { $director = new Soap\SoapClientDirector($this->username, $this->mode, $this->endpoint); switch ($service) { case 'DomainService': return $director->build(new Soap\Builder\DomainSoapClientBuilder); case 'ColocationService': return $director->build(new Soap\Builder\ColocationSoapClientBuilder); case 'ForwardService': return $director->build(new Soap\Builder\ForwardSoapClientBuilder); case 'VpsService': return $director->build(new Soap\Builder\VpsSoapClientBuilder); case 'WebhostingService': return $director->build(new Soap\Builder\WebHostingSoapClientBuilder); case 'HaipService': return $director->build(new Soap\Builder\HaipSoapClientBuilder); default: throw new \InvalidArgumentException(sprintf('Undefined soap client service builder called: [%s]', $service)); } }
php
{ "resource": "" }
q246580
Client.setMode
validation
public function setMode($mode) { if (!in_array($mode, $this->acceptedModes)) { throw new \InvalidArgumentException(sprintf('Invalid mode: [%s]', $mode)); } $this->mode = $mode; }
php
{ "resource": "" }
q246581
Haip.setBalancingMode
validation
public function setBalancingMode($haipName, $balancingMode, $cookieName = '') { return $this->call(self::SERVICE, 'setBalancingMode', [$haipName, $balancingMode, $cookieName]); }
php
{ "resource": "" }
q246582
AbstractApi.call
validation
protected function call($service, $method, array $parameters = []) { return $this->getSoapClient($service, $method, $parameters)->__call($method, $parameters); }
php
{ "resource": "" }
q246583
AbstractApi.getSoapClient
validation
private function getSoapClient($service, $method, array $parameters) { $timestamp = time(); $nonce = uniqid(null, true); $soapClient = $this->client->buildSoapClient($service); $soapClient->setTimestamp($timestamp); $soapClient->setNonce($nonce); $soapClient->setSignature(array_merge($parameters, ['__method' => $method]), $this->client->getPrivateKey(), $service, $this->client->getEndpoint(), $timestamp, $nonce); return $soapClient; }
php
{ "resource": "" }
q246584
SoapClientDirector.build
validation
public function build(SoapClientBuilderInterface $builder) { $builder->createWsdl($this->endpoint); $builder->createSoapClient(); $builder->setLogin($this->login); $builder->setMode($this->mode); $builder->setClientVersion(self::CLIENT_VERSION); return $builder->getSoapClient(); }
php
{ "resource": "" }
q246585
SoapClientFactory.make
validation
public function make($wsdl, array $classMap = []) { return new SoapClient($wsdl, [ 'trace' => true, 'exceptions' => true, 'encoding' => 'utf-8', 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, 'classmap' => $classMap, 'cache_wsdl' => WSDL_CACHE_MEMORY, ]); }
php
{ "resource": "" }
q246586
Colocation.requestAccess
validation
public function requestAccess($when, $duration, array $visitors, $phoneNumber) { return $this->call(self::SERVICE, 'requestAccess', [$when, $duration, $visitors, $phoneNumber]); }
php
{ "resource": "" }
q246587
Colocation.requestRemoteHands
validation
public function requestRemoteHands($colocationName, $contactName, $phoneNumber, $expectedDuration, $instructions) { return $this->call(self::SERVICE, 'requestRemoteHands', [$colocationName, $contactName, $phoneNumber, $expectedDuration, $instructions]); }
php
{ "resource": "" }
q246588
Vps.revertSnapshotToOtherVps
validation
public function revertSnapshotToOtherVps($sourceVpsName, $snapshotName, $destinationVpsName) { return $this->call(self::SERVICE, 'revertSnapshotToOtherVps', [$sourceVpsName, $snapshotName, $destinationVpsName]); }
php
{ "resource": "" }
q246589
Vps.installOperatingSystem
validation
public function installOperatingSystem($vpsName, $operatingSystemName, $hostname) { return $this->call(self::SERVICE, 'installOperatingSystem', [$vpsName, $operatingSystemName, $hostname]); }
php
{ "resource": "" }
q246590
Vps.installOperatingSystemUnattended
validation
public function installOperatingSystemUnattended($vpsName, $operatingSystemName, $base64InstallText) { return $this->call(self::SERVICE, 'installOperatingSystemUnattended', [$vpsName, $operatingSystemName, $base64InstallText]); }
php
{ "resource": "" }
q246591
WebHosting.setMailBoxPassword
validation
public function setMailBoxPassword($domainName, $mailBox, $password) { return $this->call(self::SERVICE, 'setMailBoxPassword', [$domainName, $mailBox, $password]); }
php
{ "resource": "" }
q246592
WebHosting.setDatabasePassword
validation
public function setDatabasePassword($domainName, $database, $password) { return $this->call(self::SERVICE, 'setDatabasePassword', [$domainName, $database, $password]); }
php
{ "resource": "" }
q246593
Site.getSupportedNamespaces
validation
public function getSupportedNamespaces() { if ( empty( $this->data->namespaces ) || ! is_array( $this->data->namespaces ) ) { return array(); } return $this->data->namespaces; }
php
{ "resource": "" }
q246594
Site.getSupportedAuthentication
validation
public function getSupportedAuthentication() { if ( empty( $this->data->authentication ) || empty( $this->data->authentication ) ) { return array(); } return (array) $this->data->authentication; }
php
{ "resource": "" }
q246595
Site.getAuthenticationData
validation
public function getAuthenticationData( $method ) { if ( ! $this->supportsAuthentication( $method ) ) { return null; } $authentication = $this->getSupportedAuthentication(); return $authentication[ $method ]; }
php
{ "resource": "" }
q246596
OpenApiGuesser.getClassFromOperation
validation
protected function getClassFromOperation($name, Operation $operation = null, $reference, $registry) { if ($operation === null) { return; } if ($operation->getParameters()) { foreach ($operation->getParameters() as $key => $parameter) { if ($parameter instanceof BodyParameter) { $this->chainGuesser->guessClass($parameter->getSchema(), $name . 'Body', $reference . '/parameters/' . $key, $registry); } } } if ($operation->getResponses()) { foreach ($operation->getResponses() as $status => $response) { if ($response instanceof Response) { $this->chainGuesser->guessClass($response->getSchema(), $name.'Response'.$status, $reference . '/responses/' . $status, $registry); } } } }
php
{ "resource": "" }
q246597
SchemaParser.parseSchema
validation
public function parseSchema($openApiSpec) { $openApiSpecContents = file_get_contents($openApiSpec); $schemaClass = self::OPEN_API_MODEL; $schema = null; $jsonException = null; $yamlException = null; try { return $this->serializer->deserialize( $openApiSpecContents, $schemaClass, self::CONTENT_TYPE_JSON, [ 'document-origin' => $openApiSpec ] ); } catch (\Exception $exception) { $jsonException = $exception; } $content = Yaml::parse($openApiSpecContents, Yaml::PARSE_OBJECT | Yaml::PARSE_OBJECT_FOR_MAP | Yaml::PARSE_DATETIME | Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE); $openApiSpecContents = json_encode($content); return $this->serializer->deserialize( $openApiSpecContents, $schemaClass, self::CONTENT_TYPE_JSON, [ 'document-origin' => $openApiSpec ] ); }
php
{ "resource": "" }
q246598
InputGeneratorTrait.createQueryParamStatements
validation
protected function createQueryParamStatements(Operation $operation) { $queryParamDocumentation = []; $queryParamVariable = new Expr\Variable('queryParam'); $queryParamStatements = [ new Expr\Assign($queryParamVariable, new Expr\New_(new Name('QueryParam'))) ]; if ($operation->getOperation()->getParameters()) { foreach ($operation->getOperation()->getParameters() as $parameter) { if ($parameter instanceof Reference) { $parameter = $this->resolveParameter($parameter); } if ($parameter instanceof FormDataParameterSubSchema) { $queryParamStatements = array_merge($queryParamStatements, $this->formDataParameterGenerator->generateQueryParamStatements($parameter, $queryParamVariable)); $queryParamDocumentation[] = $this->formDataParameterGenerator->generateQueryDocParameter($parameter); } if ($parameter instanceof HeaderParameterSubSchema) { $queryParamStatements = array_merge($queryParamStatements, $this->headerParameterGenerator->generateQueryParamStatements($parameter, $queryParamVariable)); $queryParamDocumentation[] = $this->headerParameterGenerator->generateQueryDocParameter($parameter); } if ($parameter instanceof QueryParameterSubSchema) { $queryParamStatements = array_merge($queryParamStatements, $this->queryParameterGenerator->generateQueryParamStatements($parameter, $queryParamVariable)); $queryParamDocumentation[] = $this->queryParameterGenerator->generateQueryDocParameter($parameter); } } } return [$queryParamDocumentation, $queryParamStatements, $queryParamVariable]; }
php
{ "resource": "" }
q246599
InputGeneratorTrait.createParameters
validation
protected function createParameters(Operation $operation, $queryParamDocumentation, Context $context) { $documentationParams = []; $methodParameters = []; if ($operation->getOperation()->getParameters()) { foreach ($operation->getOperation()->getParameters() as $key => $parameter) { if ($parameter instanceof Reference) { $parameter = $this->resolveParameter($parameter); } if ($parameter instanceof PathParameterSubSchema) { $methodParameters[] = $this->pathParameterGenerator->generateMethodParameter($parameter, $context, $operation->getReference() . '/parameters/' . $key); $documentationParams[] = sprintf(' * @param %s', $this->pathParameterGenerator->generateDocParameter($parameter, $context, $operation->getReference() . '/parameters/' . $key)); } } foreach ($operation->getOperation()->getParameters() as $key => $parameter) { if ($parameter instanceof Reference) { $parameter = $this->resolveParameter($parameter); } if ($parameter instanceof BodyParameter) { $methodParameters[] = $this->bodyParameterGenerator->generateMethodParameter($parameter, $context, $operation->getReference() . '/parameters/' . $key); $documentationParams[] = sprintf(' * @param %s', $this->bodyParameterGenerator->generateDocParameter($parameter, $context, $operation->getReference() . '/parameters/' . $key)); } } } if (!empty($queryParamDocumentation)) { $documentationParams[] = " * @param array \$parameters {"; $documentationParams = array_merge($documentationParams, array_map(function ($doc) { return " * " . $doc; }, $queryParamDocumentation)); $documentationParams[] = " * }"; } else { $documentationParams[] = " * @param array \$parameters List of parameters"; } $documentationParams[] = " * @param string \$fetch Fetch mode (object or response)"; $methodParameters[] = new Param('parameters', new Expr\Array_()); $methodParameters[] = new Param('fetch', new Expr\ConstFetch(new Name('self::FETCH_OBJECT'))); return [$documentationParams, $methodParameters]; }
php
{ "resource": "" }