_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q265500
SerializerExceptionRenderer.renderValidationSerializerException
test
protected function renderValidationSerializerException(ValidationBaseSerializerException $error) { if ($this->isJsonApiRequest()) { return $this->renderValidationSerializerAsJsonApi($error); } if ($this->isJsonRequest()) { return $this->renderValidationSerializerAsJson($error); } return $this->default...
php
{ "resource": "" }
q265501
SerializerExceptionRenderer.renderHttpAsJson
test
protected function renderHttpAsJson(HttpException $error) { // Set the view class as json and render as json $this->controller->viewClass = 'Json'; $this->controller->response->type('json'); $url = $this->controller->request->here(); $code = ($error->getCode() >= 400 && $error->getCode() < 506) ? $error->get...
php
{ "resource": "" }
q265502
SerializerExceptionRenderer.renderHttpAsJsonApi
test
protected function renderHttpAsJsonApi(HttpException $error) { // Add a response type for JSON API $this->controller->response->type(array('jsonapi' => 'application/vnd.api+json')); // Set the controller to response as JSON API $this->controller->response->type('jsonapi'); // Set the correct Status Code $th...
php
{ "resource": "" }
q265503
SerializerExceptionRenderer.renderCakeAsJson
test
protected function renderCakeAsJson(CakeException $error) { // Set the view class as json and render as json $this->controller->viewClass = 'Json'; $this->controller->response->type('json'); $url = $this->controller->request->here(); $code = ($error->getCode() >= 400 && $error->getCode() < 506) ? $error->get...
php
{ "resource": "" }
q265504
SerializerExceptionRenderer.renderCakeAsJsonApi
test
protected function renderCakeAsJsonApi(CakeException $error) { // Add a response type for JSON API $this->controller->response->type(array('jsonapi' => 'application/vnd.api+json')); // Set the controller to response as JSON API $this->controller->response->type('jsonapi'); // Set the correct Status Code $th...
php
{ "resource": "" }
q265505
SerializerExceptionRenderer.defaultSerializerRender
test
protected function defaultSerializerRender(BaseSerializerException $error) { $this->controller->response->statusCode($error->status()); // set the errors object to match JsonApi's expectations $this->controller->set('id', $error->id()); $this->controller->set('href', $error->href()); $this->controller->set('...
php
{ "resource": "" }
q265506
SerializerExceptionRenderer.renderSerializerAsJson
test
protected function renderSerializerAsJson(BaseSerializerException $error) { // Set the view class as json and render as json $this->controller->viewClass = 'Json'; $this->controller->response->type('json'); $this->controller->response->statusCode($error->status()); // set all the values we have from our exce...
php
{ "resource": "" }
q265507
SerializerExceptionRenderer.renderSerializerAsJsonApi
test
protected function renderSerializerAsJsonApi(BaseSerializerException $error) { // Add a response type for JSON API $this->controller->response->type(array('jsonapi' => 'application/vnd.api+json')); // Set the controller to response as JSON API $this->controller->response->type('jsonapi'); // Set the correct S...
php
{ "resource": "" }
q265508
SerializerExceptionRenderer.defaultValidationSerializerRender
test
protected function defaultValidationSerializerRender(ValidationBaseSerializerException $error) { $this->addHttpCodes(); $this->controller->response->statusCode($error->status()); // set the errors object to match JsonApi's expectations $this->controller->set('title', $error->title()); $this->controller->set(...
php
{ "resource": "" }
q265509
SerializerExceptionRenderer.renderValidationSerializerAsJson
test
protected function renderValidationSerializerAsJson(ValidationBaseSerializerException $error) { // Set the view class as json and render as json $this->controller->viewClass = 'Json'; $this->controller->response->type('json'); $this->addHttpCodes(); $this->controller->response->statusCode($error->status()); ...
php
{ "resource": "" }
q265510
SerializerExceptionRenderer.renderValidationSerializerAsJsonApi
test
protected function renderValidationSerializerAsJsonApi(ValidationBaseSerializerException $error) { // Add a response type for JSON API $this->controller->response->type(array('jsonapi' => 'application/vnd.api+json')); // Set the controller to response as JSON API $this->controller->response->type('jsonapi'); ...
php
{ "resource": "" }
q265511
SessionManager.openSessionByID
test
public function openSessionByID($sessionID, $userProfile = null) { $session = $this->driver->openSessionByID( $sessionID, $this, $userProfile ); if ($session == null) { $this->invalidSessionAccessed(); } return $sessio...
php
{ "resource": "" }
q265512
SessionManager.createSession
test
function createSession(array $cookieData, $userProfile = null) { if (!array_key_exists($this->sessionConfig->getSessionName(), $cookieData)) { return $this->driver->createSession($this, $userProfile); } $sessionID = $cookieData[$this->sessionConfig->getSessionName()]; $e...
php
{ "resource": "" }
q265513
Title.prepareText
test
protected function prepareText(&$text) { // check if it is a string if (!is_string($text)) { // it is not, raise a flag return false; } // trim any front or ending spaces $text = trim($text); // if there is no text, no need to continue ...
php
{ "resource": "" }
q265514
Title.display
test
public function display($text) { // prepare the text for the particular style of text // if it returns false, the text is bad if (!$this->prepareText($text)) { // chaining return $this; } // justify the text $text = $this->clio->justify($text, $...
php
{ "resource": "" }
q265515
Title.displayEmptyLines
test
private function displayEmptyLines($lines) { // create an empty line $emptyLine = str_pad(" ", $this->clio->getWidth()); // if there is more than one line for ($i = 0; $i < $lines; ++$i) { // generate an empty line $this->clio->line($emptyLine); } ...
php
{ "resource": "" }
q265516
ConsoleProvider.init
test
public function init(Application $cli, $commands = []) { $this->cli = $cli; $this->commands = $commands; }
php
{ "resource": "" }
q265517
KernelSubscriber.onKernelResponse
test
public function onKernelResponse(FilterResponseEvent $event) { if ($event->isMasterRequest()) { $request = $event->getRequest(); $response = $event->getResponse(); if ($request->isXmlHttpRequest() && !$response->isRedirection()) { // flash messages ...
php
{ "resource": "" }
q265518
DebugBarProvider.init
test
public function init(StandardDebugBar $debugBar){ $this->debugBar = $debugBar; $this->debugBarRenderer = $debugBar->getJavascriptRenderer(); }
php
{ "resource": "" }
q265519
SessionManager.sessionStart
test
public static function sessionStart($name, $lifetime = 0, $path = '/', $domain = null, $secure = null) { // Set the cookie name before we start. session_name($name . '_Session'); // Set the domain to default to the current domain. $domain = isset($domain) ? $domain : $_SERVER['SERVE...
php
{ "resource": "" }
q265520
SessionManager.preventHijacking
test
private static function preventHijacking() { if (!isset($_SESSION['ipAddress']) || !isset($_SESSION['userAgent'])) { return false; } if ($_SESSION['ipAddress'] != $_SERVER['REMOTE_ADDR']) { return false; } if ($_SESSION['userAgent'] != $_SERVER['HTTP_U...
php
{ "resource": "" }
q265521
SessionManager.regenerateSession
test
private static function regenerateSession() { // If this session is obsolete it means there already is a new id if (isset($_SESSION['OBSOLETE']) && $_SESSION['OBSOLETE'] == true) { return; } // Set current session to expire in 10 seconds $_SESSION['OBSOLETE'] = ...
php
{ "resource": "" }
q265522
SessionManager.validateSession
test
private static function validateSession() { if (isset($_SESSION['OBSOLETE']) && !isset($_SESSION['EXPIRES'])) { return false; } if (isset($_SESSION['EXPIRES']) && $_SESSION['EXPIRES'] < time()) { return false; } return true; }
php
{ "resource": "" }
q265523
Network.linkLayers
test
public function linkLayers() { for ($i = 1; $i < count($this->structure); $i++) { $this->layers[$i]->bind($this->layers[$i - 1]); } }
php
{ "resource": "" }
q265524
Request._paramBackbone
test
protected function _paramBackbone($key) { if (isset($this->_request['model'])) { $model = json_decode($this->_request['model'], true); return $model[$key]; } return null; }
php
{ "resource": "" }
q265525
publish.register
test
public static function register( $px, $json ){ // プラグイン設定の初期化 if( !is_object(@$json) ){ $json = json_decode('{}'); } if( !is_array(@$json->paths_ignore) ){ $json->paths_ignore = array(); } // var_dump($json); $self = new self( $px, $json ); $px->pxcmd()->register('publish', array($...
php
{ "resource": "" }
q265526
publish.cli_header
test
private function cli_header(){ ob_start(); print $this->px->pxcmd()->get_cli_header(); print 'publish directory(tmp): '.$this->path_tmp_publish."\n"; print 'lockfile: '.$this->path_lockfile."\n"; print 'publish directory: '.$this->path_publish_dir."\n"; print 'domain: '.$this->domain."\n"; print 'd...
php
{ "resource": "" }
q265527
ExampleTokenParser.parseRawBody
test
private function parseRawBody($startLine) { $templateSource = \file_get_contents($this->parser->getStream()->getSourceContext()->getPath()); // parse tag contents \preg_match( '/\\s*\\{%\s*example\\s*%\\}(.*?)\\s*\\{%\\s*endexample\\s*%\\}/s', \implode( ...
php
{ "resource": "" }
q265528
ExampleTokenParser.removeExtraIndentation
test
private function removeExtraIndentation($string) { $lines = \preg_split('/\\n|\\r\\n?/', $string); // determine indentation length $indentLen = null; for ($i = 0; isset($lines[$i]); ++$i) { if ('' !== \trim($lines[$i])) { \preg_match('/^\\s*/', $lines[$i]...
php
{ "resource": "" }
q265529
CorrelationIdHTTPlug.handleRequest
test
public function handleRequest(RequestInterface $request, callable $next, callable $first) { $headers = [ $this->correlationEntryName->parent() => $this->requestIdentifier->current(), $this->correlationEntryName->root() => $this->selectBestRootHeaderValue(), ]; foreac...
php
{ "resource": "" }
q265530
Url.parseQueryStringFromUrl
test
public static function parseQueryStringFromUrl($url) { $query = (string) parse_url($url, \PHP_URL_QUERY); parse_str($query, $result); return $result; }
php
{ "resource": "" }
q265531
theme.bind
test
private function bind( $px ){ $theme = $this; ob_start(); include( $this->path_tpl.$this->page['layout'].'.html' ); $src = ob_get_clean(); return $src; }
php
{ "resource": "" }
q265532
Route.getMatch
test
public function getMatch($uri) { $expression = $this->pattern->getExpression(); $matches = []; if (preg_match($expression, $uri, $matches) === 0) { return false; } $matches = $this->cleanMatches($matches); $matches = $this->removeNoise($matches); ...
php
{ "resource": "" }
q265533
Justification.getJustificationConstant
test
public static function getJustificationConstant($value) { // if the value coming in, is a integer, ensure it is one of the constants if (is_int($value)) { // get the justification integer values $values = array_values(self::$justificationConstants); // if the integ...
php
{ "resource": "" }
q265534
Crawler.listLocalFiles
test
public function listLocalFiles(){ $files = array(); $dir = dir($this->docsHome); while (false !== ($file = $dir->read())) { if(substr($file, -4)==".pdf"){ $files[] = array('path'=>$this->docsHome, 'fileName'=>$file); } } return $fil...
php
{ "resource": "" }
q265535
Crawler.extractDocumentsLink
test
private function extractDocumentsLink($html){ $links = array(); //preg_match_all("#<a\ href=\"(.*)\.pdf\"#", $html, $matches); preg_match_all("#<a\ href=\"(.*)\"#", $html, $matches); foreach($matches[1] as $f) { $pospdf = strpos($f,".pdf"); if($pospdf !== fa...
php
{ "resource": "" }
q265536
Crawler.excludeLink
test
private function excludeLink($href) { //If href string contains any of the 'words' in $excludes array, return true $excluded = false; foreach ($this->excludes as $word) { if (strpos($href, $word) !== false) { $excluded = true; break; ...
php
{ "resource": "" }
q265537
Crawler.saveFile
test
private function saveFile($filename, $content, $hash){ $ruta = realpath($this->docsHome).'/'.$hash."-".$filename; file_put_contents($ruta, $content); }
php
{ "resource": "" }
q265538
Crawler.existePdf
test
private function existePdf($filename, $hash){ $ruta = realpath($this->docsHome).'/'.$hash."-".$filename; return file_exists($ruta); }
php
{ "resource": "" }
q265539
OrderedList.getNextOrderedNumber
test
protected function getNextOrderedNumber() { // see if the current nesting has an entry in the orderedNumbers array if (array_key_exists($this->nesting, $this->orderedNumbers)) { // it does, so increase the number by 1 $this->orderedNumbers[$this->nesting] = $this->orderedNumber...
php
{ "resource": "" }
q265540
OrderedList.end
test
public function end() { // remove this ordered number tracking for this nesting if (array_key_exists($this->nesting, $this->orderedNumbers)) { // remove the item off the array unset ($this->orderedNumbers[$this->nesting]); } // close the start parent::e...
php
{ "resource": "" }
q265541
Paragraph.display
test
public function display($text) { // if trimming was desired if ($this->trim) { // trim any front or ending spaces $text = trim($text); } // if there is no text, no need to continue if (strlen($text) == 0) { // no need to continue ...
php
{ "resource": "" }
q265542
Paragraph.nl
test
public function nl($count = 1) { // create an empty line for space after $emptyLine = str_pad(" ",$this->clio->getWidth()) . "\n"; // go through each line for ($i=0; $i<$count; ++$i) { // display an empty line, so the styling carries through to the right edge $...
php
{ "resource": "" }
q265543
LinearRegression.fit
test
public function fit(DataSet $dataSet, float $learningRate = 0.0): AlgorithmsInterface { $outputSize = count($dataSet->getMapper()->getOutputKeys()); if ($outputSize !== 1) { throw new WrongUsageException('Linear regression assumes only one output, ' . $outputSize . ' given'); } ...
php
{ "resource": "" }
q265544
LinearRegression.predict
test
public function predict(DataSet $dataSet) { foreach ($dataSet as $instance) { $prediction = $this ->calculator ->calculate(new LinearPrediction($instance->getDimensions(), $this->coefficients)) ->getResult() ->last() ; ...
php
{ "resource": "" }
q265545
PDOHandler.initialize
test
private function initialize() { $this->pdo->exec( 'CREATE TABLE IF NOT EXISTS `'.$this->table.'` ' .'(id INTEGER PRIMARY KEY AUTO_INCREMENT, channel VARCHAR(255),level_name VARCHAR(255), level INTEGER, message LONGTEXT, date DATETIME)' ); //Read out actual columns ...
php
{ "resource": "" }
q265546
PDOHandler.write
test
protected function write(array $record) { if (!$this->initialized) { $this->initialize(); } //'context' contains the array $contentArray = array_merge(array( 'channel' => $record['channel'], 'level' => $record['level'], 'level_name' => ...
php
{ "resource": "" }
q265547
BulletedList.drawListItem
test
protected function drawListItem($bullet, $text) { // determine the blank space indentation $indentation = $this->createIndentation(); // In unordered list, the bullet can be specified $left = $indentation . $bullet; // determine the width of the bullet text $bulletText...
php
{ "resource": "" }
q265548
BulletedList.start
test
public function start($text = null) { // if text was defined and it the first level of nesting if ($text && ($this->nesting === 0)) { // display the text with any markup $this->clio->display($text)->newLine(); } // add one to the nesting ++$this->nest...
php
{ "resource": "" }
q265549
CacheProvider.init
test
public function init($config = [], $use) { $this->config = $config; $this->cache = $this->getCache($use); $this->app->addAlias($use, $config['drivers'][$use]['class']); }
php
{ "resource": "" }
q265550
ImageSize.get
test
public static function get($name) { $name = (strtolower($name) === self::SIZE_ORIG) ? self::SIZE_ORIG : strtoupper($name); return isset(self::$allowedSize[$name]) ? self::$allowedSize[$name] : null; }
php
{ "resource": "" }
q265551
Form.buildFormForSection
test
public function buildFormForSection( string $forHandle, RequestStack $requestStack, SectionFormOptions $sectionFormOptions = null, bool $csrfProtection = true ): FormInterface { $sectionConfig = $this->getSectionConfig($forHandle); $section = $this->getSection($secti...
php
{ "resource": "" }
q265552
Form.getFormFactory
test
private function getFormFactory(RequestStack $requestStack): FormFactory { $factory = $this->formFactory; if (empty($this->formFactory)) { $validatorBuilder = Validation::createValidatorBuilder(); // Loads validator metadata from entity static method $validatorBui...
php
{ "resource": "" }
q265553
FixturesLoader.loadFromIterator
test
private function loadFromIterator(\Iterator $iterator) { /* @var \SplFileInfo[] $iterator */ foreach ($iterator as $file) { if ($file->getFilename() === 'fixtures.yml') { $this->addFixture($file->getPathname()); } } }
php
{ "resource": "" }
q265554
Url.resolveRelativeUrl
test
public function resolveRelativeUrl($url) { try { // return absolute url return new static($url); } catch(UrlException $exception) {} // anchor if($url[0] === '#') { return new static($this->getUrl(self::ALL - self::FRAGMENT) . $url); ...
php
{ "resource": "" }
q265555
Installer.install
test
public function install(InstalledRepositoryInterface $repo, PackageInterface $package) { parent::install($repo, $package); $strPackageName = $package->getName(); if (self::startsWith($strPackageName, 'qcubed/plugin')) { $this->composerPluginInstall($package); } elseif (self::startsWith($strPackageName, '...
php
{ "resource": "" }
q265556
Installer.composerPluginInstall
test
protected function composerPluginInstall ($package) { require_once(($this->vendorDir ? $this->vendorDir . '/' : '') . 'qcubed/qcubed/qcubed.inc.php'); // get the configuration options so we can know where to put the plugin files // recursively copy the contents of the install subdirectory in the plugin. $strPlug...
php
{ "resource": "" }
q265557
Installer.composerFrameworkInstall
test
protected function composerFrameworkInstall ($package) { $extra = $package->getExtra(); // recursively copy the contents of the install directory, providing each file is not there. $strInstallDir = self::NormalizeNonPosixPath($this->getPackageBasePath($package)) . '/install/project'; $strDestDir = ($this->vend...
php
{ "resource": "" }
q265558
Installer.update
test
public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target) { parent::install($repo, $initial, $target); $strPackageName = $target->getName(); if (self::startsWith($strPackageName, 'qcubed/plugin')) { $this->composerPluginInstall($target); } elseif (self...
php
{ "resource": "" }
q265559
Installer.composerFrameworkUpdate
test
protected function composerFrameworkUpdate ($package) { require_once(($this->vendorDir ? $this->vendorDir . '/' : '') . 'qcubed/qcubed/qcubed.inc.php'); // get the configuration options so we can know where to put the plugin files // recursively copy the contents of the install directory, providing each file is no...
php
{ "resource": "" }
q265560
Installer.uninstall
test
public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package) { $strPackageName = $package->getName(); if (self::startsWith($strPackageName, 'qcubed/plugin')) { $this->composerPluginUninstall($package); } parent::uninstall ($repo, $package); }
php
{ "resource": "" }
q265561
Installer.composerPluginUninstall
test
public function composerPluginUninstall (PackageInterface $package) { require_once(($this->vendorDir ? $this->vendorDir . '/' : '') . 'qcubed/qcubed/qcubed.inc.php'); // get the configuration options so we can know where the plugin files are // recursively delete the contents of the install directory, providing ea...
php
{ "resource": "" }
q265562
Installer.remove_matching_dir
test
protected static function remove_matching_dir($src,$dst) { if (!$dst || !$src || !is_dir($src) || !is_dir($dst)) return; // prevent deleting an entire disk by accidentally calling this with an empty string! $dir = opendir($src); while(false !== ( $file = readdir($dir)) ) { if (( $file != '.' ) && ( $file != '...
php
{ "resource": "" }
q265563
Installer.remove_dir
test
protected static function remove_dir($dst) { if (!$dst || !is_dir($dst)) return; // prevent deleting an entire disk by accidentally calling this with an empty string! $dir = opendir($dst); while(false !== ( $file = readdir($dir)) ) { if (( $file != '.' ) && ( $file != '..' )) { if ( is_dir($dst . '/' . $f...
php
{ "resource": "" }
q265564
Column.setColors
test
public function setColors($textColor = null, $fillColor = null) { // if the text color was specified if ($textColor) { // store it $this->textColor = new Color($textColor); // not set } else { // clear out the text c...
php
{ "resource": "" }
q265565
Column.getTextArea
test
protected function getTextArea() { // initialize the return value $textArea = 0; // if the width has a value (if it is calculated, it may not) if ($this->width) { // subtract the padding from the width $textArea = $this->width - $this->rightPaddi...
php
{ "resource": "" }
q265566
Column.calculateWidth
test
public function calculateWidth($data, $markupDefinition = null) { // if the width is not calculated, or the data is invalid if (($this->calculateWidth === false) || !is_array($data) || (count($data) === 0)) { // nothing to do, it is not a calculated width return; } ...
php
{ "resource": "" }
q265567
DateField.scopeGetByDateValue
test
public function scopeGetByDateValue($obQuery, $sField, $sDate, $sCondition = '=') { if(empty($sDate) || empty($sCondition) || empty($sField)) { return $obQuery; } return $obQuery->where($sField, $sCondition, $sDate); }
php
{ "resource": "" }
q265568
DateField.getDateValue
test
public function getDateValue($sFieldName, $sFormat = 'd.m.Y') { if(empty($sFieldName) || empty($sFormat)) { return null; } /** @var Carbon $obDate */ $obDate = $this->$sFieldName; if(empty($obDate) || !$obDate instanceof Carbon) { return $obDa...
php
{ "resource": "" }
q265569
PolyfillTrait.castAttribute
test
protected function castAttribute($key, $value) { $type = $this->getCastType($key); if (!empty($type) && !in_array($type, $this->originalCastTypes)) { $method = 'as'.Str::studly($type); if (method_exists($this, $method)) return call_user_func([$this, $method], $value, $key, $type); } return parent::...
php
{ "resource": "" }
q265570
PolyfillTrait.attributesToArray
test
public function attributesToArray() { $data = parent::attributesToArray(); foreach ($this->getCasts() as $key => $type) { if (!empty($type) && !in_array($type, $this->originalCastTypes) && isset($data[$key])) { $method = Str::camel($type).'ToArray'; if (method_exists($this, $method)) $data[$ke...
php
{ "resource": "" }
q265571
TreeCollection.offsetSet
test
public function offsetSet($key, $value) { $value = $value instanceof TreeNode ? $value : new TreeNode($value); if (is_null($key)) { $this->items[] = $value; } else { $this->items[$key] = $value; } }
php
{ "resource": "" }
q265572
ContainerProvider.get
test
public function get($name, array $options = []) { if (!isset($this->menuCollection[$name])) { if (!isset($this->menuInfoCollection[$name])) { throw new \InvalidArgumentException(\sprintf('The menu "%s" is not defined.', $name)); } $menuInfo = $this->menuI...
php
{ "resource": "" }
q265573
AddTrackingListener.onKernelResponse
test
public function onKernelResponse(FilterResponseEvent $event) { $config = [ 'id' => $this->params['number'], 'accurateTrackBounce' => $this->params['accurateTrackBounce'], // показатель отказов: true | false | 10000 (ms) 'clickmap' => $this->params['clickmap'], // Включает...
php
{ "resource": "" }
q265574
YamlDefinitionLoader.getDefinitions
test
public function getDefinitions() { $content = $this->loadFile($this->fileName); // empty file if (null === $content) { return []; } // imports $definitions = $this->parseImports($content); // parameters if (isset($content['parameters']))...
php
{ "resource": "" }
q265575
YamlDefinitionLoader.parseImports
test
private function parseImports($content) { if (!isset($content['imports'])) { return []; } if (!is_array($content['imports'])) { throw new InvalidArgumentException(sprintf('The "imports" key should contain an array in %s. Check your YAML syntax.', $this->fileName)); ...
php
{ "resource": "" }
q265576
YamlDefinitionLoader.parseDefinitions
test
private function parseDefinitions($content) { if (!isset($content['services'])) { return []; } if (!is_array($content['services'])) { throw new InvalidArgumentException(sprintf('The "services" key should contain an array in %s. Check your YAML syntax.', $this->fileNa...
php
{ "resource": "" }
q265577
YamlDefinitionLoader.loadFile
test
protected function loadFile($file) { if (!stream_is_local($file)) { throw new InvalidArgumentException(sprintf('This is not a local file "%s".', $file)); } if (!is_readable($file)) { throw new FileNotFoundException(sprintf('The file "%s" does not exist or is not read...
php
{ "resource": "" }
q265578
YamlDefinitionLoader.resolveServices
test
private function resolveServices($value) { if (is_array($value)) { return array_map(array($this, 'resolveServices'), $value); } elseif (is_string($value) && 0 === strpos($value, '@=')) { throw new InvalidArgumentException('Expressions (starting by "@=") are not supported by ...
php
{ "resource": "" }
q265579
AutoloadProvider.init
test
public function init(Autoload $loader, $loads = []){ $this->loader = $loader; foreach ($loads['namespaces'] as $prefix => $namespace) { $this->loader->addNamespace($prefix, ROOT . DIRECTORY_SEPARATOR . ltrim($namespace, '/')); } foreach ($loads['classes'] as $class => $path) ...
php
{ "resource": "" }
q265580
Encrypt.getApi
test
public function getApi() { if (is_null($this->api)) { $this->api = new AES(); $this->api->setKey($this->getKey()); } return $this->api; }
php
{ "resource": "" }
q265581
Utils.humanize
test
public static function humanize($bytes, $base = 1024) { if (empty($bytes)) { return '0 B'; } $class = min((int)log($bytes, $base), count(static::$siPrefix) - 1); return sprintf('%1.2F %s', $bytes / pow($base, $class), static::$siPrefix[$class]); }
php
{ "resource": "" }
q265582
UnorderedList.setBullet
test
public function setBullet($str) { // store the bullet, if it is null.. if (is_null($str)) { // store the default bullet $this->bullet = $this->defaultBullet; // something was sent in } else { // store it $this->bullet = $str; } ...
php
{ "resource": "" }
q265583
Table.setColumnDefinition
test
public function setColumnDefinition($columnIndex, Column $column) { // if the index is valid if ($columnIndex < $this->columnCount) { // copy the column information $this->columnDefinitions[$columnIndex] = clone $column; } }
php
{ "resource": "" }
q265584
Table.calcTotalWidth
test
protected function calcTotalWidth() { $totalWidth = 0; // go through all the widths for ($w=0; $w<count($this->columnDefinitions); ++$w) { // add the column's width $totalWidth += $this->columnDefinitions[$w]->getWidth(); } // return the t...
php
{ "resource": "" }
q265585
Table.hasHeader
test
protected function hasHeader() { // go through the column definitions for ($i=0; $i<count($this->columnDefinitions); ++$i) { // if one column has header text if ($this->columnDefinitions[$i]->hasHeaderText()) { // then there ...
php
{ "resource": "" }
q265586
Table.getHeaderText
test
protected function getHeaderText() { $headers = []; // go through the column definitions for ($i=0; $i<count($this->columnDefinitions); ++$i) { $next = $this->columnDefinitions[$i]; // if one column has header text if ($this->co...
php
{ "resource": "" }
q265587
Table.dataCheck
test
protected function dataCheck(&$data) { // no need to go on, if there is no data if (count($data) < 1 || !is_array($data)) { // exit return false; } // first check that there are enough Column definitions for the data supplied for ($r=0; ...
php
{ "resource": "" }
q265588
Table.calculateWidths
test
protected function calculateWidths($data) { // get the markup definition from the HTML object $markupDefinition = $this->clio->getMarkupDefinition(); // go through and calculate any column widths that were not calculated for ($column = 0; $column < $this->columnCount; ++$co...
php
{ "resource": "" }
q265589
Table.draw
test
public function draw($data) { // if the data is sane, and the widths have been set (if not calculate them) if ($this->dataCheck($data)) { // calculate the widths $this->calculateWidths($data); // if at least one of the columns has he...
php
{ "resource": "" }
q265590
FileDriver.createSession
test
public function createSession(SessionManager $sessionManager, $userProfile = null) { list($sessionId, $fileHandle) = $this->createNewSessionFile(); $lockFileHandle = null; if ($sessionManager->getLockMode() == SessionConfig::LOCK_ON_OPEN) { $lockFileHandle = $this->acquireLock( ...
php
{ "resource": "" }
q265591
FileDriver.createNewSessionFile
test
private function createNewSessionFile() { for ($count=0 ; $count<10 ; $count++) { $sessionId = $this->idGenerator->generateSessionID(); $filename = $this->generateFilenameForDataFile($sessionId); //TODO remove? - the user should create the directory themselves ...
php
{ "resource": "" }
q265592
FileDriver.save
test
public function save($sessionId, $data, $existingProfiles, FileInfo $fileInfo) { $rawData = []; $rawData['data'] = $data; $rawData['profiles'] = $existingProfiles; $dataString = $this->serializer->serialize($rawData); $filename = $this->generateFilenameForDataFile($sessionId...
php
{ "resource": "" }
q265593
FileDriver.acquireLock
test
public function acquireLock($sessionId, $lockTimeMS, $acquireTimeoutMS) { // Get the time in MS $currentTime = microtime(true); $giveUpTime = $currentTime + ($acquireTimeoutMS * 0.001); $lockFilename = $this->generateFilenameForLockFile($sessionId); do { //Re-o...
php
{ "resource": "" }
q265594
SectionFormTwigExtension.sectionForm
test
public function sectionForm( string $forHandle, array $sectionFormOptions = [] ): FormView { $sectionFormOptions = SectionFormOptions::fromArray($sectionFormOptions); $form = $this->form->buildFormForSection( $forHandle, $this->requestStack, $sec...
php
{ "resource": "" }
q265595
ReflectionProperty.factory
test
public static function factory($class, $property = null) { if (is_object($class)) $class = get_class($class); $class = (string)$class; if (!isset(self::$properties[$class])) { $classReflection = new \ReflectionClass($class); $properties = $classReflection-...
php
{ "resource": "" }
q265596
CommandProvider.getFacts
test
public function getFacts() { try { $output = $this->runCommand($this->cmd); if ($this->as_json) { $json = json_decode($output, true); if (is_null($json)) { return array(); } return $json; ...
php
{ "resource": "" }
q265597
CommandProvider.parseFacts
test
protected function parseFacts($facts_string) { $facts = array(); foreach (explode(PHP_EOL, $facts_string) as $line) { if (empty($line)) { continue; } list($key, $value) = explode('=', $line, 2); $facts[$key] = $value; } ...
php
{ "resource": "" }
q265598
ActiveRecordModel.findById
test
public function findById($id = null) { $id = $id ?: $this->{$this->tableIdColumn}; return $this->findWhere("{$this->tableIdColumn} = ?", $id); }
php
{ "resource": "" }
q265599
ActiveRecordModel.findWhere
test
public function findWhere($where, $value) { $this->checkDb(); $params = is_array($value) ? $value : [$value]; $this->db->connect() ->select() ->from($this ->tableName) ->where($where) ->execute($params) ->fe...
php
{ "resource": "" }