_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q6100
SMTP.Close
train
public function Close() { $this->error = null; // so there is no confusion $this->helo_rply = null; if (!empty($this->smtp_conn)) { // close the connection and cleanup fclose($this->smtp_conn); $this->smtp_conn = 0; } }
php
{ "resource": "" }
q6101
AbstractProcessor.registerAnnotations
train
static protected function registerAnnotations() { if (self::$annotationsRegistered === false) { AnnotationRegistry::registerFile(__DIR__ . '/../Annotation/ResourceIdentifier.php'); AnnotationRegistry::registerFile(__DIR__ . '/../Annotation/Relationship.php'); AnnotationRegistry::registerFile(__DIR__ . '/../Annotation/Attribute.php'); AnnotationRegistry::registerFile(__DIR__ . '/../Annotation/Link.php'); self::$annotationsRegistered = true; } }
php
{ "resource": "" }
q6102
AbstractProcessor.createLink
train
protected function createLink(LinkAnnotation $annotation): Link { if (! preg_match(self::RESOURCE_PATTERN, $annotation->resource, $matches)) { throw new \LogicException(sprintf('Invalid resource definition: "%s"', $annotation->resource)); } $link = new Link( $annotation->name, $matches['repository'], $matches['link'] ); $link->setParameters($annotation->parameters); $link->setMetadata($annotation->metadata); return $link; }
php
{ "resource": "" }
q6103
Validator.isValidLocalClass
train
public function isValidLocalClass() { $className = SPLASH_CLASS_PREFIX.'\\Local'; //====================================================================// // Verify Results in Cache if (isset($this->ValidLocalClass[$className])) { return $this->ValidLocalClass[$className]; } $this->ValidLocalClass[$className] = false; //====================================================================// // Verify Splash Local Core Class Exists if (false == class_exists($className)) { return Splash::log()->err(Splash::trans('ErrLocalClass', $className)); } //====================================================================// // Verify Splash Local Core Extends LocalClassInterface try { $class = new $className(); if (!($class instanceof LocalClassInterface)) { return Splash::log()->err(Splash::trans('ErrLocalInterface', $className, LocalClassInterface::class)); } } catch (Exception $exc) { echo $exc->getMessage(); return Splash::log()->err($exc->getMessage()); } $this->ValidLocalClass[$className] = true; return $this->ValidLocalClass[$className]; }
php
{ "resource": "" }
q6104
Validator.isValidLocalParameterArray
train
public function isValidLocalParameterArray($input) { //====================================================================// // Verify Array Given if (!is_array($input)) { return Splash::log()->err(Splash::trans('ErrorCfgNotAnArray', get_class($input))); } //====================================================================// // Required Parameters are Available //====================================================================// if (!array_key_exists('WsIdentifier', $input)) { return Splash::log()->err(Splash::trans('ErrWsNoId')); } if (!array_key_exists('WsEncryptionKey', $input)) { return Splash::log()->err(Splash::trans('ErrWsNoKey')); } return true; }
php
{ "resource": "" }
q6105
Validator.isValidServerInfos
train
public function isValidServerInfos() { $infos = Splash::ws()->getServerInfos(); //====================================================================// // Verify Array Given if (!is_a($infos, 'ArrayObject')) { return Splash::log()->err(Splash::trans('ErrInfosNotArrayObject', get_class($infos))); } if (defined('SPLASH_DEBUG') && !empty(SPLASH_DEBUG)) { Splash::log()->war('Host : '.$infos['ServerHost']); Splash::log()->war('Path : '.$infos['ServerPath']); } //====================================================================// // Required Parameters are Available //====================================================================// if (!isset($infos['ServerHost']) || empty($infos['ServerHost'])) { Splash::log()->err(Splash::trans('ErrEmptyServerHost')); return Splash::log()->err(Splash::trans('ErrEmptyServerHostDesc')); } if (!isset($infos['ServerPath']) || empty($infos['ServerPath'])) { Splash::log()->err(Splash::trans('ErrEmptyServerPath')); return Splash::log()->err(Splash::trans('ErrEmptyServerPathDesc')); } //====================================================================// // Detect Local Installations //====================================================================// $this->isLocalInstallation($infos); return true; }
php
{ "resource": "" }
q6106
Validator.isLocalInstallation
train
public function isLocalInstallation($infos) { if (false !== strpos($infos['ServerHost'], 'localhost')) { Splash::log()->war(Splash::trans('WarIsLocalhostServer')); } elseif (false !== strpos($infos['ServerIP'], '127.0.0.1')) { Splash::log()->war(Splash::trans('WarIsLocalhostServer')); } if ('https' === Splash::input('REQUEST_SCHEME')) { Splash::log()->war(Splash::trans('WarIsHttpsServer')); } }
php
{ "resource": "" }
q6107
Validator.isValidObject
train
public function isValidObject($objectType) { //====================================================================// // Verify Result in Cache if (isset($this->ValidLocalObject[$objectType])) { return $this->ValidLocalObject[$objectType]; } $this->ValidLocalObject[$objectType] = false; //====================================================================// // Verify Local Core Class Exist & Is Valid if (!$this->isValidLocalClass()) { return false; } //====================================================================// // Check if Object Manager is NOT Overriden if (!(Splash::local() instanceof ObjectsProviderInterface)) { //====================================================================// // Verify Object File Exist & is Valid if (!$this->isValidObjectFile($objectType)) { return false; } } //====================================================================// // Verify Object Class Exist & is Valid if (!$this->isValidObjectClass($objectType)) { return false; } $this->ValidLocalObject[$objectType] = true; return true; }
php
{ "resource": "" }
q6108
Validator.isValidObjectId
train
public function isValidObjectId($objectId) { //====================================================================// // Checks Id is not Null if (is_null($objectId)) { return Splash::log()->err('ErrEmptyObjectId'); } //====================================================================// // Checks Id is String or Int if (!is_string($objectId) && !is_numeric($objectId)) { return Splash::log()->err('ErrWrongObjectId'); } //====================================================================// // Checks List Not Empty if (is_numeric($objectId) && ($objectId < 0)) { return Splash::log()->err('ErrNegObjectId'); } return Splash::log()->deb('MsgObjectIdOk'); }
php
{ "resource": "" }
q6109
Validator.isValidObjectFieldsList
train
public function isValidObjectFieldsList($fieldsList) { //====================================================================// // Checks List Type if (!is_array($fieldsList) && !($fieldsList instanceof ArrayObject)) { return Splash::log()->err('ErrWrongFieldList'); } //====================================================================// // Checks List Not Empty if (empty($fieldsList)) { return Splash::log()->err('ErrEmptyFieldList'); } return Splash::log()->deb('MsgFieldListOk'); }
php
{ "resource": "" }
q6110
Validator.isValidWidget
train
public function isValidWidget($widgetType) { //====================================================================// // Verify Result in Cache if (isset($this->ValidLocalWidget[$widgetType])) { return $this->ValidLocalWidget[$widgetType]; } $this->ValidLocalWidget[$widgetType] = false; //====================================================================// // Verify Local Core Class Exist & Is Valid if (!$this->isValidLocalClass()) { return false; } //====================================================================// // Check if Widget Manager is NOT Overriden if (!(Splash::local() instanceof WidgetsProviderInterface)) { //====================================================================// // Verify Widget File Exist & is Valid if (!$this->isValidWidgetFile($widgetType)) { return false; } } //====================================================================// // Verify Widget Class Exist & is Valid if (!$this->isValidWidgetClass($widgetType)) { return false; } $this->ValidLocalWidget[$widgetType] = true; return true; }
php
{ "resource": "" }
q6111
Validator.isValidLocalPath
train
public function isValidLocalPath() { //====================================================================// // Verify no result in Cache if (!isset($this->ValidLocalPath)) { $path = Splash::getLocalPath(); //====================================================================// // Verify Local Path Exist if (is_null($path) || !is_dir($path)) { $this->ValidLocalPath = false; return Splash::log()->err(Splash::trans('ErrLocalPath', (string) $path)); } $this->ValidLocalPath = true; } return $this->ValidLocalPath; }
php
{ "resource": "" }
q6112
Validator.isValidPHPVersion
train
public function isValidPHPVersion() { if (version_compare(PHP_VERSION, '5.6.0') < 0) { return Splash::log()->err( 'PHP : Your PHP version is too low to use Splash ('.PHP_VERSION.'). PHP >5.6 is Requiered.' ); } return Splash::log()->msg( 'PHP : Your PHP version is compatible with Splash ('.PHP_VERSION.')' ); }
php
{ "resource": "" }
q6113
Validator.isValidPHPExtensions
train
public function isValidPHPExtensions() { $extensions = array('xml', 'soap', 'curl'); foreach ($extensions as $extension) { if (!extension_loaded($extension)) { return Splash::log()->err( 'PHP :'.$extension.' PHP Extension is required to use Splash PHP Module.' ); } } return Splash::log()->msg( 'PHP : Required PHP Extension are installed ('.implode(', ', $extensions).')' ); }
php
{ "resource": "" }
q6114
Validator.isValidSOAPMethod
train
public function isValidSOAPMethod() { if (!in_array(Splash::configuration()->WsMethod, array('SOAP', 'NuSOAP'), true)) { return Splash::log()->err( 'Config : Your selected an unknown SOAP Method ('.Splash::configuration()->WsMethod.').' ); } return Splash::log()->msg( 'Config : SOAP Method is Ok ('.Splash::configuration()->WsMethod.').' ); }
php
{ "resource": "" }
q6115
Validator.isValidConfigurator
train
public function isValidConfigurator($className) { //====================================================================// // Verify Class Exists if (false == class_exists($className)) { return Splash::log()->err('Configurator Class Not Found: '.$className); } //====================================================================// // Verify Configurator Class Extends ConfiguratorInterface try { $class = new $className(); if (!($class instanceof ConfiguratorInterface)) { return Splash::log()->err(Splash::trans('ErrLocalInterface', $className, ConfiguratorInterface::class)); } } catch (Exception $exc) { echo $exc->getMessage(); return Splash::log()->err($exc->getMessage()); } return true; }
php
{ "resource": "" }
q6116
Validator.isValidObjectFile
train
private function isValidObjectFile($objectType) { //====================================================================// // Verify Local Path Exist if (false == $this->isValidLocalPath()) { return false; } //====================================================================// // Verify Object File Exist $filename = Splash::getLocalPath().'/Objects/'.$objectType.'.php'; if (false == file_exists($filename)) { $msg = 'Local Object File Not Found.</br>'; $msg .= 'Current Filename : '.$filename.''; return Splash::log()->err($msg); } return true; }
php
{ "resource": "" }
q6117
Validator.isValidObjectClass
train
private function isValidObjectClass($objectType) { //====================================================================// // Check if Object Manager is Overriden if (Splash::local() instanceof ObjectsProviderInterface) { //====================================================================// // Retrieve Object Manager ClassName $className = get_class(Splash::local()->object($objectType)); } else { $className = SPLASH_CLASS_PREFIX.'\\Objects\\'.$objectType; } //====================================================================// // Verify Splash Local Core Class Exists if (false == class_exists($className)) { return Splash::log()->err(Splash::trans('ErrLocalClass', $objectType)); } //====================================================================// // Verify Local Object Core Class Functions Exists //====================================================================// //====================================================================// // Read Object Disable Flag if (false == $this->isValidLocalFunction('getIsDisabled', $className)) { return false; } if (Splash::configurator()->isDisabled($objectType, $className::getIsDisabled())) { return false; } //====================================================================// // Verify Local Object Class Implements ObjectInterface return is_subclass_of($className, ObjectInterface::class); }
php
{ "resource": "" }
q6118
Validator.isValidWidgetFile
train
private function isValidWidgetFile($widgetType) { //====================================================================// // Verify Local Path Exist if (false == $this->isValidLocalPath()) { return false; } //====================================================================// // Verify Object File Exist $filename = Splash::getLocalPath().'/Widgets/'.$widgetType.'.php'; if (false == file_exists($filename)) { $msg = 'Local Widget File Not Found.</br>'; $msg .= 'Current Filename : '.$filename.''; return Splash::log()->err($msg); } return true; }
php
{ "resource": "" }
q6119
Validator.isValidWidgetClass
train
private function isValidWidgetClass($widgetType) { //====================================================================// // Check if Widget Manager is Overriden if (Splash::local() instanceof WidgetsProviderInterface) { //====================================================================// // Retrieve Widget Manager ClassName $className = get_class(Splash::local()->widget($widgetType)); } else { $className = SPLASH_CLASS_PREFIX.'\\Widgets\\'.$widgetType; } //====================================================================// // Verify Splash Local Core Class Exists if (false == class_exists($className)) { return Splash::log()->err(Splash::trans('ErrLocalClass', $widgetType)); } //====================================================================// // Verify Local Widget Core Class Functions Exists //====================================================================// //====================================================================// // Read Object Disable Flag if (false == $this->isValidLocalFunction('getIsDisabled', $className)) { $this->ValidLocalWidget[$widgetType] = false; return false; } if ($className::getIsDisabled()) { $this->ValidLocalWidget[$widgetType] = false; return false; } //====================================================================// // Verify Local Object Class Implements WidgetInterface return is_subclass_of($className, WidgetInterface::class); }
php
{ "resource": "" }
q6120
CallbackFactory.instantiateCallback
train
protected function instantiateCallback($callbackClass, $callbackType) { if (!is_a($callbackClass, static::$callbackInterface, true)) { throw new RuntimeException("Callback class '{$callbackClass}' does not implements '" . static::$callbackInterface . "' interface."); } return new $callbackClass($callbackType); }
php
{ "resource": "" }
q6121
PostgreSQL.getTableGeomType
train
public function getTableGeomType($tableName, $schema = null) { $connection = $this->connection; if (strpos($tableName, '.')) { list($schema, $tableName) = explode('.', $tableName); } $_schema = $schema ? $connection->quote($schema) : 'current_schema()'; $type = $connection->query("SELECT \"type\" FROM geometry_columns WHERE f_table_schema = " . $_schema . " AND f_table_name = " . $connection->quote($tableName))->fetchColumn(); return $type; }
php
{ "resource": "" }
q6122
PostgreSQL.getLastInsertId
train
public function getLastInsertId() { $connection = $this->getConnection(); $id = $connection->lastInsertId(); if ($id < 1) { $fullTableName = $this->tableName; $fullUniqueIdName = $connection->quoteIdentifier($this->getUniqueId()); $sql = /** @lang PostgreSQL */ "SELECT $fullUniqueIdName FROM $fullTableName LIMIT 1 OFFSET (SELECT count($fullUniqueIdName)-1 FROM $fullTableName )"; $id = $connection->fetchColumn($sql); } return $id; }
php
{ "resource": "" }
q6123
PostgreSQL.getNodeFromGeom
train
public function getNodeFromGeom($waysVerticesTableName, $waysGeomFieldName, $ewkt, $transformTo = null, $idKey = "id") { $db = $this->getConnection(); $geom = "ST_GeometryFromText('" . $db->quote($ewkt) . "')"; if ($transformTo) { $geom = "ST_TRANSFORM($geom, $transformTo)"; } return $db->fetchColumn(/** @lang PostgreSQL */ "SELECT {$db->quoteIdentifier($idKey)}, ST_Distance({$db->quoteIdentifier($waysGeomFieldName)}, $geom) AS distance FROM {$db->quoteIdentifier($waysVerticesTableName)} ORDER BY distance ASC LIMIT 1"); }
php
{ "resource": "" }
q6124
PostgreSQL.routeBetweenNodes
train
public function routeBetweenNodes( $waysTableName, $waysGeomFieldName, $startNodeId, $endNodeId, $srid, $directedGraph = false, $hasReverseCost = false) { /** @var Connection $db */ $db = $this->getConnection(); $waysTableName = $db->quoteIdentifier($waysTableName); $geomFieldName = $db->quoteIdentifier($waysGeomFieldName); $directedGraph = $directedGraph ? 'TRUE' : 'FALSE'; // directed graph [true|false] $hasReverseCost = $hasReverseCost && $directedGraph ? 'TRUE' : 'FALSE'; // directed graph [true|false] $results = $db->query("SELECT route.seq as orderId, route.id1 as startNodeId, route.id2 as endNodeId, route.cost as distance, ST_AsEWKT ($waysTableName.$geomFieldName) AS geom FROM pgr_dijkstra ( 'SELECT gid AS id, source, target, length AS cost FROM $waysTableName', $startNodeId, $endNodeId, $directedGraph, $hasReverseCost ) AS route LEFT JOIN $waysTableName ON route.id2 = $waysTableName.gid")->fetchAll(); return $this->prepareResults($results, $srid); }
php
{ "resource": "" }
q6125
Insurer.all
train
public function all(string $country = 'MY', ?Query $query = null): Response { return $this->send( 'GET', "insurer/{$country}", $this->getApiHeaders(), $this->buildHttpQuery($query) ); }
php
{ "resource": "" }
q6126
FeatureType.getById
train
public function getById($id, $srid = null) { $rows = $this->getSelectQueryBuilder($srid) ->where($this->getUniqueId() . " = :id") ->setParameter('id', $id) ->execute() ->fetchAll(); $this->prepareResults($rows, $srid); return reset($rows); }
php
{ "resource": "" }
q6127
FeatureType.search
train
public function search(array $criteria = array()) { /** @var Statement $statement */ /** @var Feature $feature */ $maxResults = isset($criteria['maxResults']) ? intval($criteria['maxResults']) : self::MAX_RESULTS; $intersect = isset($criteria['intersectGeometry']) ? $criteria['intersectGeometry'] : null; $returnType = isset($criteria['returnType']) ? $criteria['returnType'] : null; $srid = isset($criteria['srid']) ? $criteria['srid'] : $this->getSrid(); $where = isset($criteria['where']) ? $criteria['where'] : null; $queryBuilder = $this->getSelectQueryBuilder($srid); $connection = $queryBuilder->getConnection(); $whereConditions = array(); // add GEOM where condition if ($intersect) { $geometry = BaseDriver::roundGeometry($intersect, 2); $whereConditions[] = $this->getDriver()->getIntersectCondition($geometry, $this->geomField, $srid, $this->getSrid()); } // add filter (https://trac.wheregroup.com/cp/issues/3733) if (!empty($this->sqlFilter)) { $securityContext = $this->container->get("security.context"); $user = $securityContext->getUser(); $sqlFilter = strtr($this->sqlFilter, array( ':userName' => $user->getUsername() )); $whereConditions[] = $sqlFilter; } // add second filter (https://trac.wheregroup.com/cp/issues/4643) if ($where) { $whereConditions[] = $where; } if (isset($criteria["source"]) && isset($criteria["distance"])) { $whereConditions[] = "ST_DWithin(t." . $this->getGeomField() . "," . $connection->quote($criteria["source"]) . "," . $criteria['distance'] . ')'; } if (count($whereConditions)) { $queryBuilder->where(join(" AND ", $whereConditions)); } $queryBuilder->setMaxResults($maxResults); // $queryBuilder->setParameters($params); // $sql = $queryBuilder->getSQL(); $statement = $queryBuilder->execute(); $rows = $statement->fetchAll(); $hasResults = count($rows) > 0; // Convert to Feature object if ($hasResults) { $this->prepareResults($rows, $srid); } if ($returnType == "FeatureCollection") { $rows = $this->toFeatureCollection($rows); } return $rows; }
php
{ "resource": "" }
q6128
FeatureType.getTableSequenceName
train
public function getTableSequenceName() { $connection = $this->getConnection(); $result = $connection->fetchColumn("SELECT column_default from information_schema.columns where table_name='" . $this->getTableName() . "' and column_name='" . $this->getUniqueId() . "'"); $result = explode("'", $result); return $result[0]; }
php
{ "resource": "" }
q6129
FeatureType.getFileUri
train
public function getFileUri($fieldName = null) { $path = self::UPLOAD_DIR_NAME . "/" . $this->getTableName(); if ($fieldName) { $path .= "/" . $fieldName; } foreach ($this->getFileInfo() as $fileInfo) { if (isset($fileInfo["field"]) && isset($fileInfo["uri"]) && $fieldName == $fileInfo["field"]) { $path = $fileInfo["uri"]; break; } } return $path; }
php
{ "resource": "" }
q6130
FeatureType.getFilePath
train
public function getFilePath($fieldName = null, $createPath = true) { $path = realpath(AppComponent::getUploadsDir($this->container)) . "/" . $this->getFileUri($fieldName); foreach ($this->getFileInfo() as $fileInfo) { if (isset($fileInfo["field"]) && isset($fileInfo["path"]) && $fieldName == $fileInfo["field"]) { $path = $fileInfo["path"]; break; } } if ($createPath && !is_dir($path)) { mkdir($path, 0775, true); } return $path; }
php
{ "resource": "" }
q6131
FeatureType.genFilePath
train
public function genFilePath($fieldName = null) { $id = $this->countFiles($fieldName) + 1; $src = null; $path = null; while (1) { $path = $id; //. "-" . System::generatePassword(12) ; $src = $this->getFilePath($fieldName) . "/" . $path; if (!file_exists($src)) { break; } $id++; } return array( "src" => $src, "path" => $path ); }
php
{ "resource": "" }
q6132
FeatureType.countFiles
train
private function countFiles($fieldName = null) { $finder = new Finder(); $finder->files()->in($this->getFilePath($fieldName)); return count($finder); }
php
{ "resource": "" }
q6133
FeatureType.routeBetweenGeom
train
public function routeBetweenGeom($sourceGeom, $targetGeom) { $driver = $this->getDriver(); $srid = $this->getSrid(); $sourceNode = $driver->getNodeFromGeom($this->waysVerticesTableName, $this->waysGeomFieldName, $sourceGeom, $srid, 'id'); $targetNode = $driver->getNodeFromGeom($this->waysVerticesTableName, $this->waysGeomFieldName, $targetGeom, $srid, 'id'); return $driver->routeBetweenNodes($this->waysVerticesTableName, $this->waysGeomFieldName, $sourceNode, $targetNode, $srid); }
php
{ "resource": "" }
q6134
FeatureType.getByIds
train
public function getByIds($ids, $prepareResults = true) { $queryBuilder = $this->getSelectQueryBuilder(); $connection = $queryBuilder->getConnection(); $rows = $queryBuilder->where( $queryBuilder->expr()->in($this->getUniqueId(), array_map(function ($id) use ($connection) { return $connection->quote($id); }, $ids)) )->execute()->fetchAll(); if ($prepareResults) { $this->prepareResults($rows); } return $rows; }
php
{ "resource": "" }
q6135
FeatureType.getConfiguration
train
public function getConfiguration($key = null) { return isset($this->_args[ $key ]) ? $this->_args[ $key ] : null; }
php
{ "resource": "" }
q6136
FeatureType.export
train
public function export(array &$rows) { $config = $this->getConfiguration('export'); $fieldNames = isset($config['fields']) ? $config['fields'] : null; $result = array(); if ($fieldNames) { foreach ($rows as &$row) { $exportRow = array(); foreach ($fieldNames as $fieldName => $fieldCode) { $exportRow[ $fieldName ] = $this->evaluateField($row, $fieldCode); } $result[] = $exportRow; } } else { $result = &$rows; } return $result; }
php
{ "resource": "" }
q6137
ConsoleExporterTrait.getConsoleLog
train
public function getConsoleLog($clean = false) { $result = null; //====================================================================// // Read All Messages as Html $result .= $this->getConsole($this->err, ' - Error => ', self::CMD_COLOR_ERR); $result .= $this->getConsole($this->war, ' - Warning => ', self::CMD_COLOR_WAR); $result .= $this->getConsole($this->msg, ' - Messages => ', self::CMD_COLOR_MSG); $result .= $this->getConsole($this->deb, ' - Debug => ', self::CMD_COLOR_DEB); $result .= "\e[0m"; //====================================================================// // Clear Log Buffer If Requiered if ($clean) { $this->cleanLog(); } return $result; }
php
{ "resource": "" }
q6138
ConsoleExporterTrait.getConsole
train
private function getConsole($msgArray, $title = '', $color = 0) { $result = ''; if ((is_array($msgArray) || $msgArray instanceof Countable) && count($msgArray)) { //====================================================================// // Add Messages foreach ($msgArray as $txt) { $result .= self::getConsoleLine($txt, $title, $color); } } return $result; }
php
{ "resource": "" }
q6139
AttributeHandler.processAttributeToResource
train
protected function processAttributeToResource($object, ResourceObject $resource, Attribute $definition) { $name = $definition->getName(); $getter = $definition->getGetter(); $value = $object->$getter(); if ($value === null && ! $definition->getProcessNull()) { return; } $value = $this->typeManager->toResource($definition, $value); $resource->setAttribute($name, $value); }
php
{ "resource": "" }
q6140
AttributeHandler.processResourceToAttribute
train
protected function processResourceToAttribute($object, ResourceObject $resource, Attribute $definition) { $name = $definition->getName(); if (! $resource->hasAttribute($name)) { return; } $value = $resource->getAttribute($name); if ($value === null && ! $definition->getProcessNull()) { return; } $value = $this->typeManager->fromResource($definition, $value); $setter = $definition->getSetter(); $object->$setter($value); }
php
{ "resource": "" }
q6141
Html._parse_form_attributes
train
private static function _parse_form_attributes($attributes, $default) { if (is_array($attributes)) { foreach ($default as $key => $val) { if (isset($attributes[$key])) { $default[$key] = $attributes[$key]; unset($attributes[$key]); } } if (count($attributes) > 0) { $default = array_merge($default, $attributes); } } $att = ''; foreach ($default as $key => $val) { if ($key == 'value') { $val = self::form_prep($val, $default['name']); } $att .= $key . '="' . $val . '" '; } return $att; }
php
{ "resource": "" }
q6142
DateIntervalHandler.resolveFormat
train
protected function resolveFormat(\DateInterval $interval): string { $baseFormat = $this->resolveBaseFormat($interval); $timeFormat = $this->resolveTimeFormat($interval); if ($baseFormat === '') { if ($timeFormat === '') { return ''; } return 'PT' . $timeFormat; } if ($timeFormat === '') { return 'P' . $baseFormat; } return 'P' . $baseFormat . 'T' . $timeFormat; }
php
{ "resource": "" }
q6143
DateIntervalHandler.resolveBaseFormat
train
protected function resolveBaseFormat(\DateInterval $interval): string { $format = ''; if ($interval->y > 0) { $format .= '%yY'; } if ($interval->m > 0) { $format .= '%mM'; } if ($interval->d > 0) { $format .= '%dD'; } return $format; }
php
{ "resource": "" }
q6144
DateIntervalHandler.resolveTimeFormat
train
protected function resolveTimeFormat(\DateInterval $interval): string { $format = ''; if ($interval->h > 0) { $format .= '%hH'; } if ($interval->i > 0) { $format .= '%iM'; } if ($interval->s > 0) { $format .= '%sS'; } return $format; }
php
{ "resource": "" }
q6145
App.getInstance
train
public static function getInstance(ServerRequestInterface $request) { if (is_null(self::$instance)) { $class = get_called_class(); self::$instance = new $class($request); } return self::$instance; }
php
{ "resource": "" }
q6146
App.run
train
public function run() { $request = clone $this->request; $response = new Response(404, new Stream(null)); $this->container->callHook('app.response.before', [ &$request, &$response ]); if (($route = $this->router->parse($request)) && $response->getStatusCode() == 404) { $this->container->callHook($route[ 'key' ] . '.response.before', [ &$request, &$response ]); $exec = $this->router->execute($route, $request); $response = $this->parseResponse($exec); $this->container->callHook($route[ 'key' ] . '.response.after', [ $this->request, &$response ]); } $this->container->callHook('app.' . $response->getStatusCode(), [ $this->request, &$response ]); $this->container->callHook('app.response.after', [ $this->request, &$response ]); return $response; }
php
{ "resource": "" }
q6147
App.loadRoutesAndServices
train
protected function loadRoutesAndServices() { foreach ($this->modules as $module) { if ($module->getPathRoutes()) { $routesConfig = Util::getJson($module->getPathRoutes()); $this->routes += $routesConfig; } if ($module->getPathServices()) { $servicesConfig = Util::getJson($module->getPathServices()); $this->services += $servicesConfig; } } }
php
{ "resource": "" }
q6148
YamlDefinitionProvider.readConfig
train
protected function readConfig(string $path): array { if (! is_readable($path)) { throw new DefinitionProviderException(sprintf('File "%s" with definition is not readable.', $path)); } $content = file_get_contents($path); $config = $this->parser->parse($content); $schema = $this->getSchema(); return $this->processor->process($schema, [$config]); }
php
{ "resource": "" }
q6149
YamlDefinitionProvider.getSchema
train
protected function getSchema(): NodeInterface { if ($this->schema === null) { $this->schema = $this->config->getConfigTreeBuilder()->buildTree(); } return $this->schema; }
php
{ "resource": "" }
q6150
Drivers.create
train
public function create(int $fleetId, string $fullname, string $identification, array $optional = []): Response { $this->requiresAccessToken(); return $this->sendJson( 'POST', "fleets/{$fleetId}/drivers", $this->getApiHeaders(), \array_merge($optional, \compact('fullname', 'identification')) ); }
php
{ "resource": "" }
q6151
AnnotationDefinitionProvider.createDefinition
train
protected function createDefinition(\ReflectionClass $reflection): Definition { $definition = new Definition($reflection->getName()); foreach ($this->processors as $processor) { $processor->process($reflection, $definition); } $parent = $reflection->getParentClass(); if ($parent !== false) { $definition->merge($this->createDefinition($parent)); } foreach ($reflection->getTraits() as $trait) { $definition->merge($this->createDefinition($trait)); } return $definition; }
php
{ "resource": "" }
q6152
LinkHandler.createLink
train
protected function createLink(LinkDefinition $definition, LinkData $data): LinkObject { $reference = $data->getReference(); $metadata = array_replace( $data->getMetadata(), $definition->getMetadata() ); return new LinkObject($reference, $metadata); }
php
{ "resource": "" }
q6153
Application.run
train
function run() { // Set default error level, In dev env show all errors // ini_set('display_errors', Config::get('show_errors') ? 'Off' : 'Off'); ini_set('display_errors', 'Off'); error_reporting(E_ALL | E_STRICT); if (!defined('SERVER_MODE')) { // Mark server mode define('SERVER_MODE', 'fpm'); } try { $route = (\ePHP\Core\Route::init())->findRoute(); // dumpdie($route); if (empty($route)) { \show_404(); } // 整理参数 $_GET['controller'] = $route[0]; $_GET['action'] = $route[1]; $controller_name = $route[2]; $action_name = $_GET['action']; $_REQUEST = array_merge($_COOKIE, $_GET, $_POST); // 检查ACTION是否存在 if ( !method_exists($controller_name, $action_name) ) { if (defined('RUN_ENV') && RUN_ENV == 'prod') { \show_404(); } else { \show_error("method {$action_name}() is not defined in {$controller_name}"); } } if (SERVER_MODE === 'fpm') { call_user_func([new $controller_name(), $action_name]); } else if (SERVER_MODE === 'swoole') { try { // $c_init = new $controller_name(); // // $c_init->request = $request; // // $c_init->response = $response; // $c_init->{$action_name}(); call_user_func([new $controller_name(), $action_name]); } catch (\Swoole\ExitException $e) { // 屏蔽exit异常,不输出任何信息 return ; } } } catch (\ePHP\Exception\CommonException $e) { // ExitException don't show error message if ($e->getCode() === -99) { return ; } echo $e; } }
php
{ "resource": "" }
q6154
Profile.update
train
public function update(array $payload): Response { $this->requiresAccessToken(); return $this->sendJson( 'PATCH', 'profile', $this->getApiHeaders(), $this->mergeApiBody($payload) ); }
php
{ "resource": "" }
q6155
Profile.verifyPassword
train
public function verifyPassword(string $password): bool { $this->requiresAccessToken(); try { $response = $this->send( 'POST', 'auth/verify', $this->getApiHeaders(), $this->mergeApiBody(compact('password')) ); } catch (UnauthorizedException $e) { return false; } return $response->toArray()['success'] === true; }
php
{ "resource": "" }
q6156
Profile.uploadAvatar
train
public function uploadAvatar(string $file): Response { $this->requiresAccessToken(); return $this->stream( 'POST', 'profile/avatar', $this->getApiHeaders(), $this->getApiBody(), compact('file') ); }
php
{ "resource": "" }
q6157
ContactServiceProvider.registerContactMailer
train
protected function registerContactMailer() { $this->app->bind('contact.mailer', function ($app) { $mail = $app['mailer']; $home = $app['url']->to('/'); $path = $app['config']['contact.path']; $email = $app['config']['contact.email']; $name = $app['config']['app.name']; return new Mailer($mail, $home, $path, $email, $name); }); $this->app->alias('contact.mailer', Mailer::class); }
php
{ "resource": "" }
q6158
ContactServiceProvider.registerContactController
train
protected function registerContactController() { $this->app->bind(ContactController::class, function ($app) { $throttler = $app['throttle']->get($app['request'], 2, 30); $path = $app['config']['contact.path']; return new ContactController($throttler, $path); }); }
php
{ "resource": "" }
q6159
IntelParserTrait.verifyRequiredFields
train
public function verifyRequiredFields() { foreach ($this->Fields() as $field) { //====================================================================// // Field is NOT required if (!$field["required"]) { continue; } //====================================================================// // Field is Required but not available if (!$this->verifyRequiredFieldIsAvailable($field["id"])) { return Splash::log()->err( "ErrLocalFieldMissing", __CLASS__, __FUNCTION__, $field["name"]."(".$field["id"].")" ); } } return true; }
php
{ "resource": "" }
q6160
IntelParserTrait.setObjectData
train
private function setObjectData() { //====================================================================// // Walk on All Requested Fields //====================================================================// $fields = is_a($this->in, "ArrayObject") ? $this->in->getArrayCopy() : $this->in; foreach ($fields as $fieldName => $fieldData) { //====================================================================// // Write Requested Fields foreach ($this->identifySetMethods() as $method) { $this->{$method}($fieldName, $fieldData); } } //====================================================================// // Verify Requested Fields List is now Empty => All Fields Writen Successfully //====================================================================// if (count($this->in)) { foreach ($this->in as $fieldName => $fieldData) { Splash::log()->err("ErrLocalWrongField", __CLASS__, __FUNCTION__, $fieldName); } return false; } return true; }
php
{ "resource": "" }
q6161
IntelParserTrait.identifyMethods
train
private static function identifyMethods($prefix) { //====================================================================// // Prepare List of Available Methods $result = array(); foreach (get_class_methods(__CLASS__) as $method) { if (0 !== strpos($method, $prefix)) { continue; } if (false === strpos($method, "Fields")) { continue; } $result[] = $method; } return $result; }
php
{ "resource": "" }
q6162
IntelParserTrait.verifyRequiredFieldIsAvailable
train
private function verifyRequiredFieldIsAvailable($fieldId) { //====================================================================// // Detect List Field Names if (!method_exists($this, "Lists") || !self::lists()->listName($fieldId)) { //====================================================================// // Simple Field is Required but not available if (empty($this->in[$fieldId])) { return false; } return true; } //====================================================================// // List Field is required $listName = self::lists()->ListName($fieldId); $fieldName = self::lists()->FieldName($fieldId); //====================================================================// // Check List is available if (empty($this->in[$listName])) { return false; } //====================================================================// // list is a List... if (!is_array($this->in[$listName]) && !is_a($this->in[$listName], "ArrayObject")) { return false; } //====================================================================// // Check Field is Available foreach ($this->in[$listName] as $item) { if (empty($item[$fieldName])) { return false; } } return true; }
php
{ "resource": "" }
q6163
AbstractConfigurator.getConfigurationValue
train
private function getConfigurationValue($key1, $key2 = null) { //====================================================================// // Load Configuration from Configurator $config = $this->getConfiguration(); //====================================================================// // Check Configuration is Valid if (!is_array($config) || empty($config)) { return null; } //====================================================================// // Check Main Configuration Key Exists if (!isset($config[$key1])) { return null; } //====================================================================// // Check Second Configuration Key Required if (is_null($key2)) { return $config[$key1]; } //====================================================================// // Check Second Configuration Key Exists return isset($config[$key1][$key2]) ? $config[$key1][$key2] : null; }
php
{ "resource": "" }
q6164
AbstractConfigurator.sercureParameters
train
private static function sercureParameters(&$parameters) { //====================================================================// // Detect Travis from SERVER CONSTANTS => Allow Unsecure for Testing if (!empty(Splash::input('SPLASH_TRAVIS'))) { return; } //====================================================================// // Walk on Unsecure Parameter Keys foreach (self::UNSECURED_PARAMETERS as $index) { //====================================================================// // Check Parameter Exists if (isset($parameters[$index])) { unset($parameters[$index]); } } }
php
{ "resource": "" }
q6165
AbstractConfigurator.updateField
train
private static function updateField($field, $values) { Splash::log()->trace(); //====================================================================// // Check New Configuration is an Array if (!is_array($values)) { return $field; } //====================================================================// // Field Type self::updateFieldStrVal($field, $values, "type"); // Field Name self::updateFieldStrVal($field, $values, "name"); // Field Description self::updateFieldStrVal($field, $values, "desc"); // Field Group self::updateFieldStrVal($field, $values, "group"); // Field MetaData self::updateFieldMeta($field, $values); //====================================================================// // Field Favorite Sync Mode self::updateFieldStrVal($field, $values, "syncmode"); //====================================================================// // Field is Required Flag self::updateFieldBoolVal($field, $values, "required"); //====================================================================// // Field Read Allowed self::updateFieldBoolVal($field, $values, "read"); //====================================================================// // Field Write Allowed self::updateFieldBoolVal($field, $values, "write"); //====================================================================// // Field is Listed Flag self::updateFieldBoolVal($field, $values, "inlist"); //====================================================================// // Field is Logged Flag self::updateFieldBoolVal($field, $values, "log"); return $field; }
php
{ "resource": "" }
q6166
AbstractConfigurator.updateFieldStrVal
train
private static function updateFieldStrVal(&$field, $values, $key) { if (isset($values[$key]) && is_string($values[$key])) { $field->{$key} = $values[$key]; } }
php
{ "resource": "" }
q6167
AbstractConfigurator.updateFieldBoolVal
train
private static function updateFieldBoolVal(&$field, $values, $key) { if (isset($values[$key]) && is_scalar($values[$key])) { $field->{$key} = (bool) $values[$key]; } }
php
{ "resource": "" }
q6168
AbstractConfigurator.updateFieldMeta
train
private static function updateFieldMeta(&$field, $values) { // Update Field Meta ItemType self::updateFieldStrVal($field, $values, "itemtype"); // Update Field Meta ItemProp self::updateFieldStrVal($field, $values, "itemprop"); // Update Field Meta Tag if (isset($values["itemprop"]) || isset($values["itemtype"])) { if (is_string($field->itemprop) && is_string($field->itemtype)) { $field->tag = md5($field->itemprop.IDSPLIT.$field->itemtype); } } }
php
{ "resource": "" }
q6169
FeatureTypeService.get
train
public function get($id) { if (empty($this->instances[$id])) { $declarations = $this->getFeatureTypeDeclarations(); if (empty($declarations[$id])) { throw new \RuntimeException("No FeatureType with id " . var_export($id, true)); } $this->instances[$id] = new FeatureType($this->container, $declarations[$id]); } return $this->instances[$id]; }
php
{ "resource": "" }
q6170
FeatureTypeService.search
train
public function search() { foreach ($this->getFeatureTypeDeclarations() as $id => $declaration) { if (empty($this->instances[$id])) { $this->instances[$id] = new FeatureType($this->container, $declaration); } } return $this->instances; }
php
{ "resource": "" }
q6171
Typo3.createMessage
train
public function createMessage( $charset = 'UTF-8' ) { $closure = $this->closure; return new \Aimeos\MW\Mail\Message\Typo3( $closure(), $charset ); }
php
{ "resource": "" }
q6172
Typo3.send
train
public function send( \Aimeos\MW\Mail\Message\Iface $message ) { $message->getObject()->send(); }
php
{ "resource": "" }
q6173
Attribute.merge
train
public function merge(self $attribute) { if ($this->propertyName === null && $attribute->hasPropertyName()) { $this->propertyName = $attribute->getPropertyName(); } if ($this->type === null && $attribute->hasType()) { $this->type = $attribute->getType(); } if ($this->many === null && $attribute->hasManyDefined()) { $this->many = $attribute->isMany(); } if (empty($this->typeParameters)) { $this->typeParameters = $attribute->getTypeParameters(); } if ($this->processNull === null && $attribute->hasProcessNull()) { $this->processNull = $attribute->getProcessNull(); } }
php
{ "resource": "" }
q6174
Command.execute
train
public function execute(array $args, array $options = array()) { if (!count($args)) { throw new ConsoleException("Missing subcommand name"); } $command = ucfirst(Utils::camelize(array_shift($args))); $methodName = "execute$command"; if (!method_exists($this, $methodName)) { throw new ConsoleException("Command '$command' does not exist"); } $method = new ReflectionMethod($this, $methodName); $params = Utils::computeFuncParams($method, $args, $options); return $method->invokeArgs($this, $params); }
php
{ "resource": "" }
q6175
Command.writeerr
train
public function writeerr($text) { return $this->write($text, Colors::RED | Colors::BOLD, TextWriter::STDERR); }
php
{ "resource": "" }
q6176
Query.includes
train
protected function includes($includes) { $includes = \is_array($includes) ? $includes : \func_get_args(); $this->includes = $includes; return $this; }
php
{ "resource": "" }
q6177
Query.onTimeZone
train
protected function onTimeZone(?string $timeZoneCode) { if (\is_null($timeZoneCode)) { $this->timezone = null; } elseif (\in_array($timeZoneCode, \timezone_identifiers_list())) { $this->timezone = $timeZoneCode; } return $this; }
php
{ "resource": "" }
q6178
Query.excludes
train
protected function excludes($excludes) { $excludes = \is_array($excludes) ? $excludes : \func_get_args(); $this->excludes = $excludes; return $this; }
php
{ "resource": "" }
q6179
Query.build
train
public function build(callable $callback): array { $data = []; foreach (['includes', 'excludes'] as $key) { if (! empty($this->{$key})) { $data[$key] = \implode(',', $this->{$key}); } } if (! \is_null($this->timezone)) { $data['timezone'] = $this->timezone; } if (\is_int($this->page) && $this->page > 0) { $data['page'] = $this->page; if (\is_int($this->perPage) && $this->perPage > 5) { $data['per_page'] = $this->perPage; } } return \call_user_func($callback, $data, $this->customs); }
php
{ "resource": "" }
q6180
Request.getApiHeaders
train
protected function getApiHeaders(): array { $headers = [ 'Accept' => "application/vnd.KATSANA.{$this->getVersion()}+json", 'Time-Zone' => $this->requestHeaderTimezoneCode ?? 'UTC', ]; if (! \is_null($accessToken = $this->client->getAccessToken())) { $headers['Authorization'] = "Bearer {$accessToken}"; } return $headers; }
php
{ "resource": "" }
q6181
Request.onTimeZone
train
final public function onTimeZone(string $timeZoneCode): self { if (\in_array($timeZoneCode, \timezone_identifiers_list())) { $this->requestHeaderTimezoneCode = $timeZoneCode; } return $this; }
php
{ "resource": "" }
q6182
Logger.setDebug
train
public function setDebug($debug) { //====================================================================// // Change Parameter State $this->debug = $debug; //====================================================================// // Delete Existing Debug Messages if ((0 == $debug) && isset($this->debug)) { $this->deb = array(); } return true; }
php
{ "resource": "" }
q6183
Logger.err
train
public function err($text = null, $param1 = '', $param2 = '', $param3 = '', $param4 = '') { //====================================================================// // Safety Check if (is_null($text)) { return false; } //====================================================================// // Translate Message $message = Splash::trans($text, (string) $param1, (string) $param2, (string) $param3, (string) $param4); //====================================================================// // Add Message to Buffer $this->coreAddLog('err', $message); //====================================================================// // Add Message To Log File self::addLogToFile($message, 'ERROR'); return false; }
php
{ "resource": "" }
q6184
Logger.war
train
public function war($text = null, $param1 = '', $param2 = '', $param3 = '', $param4 = '') { //====================================================================// // Safety Check if (is_null($text)) { return true; } //====================================================================// // Translate Message $message = Splash::trans($text, (string) $param1, (string) $param2, (string) $param3, (string) $param4); //====================================================================// // Add Message to Buffer $this->coreAddLog('war', $message); //====================================================================// // Add Message To Log File self::addLogToFile($message, 'WARNING'); return true; }
php
{ "resource": "" }
q6185
Logger.trace
train
public function trace() { //====================================================================// // Safety Check if (!isset($this->debug) || !$this->debug) { return; } //====================================================================// // Build Error Trace $trace = (new Exception())->getTrace()[1]; //====================================================================// // Load Translation File Splash::translator()->load('main'); //====================================================================// // Push Trace to Log return self::deb("DebTraceMsg", $trace["class"], $trace["function"]); }
php
{ "resource": "" }
q6186
Logger.cleanLog
train
public function cleanLog() { if (isset($this->err)) { $this->err = array(); } if (isset($this->war)) { $this->war = array(); } if (isset($this->msg)) { $this->msg = array(); } if (isset($this->deb)) { $this->deb = array(); } $this->deb('Log Messages Buffer Cleaned'); return true; }
php
{ "resource": "" }
q6187
Logger.getRawLog
train
public function getRawLog($clean = false) { $raw = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS); if ($this->err) { $raw->err = $this->err; } if ($this->war) { $raw->war = $this->war; } if ($this->msg) { $raw->msg = $this->msg; } if ($this->deb) { $raw->deb = $this->deb; } if ($clean) { $this->cleanLog(); } return $raw; }
php
{ "resource": "" }
q6188
Logger.merge
train
public function merge($logs) { if (!empty($logs->msg)) { $this->mergeCore('msg', $logs->msg); $this->addLogBlockToFile($logs->msg, 'MESSAGE'); } if (!empty($logs->err)) { $this->mergeCore('err', $logs->err); $this->addLogBlockToFile($logs->err, 'ERROR'); } if (!empty($logs->war)) { $this->mergeCore('war', $logs->war); $this->addLogBlockToFile($logs->war, 'WARNING'); } if (!empty($logs->deb)) { $this->mergeCore('deb', $logs->deb); $this->addLogBlockToFile($logs->deb, 'DEBUG'); } return true; }
php
{ "resource": "" }
q6189
Logger.flushOuputBuffer
train
public function flushOuputBuffer() { //====================================================================// // Read the contents of the output buffer $contents = ob_get_contents(); //====================================================================// // Clean (erase) the output buffer and turn off output buffering ob_end_clean(); if ($contents) { //====================================================================// // Load Translation File Splash::translator()->load('main'); //====================================================================// // Push Warning to Log $this->war('UnexOutputs', $contents); $this->war('UnexOutputsMsg'); } }
php
{ "resource": "" }
q6190
Logger.coreAddLog
train
private function coreAddLog($type, $message) { //====================================================================// // Safety Check if (is_null($message)) { return; } //====================================================================// // Initialise buffer if unset if (!isset($this->{$type})) { $this->{$type} = array(); } //====================================================================// // Build Prefix $prefix = empty($this->prefix) ? '' : '['.$this->prefix.'] '; //====================================================================// // Add text message to buffer array_push($this->{$type}, $prefix.$message); }
php
{ "resource": "" }
q6191
Logger.mergeCore
train
private function mergeCore($logType, $logArray) { //====================================================================// // Fast Line if (empty($logArray)) { return; } //====================================================================// // Detect ArrayObjects if ($logArray instanceof ArrayObject) { $logArray = $logArray->getArrayCopy(); } //====================================================================// // If Current Log is Empty if (!isset($this->{$logType})) { $this->{$logType} = $logArray; //====================================================================// // Really merge Logs } else { foreach ($logArray as $message) { array_push($this->{$logType}, $message); } } }
php
{ "resource": "" }
q6192
NifValidator.isValid
train
public static function isValid(string $nif): bool { return self::isValidDni($nif) || self::isValidNie($nif) || self::isValidCif($nif) || self::isValidOtherPersonalNif($nif); }
php
{ "resource": "" }
q6193
NifValidator.isValidPersonal
train
public static function isValidPersonal(string $nif): bool { return self::isValidDni($nif) || self::isValidNie($nif) || self::isValidOtherPersonalNif($nif); }
php
{ "resource": "" }
q6194
NifValidator.isValidDni
train
public static function isValidDni(string $dni): bool { if (!preg_match(self::DNI_REGEX, $dni, $matches)) { return false; } if ('00000000' === $matches['number']) { return false; } return self::DNINIE_CHECK_TABLE[$matches['number'] % 23] === $matches['check']; }
php
{ "resource": "" }
q6195
NifValidator.isValidNie
train
public static function isValidNie(string $nie): bool { if (!preg_match(self::NIE_REGEX, $nie, $matches)) { return false; } $nieType = strpos(self::NIE_TYPES, $matches['type']); $nie = $nieType . $matches['number']; return self::DNINIE_CHECK_TABLE[$nie % 23] === $matches['check']; }
php
{ "resource": "" }
q6196
NifValidator.isValidOtherPersonalNif
train
public static function isValidOtherPersonalNif(string $nif): bool { if (!preg_match(self::OTHER_PERSONAL_NIF_REGEX, $nif, $matches)) { return false; } return self::isValidNifCheck($nif, $matches); }
php
{ "resource": "" }
q6197
NifValidator.isValidCif
train
public static function isValidCif(string $cif): bool { if (!preg_match(self::CIF_REGEX, $cif, $matches)) { return false; } return self::isValidNifCheck($cif, $matches); }
php
{ "resource": "" }
q6198
DB_mysqlco.prepareDB
train
private function prepareDB() { $dbpool = DBPool::init($this->db_config); // var_dump($dbpool->cap + $dbpool->activeCount, $dbpool->queue->isEmpty(), $dbpool->queue->count()); if ($dbpool->queue->isEmpty() && ($dbpool->cap + $dbpool->activeCount >= $this->config['max_pool_size'])) { \throw_error('MySQL pool is empty...', 12009); } if ($dbpool->cap < $this->config['idle_pool_size'] || ($dbpool->queue->isEmpty() && $dbpool->cap < $this->config['max_pool_size']) ) { // var_dump('........................reconnect........................'); $this->reconnect(); $dbpool->activeCount++; return false; } else { // var_dump('........................using pool........................'); $this->db = $dbpool->out($this->config['idle_pool_size']); return true; } }
php
{ "resource": "" }
q6199
Httpclient.get
train
public function get($url, $params = array(), $options = array()) { return $this->request($url, self::GET, $params, $options); }
php
{ "resource": "" }