_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q250500
HandlerWrapperGenerator.addNamedRoute
validation
public function addNamedRoute($name, $httpMethod, $routeData, $handler) { $handler = array( 'name' => $name, 'handler' => $handler, ); $this->addRoute($httpMethod, $routeData, $handler); }
php
{ "resource": "" }
q250501
CachedCollector.isCacheable
validation
private function isCacheable($data) { $cacheable = true; array_walk_recursive($data, function ($value) use (&$cacheable) { if ($value instanceof \Closure) { $cacheable = false; } }); return $cacheable; }
php
{ "resource": "" }
q250502
RouteCollector.map
validation
public function map($route, $name, $handler, array $methods = array('GET')) { foreach ($methods as $method) { if (null === $name) { $this->addRoute($method, $route, $handler); } else { $this->addNamedRoute($name, $method, $route, $handler); ...
php
{ "resource": "" }
q250503
RouteCollector.addRoute
validation
private function addRoute($httpMethod, $route, $handler) { $routeData = $this->routeParser->parse($route); foreach ($routeData as $routeDatum) { $this->dataGenerator->addRoute($httpMethod, $routeDatum, $handler); } }
php
{ "resource": "" }
q250504
RouteCollector.addNamedRoute
validation
private function addNamedRoute($name, $httpMethod, $route, $handler) { if (! ($this->dataGenerator instanceof NamedDataGeneratorInterface)) { throw new \RuntimeException('The injected generator does not support named routes'); } $routeData = $this->routeParser->parse($route); ...
php
{ "resource": "" }
q250505
ContainerAwareControllerResolver.createController
validation
protected function createController($controller) { $parts = explode(':', $controller); if (count($parts) === 2) { $service = $this->container->get($parts[0]); return array($service, $parts[1]); } $controller = parent::createController($controller); i...
php
{ "resource": "" }
q250506
ServiceProviderMiddleware.setProviders
validation
public function setProviders() { $services = $this->container['services']??null; if (is_array($services)) { foreach ($services as $service) { $service::register($this->container); $service::boot($this->container); } } }
php
{ "resource": "" }
q250507
Space.from
validation
public function from(Contract $contract, string $string, callable $callback = null): string { return $this->callback( trim($contract->recipe($string, 'space')), $callback ); }
php
{ "resource": "" }
q250508
Space.recipe
validation
public function recipe(string $string, string $method, callable $callback = null): string { return preg_replace_callback( RegEx::REGEX_SPACE, [$this, $method], $this->callback($string, $callback) ); }
php
{ "resource": "" }
q250509
OrchestrationTask.setTimeoutMinutes
validation
public function setTimeoutMinutes($value) { if ($value) $this->timeoutMinutes = (int) $value; else $this->timeoutMinutes = null; return $this; }
php
{ "resource": "" }
q250510
OrchestrationTask.setPhase
validation
public function setPhase($value) { $value = (int) $value; if ($value) $this->phase = $value; else $this->phase = null; return $this; }
php
{ "resource": "" }
q250511
FileConfigurationProvider.load
validation
public function load(ContainerBuilder $container) { $loader = $this->getContainerLoader($container); $loader->load($this->configFile); }
php
{ "resource": "" }
q250512
BaseRepository.setUri
validation
protected function setUri($uriToSet) { $uri_parts = []; array_push($uri_parts, 'api'); array_push($uri_parts, config('ckan_api.api_version')); array_push($uri_parts, trim($uriToSet, '/')); $uri_parts = array_filter($uri_parts); $this->uri = implode('/', $uri_parts)...
php
{ "resource": "" }
q250513
BaseRepository.dataToMultipart
validation
protected function dataToMultipart(array $data = []) { $multipart = []; foreach($data as $name => $contents) { array_push($multipart, ['name' => $name, 'contents' => $contents]); } return $multipart; }
php
{ "resource": "" }
q250514
Bbcode.filter
validation
public function filter($text) { //removing /r because it's bad! $text = str_replace("\r", '', $text); //transform all double spaces in '  ' to respect multiples spaces $text = str_replace(' ', '  ', $text); // first [nobbcode][/nobbcode] -> don't interpret bbcode...
php
{ "resource": "" }
q250515
Module.getServiceConfig
validation
public function getServiceConfig() { return array( 'factories' => array( 'CronHelper\Service\CronService' => function ($serviceManager) { $mainConfig = $serviceManager->get('config'); $serviceConfig = array(); if (is_array($mainConfig)) { if (array_key_exists('cron_helper', $mainConfig))...
php
{ "resource": "" }
q250516
Module.onBootstrap
validation
public function onBootstrap(MvcEvent $event) { $eventManager = $event->getApplication()->getEventManager(); $sharedEventManager = $eventManager->getSharedManager(); //$sharedEventManager->attach('CronHelper\Service\CronService', function($aEvent) { // var_dump($aEvent); //}, 100); }
php
{ "resource": "" }
q250517
FieldValidator.validateFields
validation
public function validateFields(Request $request, Repository $repository, $data) { $config = []; $validation = []; foreach ($this->versions as $version) { foreach ($version['endpoints'] as $endpoint) { if ($endpoint['repository'] == $request->attributes->get('repos...
php
{ "resource": "" }
q250518
AbstractRestController.renderRest
validation
public function renderRest( $request, $data, $statusCode = Response::HTTP_OK, $headers = [] ) { $requestSerializer = $this->get('ongr_api.request_serializer'); return new Response( $requestSerializer->serializeRequest($request, $data), $status...
php
{ "resource": "" }
q250519
JobMapper.fetchByWhere
validation
public function fetchByWhere($where = null, array $options = array()) { $select = $this->sql->select(); if ($where instanceof Where) { $select->where($where); } elseif (is_string($where) && !empty($where)) { $select->where($where); } // Options: limit $limit = array_key_exists('limit', $options) ? ...
php
{ "resource": "" }
q250520
JobMapper.save
validation
public function save(JobEntity $job) { $query = null; if ((int) $job->getId() == 0) { $query = $this->sql->insert(); $query->values($job->getArrayCopy()); } else { $query = $this->sql->update(); $query->set($job->getArrayCopy()); $query->where(array('id' => $job->getId())); } $stmt = $this->...
php
{ "resource": "" }
q250521
JobMapper.deleteByWhere
validation
public function deleteByWhere($where = null, array $options = array()) { $delete = $this->sql->delete(); if ($where instanceof Where) { $delete->where($where); } elseif (is_string($where) && !empty($where)) { $delete->where($where); } $delete->where($where); // Options: limit $limit = array_key_...
php
{ "resource": "" }
q250522
JobMapper.getPending
validation
public function getPending(array $options = array()) { $where = new Where(); $where->equalTo("{$this->tableName}.status", JobEntity::STATUS_PENDING); return $this->fetchByWhere($where, $options); }
php
{ "resource": "" }
q250523
JobMapper.getRunning
validation
public function getRunning(array $options = array()) { $where = new Where(); $where->equalTo("{$this->tableName}.status", JobEntity::STATUS_RUNNING); return $this->fetchByWhere($where, $options); }
php
{ "resource": "" }
q250524
LessServerCompiler.needsCompilation
validation
private function needsCompilation($lessPath, $cssPath) { /** * Checks whether $subject has been modified since $reference was */ $isNewer = function($subject, $reference) { return filemtime($subject) > filemtime($reference); }; // Check for obvious cases if ($this->forceCompile || !file_exists($les...
php
{ "resource": "" }
q250525
LessServerCompiler.checkImports
validation
private function checkImports($lessPath, $cssPath, $callback) { static $needsRecompile = false; if ($needsRecompile) return $needsRecompile; $lessContent = file_get_contents($lessPath); preg_match_all('/(?<=@import)\s+"([^"]+)/im', $lessContent, $imports); foreach ($imports[1] as $import) { $impor...
php
{ "resource": "" }
q250526
LessServerCompiler.compileFile
validation
protected function compileFile($lessPath, $cssPath) { $options = array(); if ($this->strictImports === true) $options[] = '--strict-imports'; if ($this->compression === self::COMPRESSION_WHITESPACE) $options[] = '--compress'; else if ($this->compression === self::COMPRESSION_YUI) $options[] = '--yui...
php
{ "resource": "" }
q250527
JobTable.create
validation
public function create() { $adapter = $this->dbAdapter; $ddl = new Ddl\CreateTable(); $ddl->setTable(self::TABLE_NAME) ->addColumn(new Column\Integer('id', false, null, array('autoincrement' => true))) ->addColumn(new Column\Varchar('code', 55)) ->addColumn(new Column\Varchar('status', 55)) ->addCol...
php
{ "resource": "" }
q250528
JobTable.drop
validation
public function drop() { $adapter = $this->dbAdapter; $ddl = new Ddl\DropTable(self::TABLE_NAME); $sql = (new Sql($adapter))->getSqlStringForSqlObject($ddl); $adapter->query($sql, $adapter::QUERY_MODE_EXECUTE); }
php
{ "resource": "" }
q250529
JobTable.truncate
validation
public function truncate() { $adapter = $this->dbAdapter; $mapper = new \CronHelper\Model\JobMapper($adapter); $where = new \Zend\Db\Sql\Where(); $mapper->deleteByWhere($where); }
php
{ "resource": "" }
q250530
JobEntity.getDuration
validation
public function getDuration() { $executed = $this->getExecuted(); $finished = $this->getFinished(); if (is_null($executed) || is_null($finished)) { return 0; } return strtotime($finished) - strtotime($executed); }
php
{ "resource": "" }
q250531
Serializer.applySerializeMetadataToArray
validation
public function applySerializeMetadataToArray(array $array, $className) { $classMetadata = $this->documentManager->getClassMetadata($className); $fieldList = $this->fieldListForSerialize($classMetadata); $return = array_merge($array, $this->serializeClassNameAndDiscriminator($classMetadata)); ...
php
{ "resource": "" }
q250532
Grid16Layout.addGrid16CSS
validation
public function addGrid16CSS(\PageModel $objPage, \LayoutModel $objLayout, \PageRegular $objPageRegular) { /* * vor internen laden * $GLOBALS['TL_CSS'][] = 'assets/contao-grid16/css/grid-1120-16-pixel.min.css'; * nach den anderen * $GLOBALS['TL_HEAD'][] = '<link ...>'; ...
php
{ "resource": "" }
q250533
Configuration.getEndpointNode
validation
public function getEndpointNode() { $builder = new TreeBuilder(); $node = $builder->root('endpoints'); $node ->info('Defines version endpoints.') ->useAttributeAsKey('endpoint') ->prototype('array') ->children() ->scal...
php
{ "resource": "" }
q250534
LessClientCompiler.getAssetsUrl
validation
protected function getAssetsUrl() { if (!isset($this->_assetsUrl)) { $path = dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'assets'; $this->_assetsUrl = Yii::app()->assetManager->publish($path, false, -1, $this->forceCopyAssets); } return $this->_assetsUrl; }
php
{ "resource": "" }
q250535
DashServicesProvider.themeDefaults
validation
public function themeDefaults() { view()->composer("*", function ($view) { /* get the theme if set in config */ $theme = config("dash.theme", null); /* if not theme is set in the config */ /* check the theme folder if exist or use the theme in package*...
php
{ "resource": "" }
q250536
GenerateFormsFields.buildCustomFields
validation
public function buildCustomFields($form_fields = [], $config_name = 'custom_form') { $fields = collect($form_fields)->map(function ($field, $name) use ($config_name) { return $this->render( isset($field['type']) ? $field['type'] : 'text', [ $na...
php
{ "resource": "" }
q250537
BatchRequestHandler.update
validation
private function update($documents, $repository, $commitSize) { if (count($documents) > $commitSize && $commitSize > 1) { $esResponse = []; $i = 1; foreach ($documents as $document) { $id = $document['_id']; unset($document['_id']); ...
php
{ "resource": "" }
q250538
ResourceRepository.update
validation
public function update(array $data = []) { $this->setActionUri(__FUNCTION__); $response = $this->client->post($this->uri, [ 'multipart' => $this->dataToMultipart($data), ]); return $this->responseToJson($response); }
php
{ "resource": "" }
q250539
CategoryRepository.getHome
validation
public function getHome() { $query = $this->createQueryBuilder('c') ->join('c.forums', 'f') ->join('f.lastMessage', 'm') ->join('m.user', 'u') ->addSelect('f') ->addSelect('m') ->addSelect('u') ->where('f.status = :status') ...
php
{ "resource": "" }
q250540
BatchController.postAction
validation
public function postAction(Request $request) { try { $data = $this->get('ongr_api.batch_request_handler')->handleRequest( $request, $repository = $this->getRequestRepository($request), 'create' ); return $this->renderRest($r...
php
{ "resource": "" }
q250541
CronService.setOptions
validation
public function setOptions(array $options) { if (!array_key_exists('options', $options)) { $options['options'] = array(); } $this->options = array_merge($this->getDefaultOptions(), $options['options']); return $this; }
php
{ "resource": "" }
q250542
CronService.setScheduleAhead
validation
public function setScheduleAhead($time) { if (!is_numeric($time)) { throw new \InvalidArgumentException('`scheduleAhead` expects integer value!'); } $this->options['scheduleAhead'] = (int) $time; return $this; }
php
{ "resource": "" }
q250543
CronService.setScheduleLifetime
validation
public function setScheduleLifetime($time) { if (!is_numeric($time)) { throw new \InvalidArgumentException('`scheduleLifetime` expects integer value!'); } $this->options['scheduleLifetime'] = (int) $time; return $this; }
php
{ "resource": "" }
q250544
CronService.setSuccessLogLifetime
validation
public function setSuccessLogLifetime($time) { if (!is_numeric($time)) { throw new \InvalidArgumentException('`successLogLifetime` expects integer value!'); } $this->options['successLogLifetime'] = (int) $time; return $this; }
php
{ "resource": "" }
q250545
CronService.setFailureLogLifetime
validation
public function setFailureLogLifetime($time) { if (!is_numeric($time)) { throw new \InvalidArgumentException('`failureLogLifetime` expects integer value!'); } $this->options['failureLogLifetime'] = (int) $time; return $this; }
php
{ "resource": "" }
q250546
CronService.setEmitEvents
validation
public function setEmitEvents($emitEvents) { if (!is_bool($emitEvents)) { throw new \InvalidArgumentException('`emitEvents` expects boolean value!'); } $this->options['emitEvents'] = (bool) $emitEvents; return $this; }
php
{ "resource": "" }
q250547
CronService.setAllowJsonApi
validation
public function setAllowJsonApi($allowJsonApi) { if (!is_bool($allowJsonApi)) { throw new \InvalidArgumentException('`allowJsonApi` expects boolean value!'); } $this->options['allowJsonApi'] = (bool) $allowJsonApi; return $this; }
php
{ "resource": "" }
q250548
CronService.setJsonApiSecurityHash
validation
public function setJsonApiSecurityHash($jsonApiSecurityHash) { if (!is_string($jsonApiSecurityHash)) { throw new \InvalidArgumentException('`jsonApiSecurityHash` expects string value!'); } $this->options['jsonApiSecurityHash'] = (string) $jsonApiSecurityHash; return $thi...
php
{ "resource": "" }
q250549
CkanServiceProvider.register
validation
public function register() { $app = $this->app; $app->bind('Germanazo\CkanApi\CkanApiClient', function () { // Build http client $config = [ 'base_uri' => config('ckan_api.url'), 'headers' => ['Authorization' => config('ckan_api.api_key')], ...
php
{ "resource": "" }
q250550
RestApiTrait.show
validation
public function show($id, $params = []) { $data = ['id' => $id] + $params; return $this->query(__FUNCTION__, $data); }
php
{ "resource": "" }
q250551
RestApiTrait.doPostAction
validation
protected function doPostAction($uri, array $data = []) { $this->setActionUri($uri); try { $response = $this->client->post($this->uri, ['json' => $data]); } catch (ClientException $e) { $response = $e->getResponse(); } catch (ServerException $e) { ...
php
{ "resource": "" }
q250552
RestApiTrait.query
validation
protected function query($uri, $data = []) { $this->setActionUri($uri); try { $response = $this->client->get($this->uri, ['query' => $data]); } catch(ClientException $e) { $response = $e->getResponse(); } catch(ServerException $e) { $response = $e...
php
{ "resource": "" }
q250553
IndexController.indexAction
validation
public function indexAction() { if (!$this->isConsoleRequest()) { throw new \RuntimeException('You can only use this action from a console!'); } $console = $this->getConsole(); $this->printConsoleBanner($console); $console->writeLine('TODO Finish indexAction!', ConsoleColor::LIGHT_RED); }
php
{ "resource": "" }
q250554
IndexController.infoAction
validation
public function infoAction() { if (!$this->isConsoleRequest()) { throw new \RuntimeException('You can only use this action from a console!'); } $console = $this->getConsole(); $this->printConsoleBanner($console); $mapper = $this->getJobMapper(); try { $pendingJobs = $mapper->getPending()->count();...
php
{ "resource": "" }
q250555
IndexController.storageClearAction
validation
public function storageClearAction() { if (!$this->isConsoleRequest()) { throw new \RuntimeException('You can only use this action from a console!'); } $dbAdapter = $this->getDbAdapter(); $console = $this->getConsole(); $this->printConsoleBanner($console); try { $table = new JobTable($dbAdapter); ...
php
{ "resource": "" }
q250556
RequestSerializer.checkAcceptHeader
validation
public function checkAcceptHeader(Request $request) { $headers = $request->getAcceptableContentTypes(); if (array_intersect($headers, ['application/json', 'text/json'])) { return 'json'; } elseif (array_intersect($headers, ['application/xml', 'text/xml'])) { return '...
php
{ "resource": "" }
q250557
eZIEImageToolCrop.filter
validation
public static function filter( $region ) { $r = array( 'x' => intval( $region['x'] ), 'y' => intval( $region['y'] ), 'width' => intval( $region['w'] ), 'height' => intval( $region['h'] ) ); return array( new ezcImageFilter( 'crop', ...
php
{ "resource": "" }
q250558
eZIEezcImageConverter.perform
validation
public function perform( $src, $dst ) { // fetch the input file locally $inClusterHandler = eZClusterFileHandler::instance( $src ); $inClusterHandler->fetch(); try { $this->converter->transform( 'transformation', $src, $dst ); } catch ( Exception $e ) ...
php
{ "resource": "" }
q250559
eZIEEzcImageMagickHandler.rotate
validation
public function rotate( $angle, $background = 'FFFFFF' ) { $angle = intval( $angle ); if ( !is_int( $angle ) || ( $angle < 0 ) || ( $angle > 360 ) ) { throw new ezcBaseValueException( 'height', $height, 'angle < 0 or angle > 360' ); } $angle = 360 - $angle; ...
php
{ "resource": "" }
q250560
MarkdownBladeCompiler.markdown
validation
public function markdown($contents) { $contents = app('markdown')->convertToHtml($contents); if (! is_null($this->cachePath)) { $this->files->put($this->getCompiledPath($this->getPath()), $contents); } return $contents; }
php
{ "resource": "" }
q250561
BladeExtCompiler.getEchoMethods
validation
protected function getEchoMethods() { $methods = [ 'compileRawEchos' => strlen(stripcslashes($this->rawTags[0])), 'compileEscapedEchos' => strlen(stripcslashes($this->escapedTags[0])), 'compileMarkdownEchos' => strlen(stripcslashes($this->markdownTags[0])), 'c...
php
{ "resource": "" }
q250562
BladeExtCompiler.compileMarkdownEchos
validation
protected function compileMarkdownEchos($value) { $pattern = sprintf('/(@)?%s\s*(.+?)\s*%s(\r?\n)?/s', $this->markdownTags[0], $this->markdownTags[1]); $callback = function ($matches) { $wrapper = sprintf($this->markdownFormat, $this->compileEchoDefaults($matches[2])); retu...
php
{ "resource": "" }
q250563
MarkdownServiceProvider.registerMarkdownEnvironment
validation
protected function registerMarkdownEnvironment() { $app = $this->app; $app->singleton('commonmark.environment', function ($app) { $config = $app['config']['markdown']; $environment = Environment::createCommonMarkEnvironment(); if ($config['configurations']) { ...
php
{ "resource": "" }
q250564
MarkdownServiceProvider.registerMarkdownParser
validation
protected function registerMarkdownParser() { $app = $this->app; $app->singleton('commonmark.docparser', function ($app) { $environment = $app['commonmark.environment']; return new DocParser($environment); }); $app->alias('commonmark.docparser', DocParser::...
php
{ "resource": "" }
q250565
MarkdownServiceProvider.registerMarkdownHtmlRenderer
validation
protected function registerMarkdownHtmlRenderer() { $app = $this->app; $app->singleton('commonmark.htmlrenderer', function ($app) { $environment = $app['commonmark.environment']; return new HtmlRenderer($environment); }); $app->alias('commonmark.htmlrendere...
php
{ "resource": "" }
q250566
MarkdownServiceProvider.registerMarkdown
validation
protected function registerMarkdown() { $app = $this->app; $app->singleton('markdown', function ($app) { return new Converter($app['commonmark.docparser'], $app['commonmark.htmlrenderer']); }); $app->alias('markdown', Converter::class); }
php
{ "resource": "" }
q250567
MarkdownServiceProvider.registerEngines
validation
protected function registerEngines() { $app = $this->app; $config = $app['config']; $resolver = $app['view.engine.resolver']; if ($config['markdown.tags']) { $this->registerBladeEngine($resolver); } if ($config['markdown.views']) { $this->reg...
php
{ "resource": "" }
q250568
MarkdownServiceProvider.registerMarkdownEngine
validation
protected function registerMarkdownEngine($resolver) { $app = $this->app; $app->singleton('markdown.compiler', function ($app) { $cache = $app['config']['view.compiled']; return new MarkdownCompiler($app['files'], $cache); }); $resolver->register('markdown'...
php
{ "resource": "" }
q250569
MarkdownServiceProvider.registerMarkdownPhpEngine
validation
protected function registerMarkdownPhpEngine($resolver) { $app = $this->app; $app->singleton('markdown.php.compiler', function ($app) { $cache = $app['config']['view.compiled']; return new MarkdownPhpCompiler($app['files'], $cache); }); $resolver->register(...
php
{ "resource": "" }
q250570
MarkdownServiceProvider.registerMarkdownBladeEngine
validation
protected function registerMarkdownBladeEngine($resolver) { $app = $this->app; $app->singleton('markdown.blade.compiler', function ($app) { $cache = $app['config']['view.compiled']; return new MarkdownBladeCompiler($app['files'], $cache); }); $resolver->reg...
php
{ "resource": "" }
q250571
eZIEImageToolResize.filter
validation
static function filter( $width, $height ) { return array( new ezcImageFilter( 'scale', array( 'width' => intval( $width ), 'height' => intval( $height ), 'direction' => ezcImageGeometryFilters::S...
php
{ "resource": "" }
q250572
eZIEEzcGDHandler.region
validation
private function region( $filter, $resource, $region, $colorspace = null, $value = null ) { $dest = imagecreatetruecolor( $region["w"], $region["h"] ); if ( !imagecopy( $dest, $resource, 0, 0, $region["x"], $region["y"], $region["w"], $region["h"] ) ) { throw new ezcImageFilterFa...
php
{ "resource": "" }
q250573
DBFontIcon.requireField
validation
public function requireField() { // Obtain Charset and Collation: $charset = MySQLDatabase::config()->charset; $collation = MySQLDatabase::config()->collation; // Define Field Specification: $spec = [ 'type' => 'varchar', '...
php
{ "resource": "" }
q250574
DBFontIcon.scaffoldFormField
validation
public function scaffoldFormField($title = null, $params = null) { return FontIconField::create($this->name, $title); }
php
{ "resource": "" }
q250575
Angle.deg
validation
public function deg() { if ($this->original->type == self::TYPE_DEG) { return $this->original->value; } return rad2deg($this->float_rad); }
php
{ "resource": "" }
q250576
Angle.rad
validation
public function rad() { if ($this->original->type == self::TYPE_RAD) { return $this->original->value; } return $this->float_rad; }
php
{ "resource": "" }
q250577
Angle.turn
validation
public function turn() { if ($this->original->type == self::TYPE_TURN) { return $this->original->value; } return $this->float_rad / (2 * pi()); }
php
{ "resource": "" }
q250578
Angle.isComplementary
validation
public function isComplementary(Angle $angle) { $out = new self($this->float_rad + $angle->rad); return $out->isRight(); }
php
{ "resource": "" }
q250579
Angle.isSupplementary
validation
public function isSupplementary(Angle $angle) { $out = new self($this->float_rad + $angle->rad); return $out->isStraight(); }
php
{ "resource": "" }
q250580
Configuration.get
validation
public function get($key, $default = null) { $keys = array_filter(explode('.', $key)); $length = count($keys); $data = $this->data; for ($i = 0; $i < $length; $i++) { $index = $keys[$i]; $data = &$data[$index]; } return $data !== null ? $d...
php
{ "resource": "" }
q250581
Configuration.load
validation
public function load($directory) { $configurations = glob($directory . '/*.php'); foreach ($configurations as $configuration) { $items = require $configuration; $name = basename($configuration, '.php'); $this->data = array_merge($this->data, array($name => $ite...
php
{ "resource": "" }
q250582
Configuration.set
validation
public function set($key, $value, $fromFile = false) { $keys = array_filter(explode('.', $key)); $value = ($fromFile) ? require $value : $value; $this->save($keys, $this->data, $value); return $this; }
php
{ "resource": "" }
q250583
Matrix.populate
validation
public function populate($arrAll) { $this->arr = array_chunk($arrAll, $this->size->cols); return $this; }
php
{ "resource": "" }
q250584
Matrix.addRow
validation
public function addRow(array $arr_row) { if (count($this->arr) == $this->size->rows) { throw new \OutOfRangeException(sprintf('You cannot add another row! Max number of rows is %d', $this->size->rows)); } if (count($arr_row) != $this->size->cols) { throw new \Invalid...
php
{ "resource": "" }
q250585
Matrix.addCol
validation
public function addCol($arr_col) { if (isset($this->arr[0]) && (count($this->arr[0]) == $this->size->cols)) { throw new \OutOfRangeException(sprintf('You cannot add another column! Max number of columns is %d', $this->size->cols)); } if (count($arr_col) != $this->size->rows) { ...
php
{ "resource": "" }
q250586
Matrix.getRow
validation
public function getRow($int = 0) { if (!isset($this->arr[$int])) { throw new \OutOfRangeException('There is no line having this index.'); } return $this->arr[$int]; }
php
{ "resource": "" }
q250587
Matrix.getCol
validation
public function getCol($int = 0) { if ($int >= $this->size->cols) { throw new \OutOfRangeException('There is not column having this index.'); } $arr_out = array(); foreach ($this->arr as $row) { $arr_out[] = $row[$int]; } return $arr_out; ...
php
{ "resource": "" }
q250588
Matrix.isDiagonal
validation
public function isDiagonal() { $int_size = min((array) $this->size); if($int_size > 0){ for($i = 0; $i < $int_size; $i++){ $arr_row = $this->getRow($i); if($arr_row[$i] != 0){ unset($arr_row[$i]); foreach($arr_row...
php
{ "resource": "" }
q250589
Matrix.sameSize
validation
public function sameSize($matrix) { return ( $this->size->cols == $matrix->cols && $this->size->rows == $matrix->rows ); }
php
{ "resource": "" }
q250590
Matrix.multiplyAllow
validation
public function multiplyAllow($matrix) { if (is_numeric($matrix)) { return true; } if ($matrix instanceof Complex) { return true; } if ($matrix instanceof Matrix) { return $this->size->cols == $matrix->rows; } return fals...
php
{ "resource": "" }
q250591
Matrix.transpose
validation
public function transpose() { $out = new self($this->size->cols, $this->size->rows); foreach ($this->arr as $row) { $out->addCol($row); } return $out; }
php
{ "resource": "" }
q250592
Matrix.add
validation
public function add($matrix) { if (!($matrix instanceof Matrix)) { throw new \InvalidArgumentException('Given argument must be an instance of \Malenki\Math\Matrix'); } if (!$this->sameSize($matrix)) { throw new \RuntimeException('Cannot adding given matrix: it has wr...
php
{ "resource": "" }
q250593
Matrix.cofactor
validation
public function cofactor() { $c = new self($this->size->rows, $this->size->cols); for ($m = 0; $m < $this->size->rows; $m++) { $arr_row = array(); for ($n = 0; $n < $this->size->cols; $n++) { if ($this->size->cols == 2) { $arr_row[] = pow...
php
{ "resource": "" }
q250594
Matrix.inverse
validation
public function inverse() { $det = $this->det(); if ($det == 0) { throw new \RuntimeException('Cannot get inverse matrix: determinant is nul!'); } return $this->adjugate()->multiply(1 / $det); }
php
{ "resource": "" }
q250595
Matrix.subMatrix
validation
public function subMatrix($int_m, $int_n) { $sm = new self($this->size->rows - 1, $this->size->cols - 1); foreach ($this->arr as $m => $row) { if ($m != $int_m) { $arr_row = array(); foreach ($row as $n => $v) { if ($n != $int_n) { ...
php
{ "resource": "" }
q250596
Matrix.det
validation
public function det() { if (!$this->isSquare()) { throw new \RuntimeException('Cannot compute determinant of non square matrix!'); } if ($this->size->rows == 2) { return $this->get(0,0) * $this->get(1,1) - $this->get(0,1) * $this->get(1,0); } else { ...
php
{ "resource": "" }
q250597
Request.withUri
validation
public function withUri(UriInterface $uri, $preserve = false) { $static = clone $this; $static->uri = $uri; if (! $preserve && $host = $uri->getHost()) { $port = $host . ':' . $uri->getPort(); $host = $uri->getPort() ? $port : $host; $static->headers['...
php
{ "resource": "" }
q250598
Message.withoutHeader
validation
public function withoutHeader($name) { $instance = clone $this; if ($this->hasHeader($name)) { $static = clone $this; unset($static->headers[$name]); $instance = $static; } return $instance; }
php
{ "resource": "" }
q250599
ModuleDetailRetriever.getModulePath
validation
public function getModulePath($moduleName) { if (array_key_exists($moduleName, $this->loadedModules)) { $module = $this->loadedModules[$moduleName]; $moduleConfig = $module->getAutoloaderConfig(); return $moduleConfig[self::STANDARD_AUTOLOLOADER][self::NAMESPACE_...
php
{ "resource": "" }