_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q28500 | SecureRandom.getBytes | train | public function getBytes($count)
{
$count = (int) $count;
if ($count < 0) {
throw new \InvalidArgumentException('Number of bytes must be 0 or more');
}
return $this->generator->getBytes($count);
} | php | {
"resource": ""
} |
q28501 | SecureRandom.getArray | train | public function getArray(array $array, $count)
{
$count = (int) $count;
$size = count($array);
if ($this->isOutOfBounds($count, 0, $size)) {
throw new \InvalidArgumentException('Invalid number of elements');
}
$result = [];
$keys = array_keys($array);
... | php | {
"resource": ""
} |
q28502 | SecureRandom.choose | train | public function choose(array $array)
{
if (count($array) < 1) {
throw new \InvalidArgumentException('Array must have at least one value');
}
$result = array_slice($array, $this->generator->getNumber(0, count($array) - 1), 1);
return current($result);
} | php | {
"resource": ""
} |
q28503 | SecureRandom.getSequence | train | public function getSequence($choices, $length)
{
$length = (int) $length;
if ($length < 0) {
throw new \InvalidArgumentException('Invalid sequence length');
}
if (is_array($choices)) {
return $this->getSequenceValues(array_values($choices), $length);
... | php | {
"resource": ""
} |
q28504 | SecureRandom.getSequenceValues | train | private function getSequenceValues(array $values, $length)
{
if ($length < 1) {
return [];
}
if (count($values) < 1) {
throw new \InvalidArgumentException('Cannot generate sequence from empty value set');
}
$size = count($values);
$result = [... | php | {
"resource": ""
} |
q28505 | SecureRandom.getUuid | train | public function getUuid()
{
$integers = array_values(unpack('n8', $this->generator->getBytes(16)));
$integers[3] &= 0x0FFF;
$integers[4] = $integers[4] & 0x3FFF | 0x8000;
return vsprintf('%04x%04x-%04x-4%03x-%04x-%04x%04x%04x', $integers);
} | php | {
"resource": ""
} |
q28506 | Zip7zipAdapter.newInstance | train | public static function newInstance(
ExecutableFinder $finder,
ResourceManager $manager,
$inflatorBinaryName = null,
$deflatorBinaryName = null
) {
$inflator = $inflatorBinaryName instanceof ProcessBuilderFactoryInterface ? $inflatorBinaryName : self::findABinary($in... | php | {
"resource": ""
} |
q28507 | Hook.processHookFunction | train | public function processHookFunction($params, &$smarty)
{
$hookName = $this->getParam($params, 'name');
$module = intval($this->getParam($params, 'module', 0));
$moduleCode = $this->getParam($params, 'modulecode', "");
$type = $smarty->getTemplateDefinition()->getType();
... | php | {
"resource": ""
} |
q28508 | Hook.moduleIncludeCompat | train | protected function moduleIncludeCompat($params, &$smarty)
{
$plugin = $this->getSmartyPluginModule();
$params = array(
"location" => $this->getParam($params, 'location', null),
"module" => $this->getParam($params, 'modulecode', null),
"countvar" => $this->getPar... | php | {
"resource": ""
} |
q28509 | Hook.getSmartyPluginModule | train | protected function getSmartyPluginModule()
{
if (null === $this->smartyPluginModule) {
$this->smartyPluginModule = $this->dispatcher->getContainer()->get("smarty.plugin.module");
}
return $this->smartyPluginModule;
} | php | {
"resource": ""
} |
q28510 | Hook.processHookBlock | train | public function processHookBlock($params, $content, $smarty, &$repeat)
{
$hookName = $this->getParam($params, 'name');
$module = intval($this->getParam($params, 'module', 0));
// explicit definition of variable that can be returned
$fields = preg_replace(
'|[^a-zA-Z0-... | php | {
"resource": ""
} |
q28511 | Hook.checkEmptyHook | train | protected function checkEmptyHook($params)
{
$hookName = $this->getParam($params, 'rel');
if (null == $hookName) {
throw new \InvalidArgumentException(
$this->translator->trans("Missing 'rel' parameter in ifhook/elsehook arguments")
);
}
if (... | php | {
"resource": ""
} |
q28512 | Hook.getArgumentsFromParams | train | protected function getArgumentsFromParams($params)
{
$args = array();
$excludes = array("name", "before", "separator", "after", "fields");
if (is_array($params)) {
foreach ($params as $key => $value) {
if (!in_array($key, $excludes)) {
$ar... | php | {
"resource": ""
} |
q28513 | AbstractPagesController.searchPageByRequestKey | train | private function searchPageByRequestKey($key)
{
$pageId = $this->getRequestParameter($key);
if (empty($pageId)) {
return null;
}
return $this->getEntityManager()
->find(AbstractPage::CN(), $pageId);
} | php | {
"resource": ""
} |
q28514 | AbstractPagesController.searchLocalizationByRequestKey | train | private function searchLocalizationByRequestKey($key)
{
$localizationId = $this->getRequestInput()->get($key);
// Fix for news application filter folders
if (strpos($localizationId, '_') !== false) {
$localizationId = strstr($localizationId, '_', true);
}
if (empty($localizationId)) {
return null;
... | php | {
"resource": ""
} |
q28515 | AbstractPagesController.getInitialPageLocalization | train | protected function getInitialPageLocalization()
{
$localization = null;
$cookieBag = $this->container->getRequest()->cookies;
if ($cookieBag->has(self::INITIAL_PAGE_ID_COOKIE)) {
$localization = $this->getEntityManager()->find(
Localization::CN(),
$cookieBag->get(self::INITIAL_PAGE_ID_COOKIE)
)... | php | {
"resource": ""
} |
q28516 | AbstractPagesController.loadNodeMainData | train | protected function loadNodeMainData(Localization $localization)
{
$localeId = $this->getCurrentLocale()
->getId();
$isCurrentLocaleLocalization = ($localization->getLocaleId() === $localeId);
$page = $localization->getMaster();
$nodeData = array(
'id' => $isCurrentLocaleLocalization ? $localizati... | php | {
"resource": ""
} |
q28517 | AbstractPagesController.checkLock | train | protected function checkLock($createOnMiss = true)
{
$this->isPostRequest();
$user = $this->getCurrentUser();
if (! $user) {
return;
}
$localization = $this->getPageLocalization();
if ($localization->isLocked()) {
$lock = $localization->getLock();
if ($lock->getUserName() !== $user->getUs... | php | {
"resource": ""
} |
q28518 | AbstractPagesController.unlockPage | train | protected function unlockPage()
{
$this->isPostRequest();
$localization = $this->getPageLocalization();
if ($localization->isLocked()) {
$lock = $localization->getLock();
$entityManager = $this->getEntityManager();
$localization->setLock(null);
$entityManager->remove($lock);
$entityManager->... | php | {
"resource": ""
} |
q28519 | AbstractPagesController.lockPage | train | protected function lockPage()
{
$this->isPostRequest();
$currentUser = $this->getCurrentUser();
if (! $currentUser) {
return null;
}
$localization = $this->getPageLocalization();
$force = $this->getRequestInput()
->filter('force', false, false, FILTER_VALIDATE_BOOLEAN);
try {
if ($this->ch... | php | {
"resource": ""
} |
q28520 | AbstractPagesController.createLock | train | protected function createLock()
{
$user = $this->getCurrentUser();
if (! $user) {
throw new \LogicException('There is no user to attach the lock.');
}
$localization = $this->getPageLocalization();
$currentRevision = $this->getAuditReader()
->getCurrentRevision($localization::CN(), $localization->... | php | {
"resource": ""
} |
q28521 | AbstractPagesController.lockNestedSet | train | protected function lockNestedSet($entityNode)
{
$class = is_string($entityNode) ? $entityNode : $entityNode->getNestedSetRepositoryClassName();
$this->getEntityManager()
->getRepository($class)
->getNestedSetRepository()
->lock();
} | php | {
"resource": ""
} |
q28522 | AbstractPagesController.unlockNestedSet | train | protected function unlockNestedSet($entityNode)
{
$class = is_string($entityNode) ? $entityNode : $entityNode->getNestedSetRepositoryClassName();
$this->getEntityManager()
->getRepository($class)
->getNestedSetRepository()
->unlock();
} | php | {
"resource": ""
} |
q28523 | AbstractPagesController.getPageApplicationData | train | protected function getPageApplicationData(PageApplicationInterface $application)
{
return array(
'id' => $application->getId(),
'title' => $application->getTitle(),
'icon' => $application->getIcon(),
'isDropTarget' => $application->getAllowChildren(),
'childInsertPolicy' => $application->getNewChil... | php | {
"resource": ""
} |
q28524 | InetAddress.getByAddress | train | public static function getByAddress($address, $hostname = null)
{
$addrLen = strlen($address);
if ($addrLen === 4) {
return new Inet4Address($address, $hostname);
} elseif ($addrLen == 16) {
return new Inet6Address($address, $hostname);
}
throw new Un... | php | {
"resource": ""
} |
q28525 | InetAddress.getHostname | train | public function getHostname()
{
if ($this->hostname === null) {
$hostname = @gethostbyaddr($this->hostAddress);
if ($hostname === false) {
$hostname = $this->hostAddress;
}
$this->hostname = $hostname;
}
return $this->hostname;... | php | {
"resource": ""
} |
q28526 | CFileBasedContent.load | train | private function load($type)
{
$index = $this->$type;
if ($index) {
return;
}
$cache = $this->di->get("cache");
$key = $cache->createKey(__CLASS__, $type);
$index = $cache->get($key);
if (is_null($index) || $this->ignoreCache) {
$crea... | php | {
"resource": ""
} |
q28527 | CFileBasedContent.isInternalRoute | train | private function isInternalRoute($filepath)
{
foreach ($this->internalRouteDirPattern as $pattern) {
if (preg_match($pattern, $filepath)) {
return true;
}
}
$filename = basename($filepath);
foreach ($this->internalRouteFilePattern as $pattern)... | php | {
"resource": ""
} |
q28528 | CFileBasedContent.createMeta | train | private function createMeta()
{
$basepath = $this->config["basepath"];
$filter = $this->config["textfilter-frontmatter"];
$pattern = $this->config["meta"];
$path = "$basepath/$pattern";
$textfilter = $this->di->get("textFilter");
$index = [];
foreach (... | php | {
"resource": ""
} |
q28529 | CFileBasedContent.getMetaForRoute | train | private function getMetaForRoute($route)
{
$base = dirname($route);
return isset($this->meta[$base])
? $this->meta[$base]
: [];
} | php | {
"resource": ""
} |
q28530 | CFileBasedContent.createBaseRouteToc | train | private function createBaseRouteToc($route)
{
$toc = [];
$len = strlen($route);
foreach ($this->index as $key => $value) {
if (substr($key, 0, $len + 1) === "$route/") {
if ($value["internal"] === false
&& $value["tocable"] === true) {
... | php | {
"resource": ""
} |
q28531 | CFileBasedContent.createAuthor | train | private function createAuthor()
{
$pattern = $this->config["author"];
$index = [];
$matches = [];
foreach ($this->meta as $key => $entry) {
if (preg_match($pattern, $key, $matches)) {
$acronym = $matches[1];
$index[$acronym] = $key;
... | php | {
"resource": ""
} |
q28532 | CFileBasedContent.loadAuthorDetails | train | private function loadAuthorDetails($author)
{
if (is_array($author) && is_array(array_values($author)[0])) {
return $author;
}
if (!is_array($author)) {
$tmp = $author;
$author = [];
$author[] = $tmp;
}
$authors = [];
... | php | {
"resource": ""
} |
q28533 | CFileBasedContent.createCategory | train | private function createCategory()
{
$pattern = $this->config["category"];
$index = [];
$matches = [];
foreach ($this->meta as $key => $entry) {
if (preg_match($pattern, $key, $matches)) {
$catKey = $matches[1];
$index[$catKey] = $key;
... | php | {
"resource": ""
} |
q28534 | CFileBasedContent.checkForMetaRoute | train | private function checkForMetaRoute($route)
{
$this->baseRoute = $route;
$this->metaRoute = null;
// If route exits in index, use it
if ($this->mapRoute2IndexKey($route)) {
return $route;
}
// Check for pagination
$pagination = $this->config["pagi... | php | {
"resource": ""
} |
q28535 | CFileBasedContent.mapRoute2IndexKey | train | private function mapRoute2IndexKey($route)
{
$route = rtrim($route, "/");
if (key_exists($route, $this->index)) {
return $route;
} elseif (empty($route) && key_exists("index", $this->index)) {
return "index";
} elseif (key_exists($route . "/index", $this->ind... | php | {
"resource": ""
} |
q28536 | CFileBasedContent.mapRoute2Index | train | private function mapRoute2Index($route)
{
$routeIndex = $this->mapRoute2IndexKey($route);
if ($routeIndex) {
return [$routeIndex, $this->index[$routeIndex]];
}
$msg = t("The route '!ROUTE' does not exists in the index.", [
"!ROUTE" => $route
]);
... | php | {
"resource": ""
} |
q28537 | CFileBasedContent.getView | train | private function getView($route, $frontmatter, $key)
{
$view = [];
// From meta frontmatter
$meta = $this->getMetaForRoute($route);
if (isset($meta[$key])) {
$view = $meta[$key];
}
// From document frontmatter
if (isset($frontmatter[$key])) {
... | php | {
"resource": ""
} |
q28538 | CFileBasedContent.getViews | train | private function getViews($route, $frontmatter)
{
// Arrange data into views
$views = $this->getView($route, $frontmatter, "views", true);
// Set defaults
if (!isset($views["main"]["template"])) {
$views["main"]["template"] = $this->config["template"];
}
... | php | {
"resource": ""
} |
q28539 | CFileBasedContent.contentForRoute | train | public function contentForRoute($route = null)
{
$content = $this->contentForInternalRoute($route);
if ($content->internal === true) {
$msg = t("The content '!ROUTE' does not exists as a public route.", ["!ROUTE" => $route]);
throw new \Anax\Exception\NotFoundException($msg);... | php | {
"resource": ""
} |
q28540 | DataTrait.unsetData | train | public function unsetData($key = null)
{
if (is_string($key) && 0 < strlen($key)) {
unset($this->data[$key]);
} else {
$this->data = [];
}
return $this;
} | php | {
"resource": ""
} |
q28541 | SchemaBuilder.makeSchema | train | public function makeSchema(): array
{
return [
Filter::SH_MAP => $this->buildMap($this->entity),
Filter::SH_VALIDATES => $this->entity->getProperty('validates', true) ?? [],
Filter::SH_SECURED => $this->entity->getSecured(),
Filter::SH_FILLABLE => $th... | php | {
"resource": ""
} |
q28542 | File.setModificationTime | train | public function setModificationTime(\DateTime $time = null)
{
if (is_null($time)) {
$time = new \DateTime('now');
}
$this->modificationTime = $time;
} | php | {
"resource": ""
} |
q28543 | File.free | train | public function free()
{
if ( ! is_null($this->nestedSetNode)) {
$this->nestedSetNode->free($this);
$this->nestedSetNode = null;
}
} | php | {
"resource": ""
} |
q28544 | File.getRealFileName | train | public function getRealFileName()
{
$path = $this->path->getSystemPath();
$pathParts = explode('/', $path);
return array_pop($pathParts);
} | php | {
"resource": ""
} |
q28545 | PageRequestView.getLocalization | train | public function getLocalization()
{
$data = parent::getLocalization();
if (empty($data)) {
$data = $this->detectRequestPageLocalization();
$this->setLocalization($data);
}
return $data;
} | php | {
"resource": ""
} |
q28546 | ExtensionUploadFilter.validateFile | train | public function validateFile(File $file, $sourceFilePath = null)
{
$result = $this->checkList($file->getExtension());
if( ! $result) {
$message = 'File extension "'.$file->getExtension().'" is not allowed';
throw new Exception\UploadFilterException(self::EXCEPTION_MESSAGE_KEY, $message);
}
} | php | {
"resource": ""
} |
q28547 | Launcher.init | train | public function init() {
$state = Module::CopyMovieGrifus()->getOption( 'state' );
if ( 'active' === $state || 'outdated' === $state ) {
add_action( 'init', [ $this, 'set_language' ] );
if ( ! is_admin() ) {
$this->front();
}
}
} | php | {
"resource": ""
} |
q28548 | Launcher.front | train | public function front() {
add_action(
'wp', function() {
App::id( 'EFG' );
if ( App::main()->is_single() ) {
$this->set_language();
$this->add_scripts();
$this->add_styles();
}
}
);
} | php | {
"resource": ""
} |
q28549 | Launcher.add_scripts | train | protected function add_scripts() {
$js = Module::CopyMovieGrifus()->getOption( 'assets', 'js' );
$setting = $js['copyMovieGrifus'];
$params = Module::CopyMovieGrifus()->getControllerInstance( 'Copy' )
->getMovieInfo();
$setting['params'] = array_merge( $setting['params'], $params );
WP_Regis... | php | {
"resource": ""
} |
q28550 | DoctrineRepositoryArrayHelper.getCurrentMax | train | public function getCurrentMax()
{
$max = 0;
/* @var $node Node\NodeInterface */
foreach ($this->array as $node) {
$max = max($max, $node->getRightValue());
}
return $max;
} | php | {
"resource": ""
} |
q28551 | DoctrineRepositoryArrayHelper.register | train | public function register(Node\NodeInterface $node)
{
if ( ! in_array($node, $this->array, true)) {
$this->array[] = $node;
}
} | php | {
"resource": ""
} |
q28552 | Calendar.isDatesValid | train | public function isDatesValid()
{
if ($this->startDate >= $this->endDate) {
return false;
}
return ($this->endDate->diff($this->startDate)->days > 0);
} | php | {
"resource": ""
} |
q28553 | ColumnFilter.getTransformedComparisonValue | train | final protected function getTransformedComparisonValue($rawComparisonValue, Model $model)
{
$columnSchema = $model->getRepositoryColumnSchemaForColumnReference($this->columnName);
if ($columnSchema != null) {
$closure = $columnSchema->getTransformIntoModelData();
if ($closu... | php | {
"resource": ""
} |
q28554 | Chain.run | train | public function run(array $args) {
foreach($this->calls as $call) {
if($call instanceof \SuperClosure\SerializableClosure)
$call = $call->getClosure();
$res = call_user_func_array($call, array_merge([$this], $args));
$this->executed++;
if($res !== null)
return $res;
if(!$this->continue)
ret... | php | {
"resource": ""
} |
q28555 | TFBCUtilities.getActiveRoute | train | private function getActiveRoute($route, $routeIndex)
{
if (substr_compare($route, "./", 0, 2) === 0) {
$route = dirname($routeIndex) . "/" . substr($route, 2);
}
return $route;
} | php | {
"resource": ""
} |
q28556 | TFBCUtilities.loadAndParseRoute | train | private function loadAndParseRoute($route)
{
// Get meta into view structure
$meta = $this->getMetaForRoute($route);
unset($meta["__toc__"]);
unset($meta["views"]);
// Get filtered content from route
list($routeIndex, , $filtered) =
$this->mapRoute2Co... | php | {
"resource": ""
} |
q28557 | SolrAdapter.getResponse | train | protected function getResponse($offset = 0, $itemCountPerPage = 0)
{
$id = md5($offset . $itemCountPerPage);
if (!isset($this->responses[$id])) {
$query = new \SolrDisMaxQuery();
$this->filter->filter($this->params, $query, $this->facets);
$query->setStart($offset... | php | {
"resource": ""
} |
q28558 | Lookup.connectToNSQLookupd | train | public function connectToNSQLookupd($addr)
{
if ($this->isStopped) {
throw new NsqException("consumer stopped");
}
$addr = $this->formatAddress($addr);
if (isset($this->lookupdHTTPAddrs[$addr])) {
return;
}
$this->lookupdHTTPAddrs[$addr] = []... | php | {
"resource": ""
} |
q28559 | Lookup.lookupdPollingTick | train | private function lookupdPollingTick()
{
// add some jitter
$jitter = (float)rand() / (float)getrandmax()
* NsqConfig::getLookupdPollJitter()
* NsqConfig::getLookupdPollInterval();
Timer::after(intval($jitter) + 1, function() {
if ($this->isStopped) {
... | php | {
"resource": ""
} |
q28560 | Lookup.disconnectFromNSQLookupd | train | public function disconnectFromNSQLookupd($addr)
{
$addr = $this->formatAddress($addr);
if (!isset($this->lookupdHTTPAddrs[$addr])) {
throw new NsqException("not connected");
}
if (count($this->lookupdHTTPAddrs) === 1) {
throw new NsqException("cannot disconne... | php | {
"resource": ""
} |
q28561 | Lookup.connectToNSQD | train | public function connectToNSQD($host, $port)
{
if ($this->isStopped) {
throw new NsqException("consumer stopped");
}
$addr = "$host:$port";
if (!isset($this->nsqdTCPAddrsConnNum[$addr])) {
$this->nsqdTCPAddrsConnNum[$addr] = 0;
}
$perNsqdMaxNu... | php | {
"resource": ""
} |
q28562 | Lookup.disconnectFromNSQD | train | public function disconnectFromNSQD($host, $port)
{
$key = "$host:$port";
if (!isset($this->nsqdTCPAddrsConnNum[$key])) {
throw new NsqException("not connected");
}
foreach ($this->getConnections() as $conn) {
if ($conn->getHost() === $host && $conn->getPort()... | php | {
"resource": ""
} |
q28563 | Layout.checkPageSize | train | private function checkPageSize($pageSize)
{
if (!in_array($pageSize, $this->availablePageSizes)) {
throw new \InvalidArgumentException(
sprintf(
'Invalid pageSize, "%s" given. Available pageSize are %s.',
$pageSize,
impl... | php | {
"resource": ""
} |
q28564 | Module.showOptionsForm | train | public function showOptionsForm(): void
{
$form = new Options\Form($this->options, $this->ADMIN_FORM_ID);
$form->handleRequest();
$form->write();
} | php | {
"resource": ""
} |
q28565 | HttpBuildQueryBehavior.httpBuildQuery | train | private function httpBuildQuery(array $data): string
{
$queryString = http_build_query($data, '', '&');
return $this->postProcessHttpQueryString($queryString, $data);
} | php | {
"resource": ""
} |
q28566 | CookieStorage.store | train | public function store(Request $request, Response $response, $localeId)
{
$response->headers->setCookie(new Cookie($this->cookieName, $localeId));
} | php | {
"resource": ""
} |
q28567 | ControllerException.getResponse | train | public function getResponse() {
if($this->response)
return $this->response;
else
return new \Asgard\Http\Response($this->code);
} | php | {
"resource": ""
} |
q28568 | TaskModel.create | train | public static function create($belongsTo, $type, $data, $attributes = [])
{
$obj = new Task();
$obj->belongsTo = $belongsTo;
$obj->type = $type;
$obj->data = $data;
$obj->additional = $attributes;
$obj->save();
} | php | {
"resource": ""
} |
q28569 | AbstractCmsController.getConfirmation | train | protected function getConfirmation($question, $id = '0', $answer = true)
{
$request = $this->container->getRequest();
$confirmationPool = $request->get(self::CONFIRMATION_ANSWER_CONTEXT, array());
if (isset($confirmationPool[$id])) {
$userAnswer = filter_var($confirmationPool[$id], FILTER_VALIDATE_BOOLEAN);... | php | {
"resource": ""
} |
q28570 | GnApiModuleBase.HandleCallQuota | train | private function HandleCallQuota()
{
if ($this->_quota_LastCall == NULL) {
$this->_quota_LastCall = new \DateTime();
$this->_quota_LastCall->setTimestamp(0);
}
$now = new \DateTime();
$secsFromLastCall = $now->getTimestamp() - $this->_quota_LastCall->getTimes... | php | {
"resource": ""
} |
q28571 | GnApiModuleBase.SimpleResultCall | train | protected function SimpleResultCall(string $actionName, $request, string $resultPropName, int $cacheTtl = 0)
{
$response = $this->ExecuteCall($actionName, $request, GnResponseType::Json, FALSE, $cacheTtl);
$result = $response->{$resultPropName};
return $result;
} | php | {
"resource": ""
} |
q28572 | Str.isPrefixed | train | public static function isPrefixed(string $data, string $prefix, string $separator = ''): bool
{
if ($separator !== '') {
$data = trim($data, $separator);
}
return static::substr($data, 0, static::length($prefix)) === $prefix;
} | php | {
"resource": ""
} |
q28573 | Str.stripPrefix | train | public static function stripPrefix(string $data, string $prefix, string $separator = ''): string
{
if ($data === '') {
return $data;
}
if ($separator !== '') {
$data = ltrim($data, $separator);
}
if (static::substr($data, 0, static::length($prefix)) ==... | php | {
"resource": ""
} |
q28574 | Str.forcePrefix | train | public static function forcePrefix(string $data, string $prefix, string $separator = ''): string
{
if ($data === '') {
return $data;
}
if ($separator !== '') {
$data = trim($data, $separator);
}
if (static::substr($data, 0, static::length($prefix)) !==... | php | {
"resource": ""
} |
q28575 | Str.isSuffixed | train | public static function isSuffixed(string $data, string $suffix, string $separator = ''): bool
{
if ($separator !== '') {
$data = trim($data, $separator);
}
return static::substr($data, -static::length($suffix)) === $suffix;
} | php | {
"resource": ""
} |
q28576 | Str.stripSuffix | train | public static function stripSuffix(string $data, string $prefix, string $separator = ''): string
{
if ($data === '') {
return $data;
}
if ($separator !== '') {
$data = rtrim($data, $separator);
}
if (static::substr($data, -static::length($prefix)) === ... | php | {
"resource": ""
} |
q28577 | Str.forceSuffix | train | public static function forceSuffix(string $data, string $prefix, string $separator = ''): string
{
if ($data === '') {
return $data;
}
if ($separator !== '') {
$data = trim($data, $separator);
}
if (static::substr($data, -static::length($prefix)) !== $... | php | {
"resource": ""
} |
q28578 | Str.part | train | public static function part(string $string, string $separator, int $index, string $defaultValue = ''): string
{
if ($string !== '') {
$string = explode($separator, $string);
if (isset($string[$index])) {
return $string[$index];
}
}
return $... | php | {
"resource": ""
} |
q28579 | Str.csvFields | train | public static function csvFields(string $line, string $delimiter = ','): array
{
if (trim($line) === '') {
return [];
}
$fields = [];
$parts = str_getcsv($line, $delimiter);
if ($parts !== null && count($parts) > 0) {
foreach ($parts as $part) {
... | php | {
"resource": ""
} |
q28580 | Str.slug | train | public static function slug(string $string, string $separator = '.'): string
{
// Make sure standard characters has been replaced to separator.
$slug = str_replace(['-', '_', ' ', '.'], $separator, mb_strtolower($string));
// Remove all "funny" characters.
$slug = preg_replace('/[^a... | php | {
"resource": ""
} |
q28581 | Str.explode | train | public static function explode(string $separator, string $content, ?callable $itemFunction = null): array
{
if ($separator === "\n") {
$content = str_replace("\r", '', $content);
}
$items = explode($separator, $content);
if (is_callable($itemFunction)) {
forea... | php | {
"resource": ""
} |
q28582 | Str.implode | train | public static function implode(string $separator, array $items, ?callable $itemFunction = null): string
{
if (is_callable($itemFunction)) {
foreach ($items as $index => $item) {
$items[$index] = $itemFunction($item);
}
}
return implode($separator, $ite... | php | {
"resource": ""
} |
q28583 | Str.padLeft | train | public static function padLeft(string $string, int $length, string $filler = ' '): string
{
while (self::length($string) <= ($length - self::length($filler))) {
$string = $filler . $string;
}
return $string;
} | php | {
"resource": ""
} |
q28584 | Str.padRight | train | public static function padRight(string $string, int $length, string $filler = ' '): string
{
while (self::length($string) <= ($length - self::length($filler))) {
$string = $string . $filler;
}
return $string;
} | php | {
"resource": ""
} |
q28585 | Str.pascalCase | train | public static function pascalCase(string $value): string
{
$value = ucwords(str_replace(['-', '_'], ' ', $value));
return str_replace(' ', '', $value);
} | php | {
"resource": ""
} |
q28586 | Str.snakeCase | train | public static function snakeCase(string $value, bool $toLowerCase = false, string $separator = '_'): string
{
$replace = strtolower(preg_replace(
['/\s+/', '/\s/', '/(?|([a-z\d])([A-Z])|([^\^])([A-Z][a-z]))/', '/[-_]+/'],
[' ', $separator, '$1' . $separator . '$2', $separator],
... | php | {
"resource": ""
} |
q28587 | Str.kebabCase | train | public static function kebabCase(string $value, bool $toLowerCase = true): string
{
return static::snakeCase($value, $toLowerCase, '-');
} | php | {
"resource": ""
} |
q28588 | Str.caseConvertArrayKeysRecursively | train | public static function caseConvertArrayKeysRecursively(
array $array,
string $method = self::PASCALCASE,
string $separator = '_'
): array {
$return = [];
foreach ($array as $key => $value) {
if (!preg_match('/^\d+$/', $key)) {
$key = self::$method(... | php | {
"resource": ""
} |
q28589 | Str.indexOf | train | public static function indexOf(string $haystack, string $needle, int $offset = 0): int
{
$pos = self::strpos($haystack, $needle, $offset);
return is_int($pos) ? $pos : -1;
} | php | {
"resource": ""
} |
q28590 | FileUploadException.fire | train | public static function fire($code)
{
if ($code == 0) {
return new LogicException('Error code 0 means upload was successful');
}
if ( ! in_array($code, array_keys(self::$messages))) {
return new self(self::$default, self::UPPLOAD_ERR_DEFAULT);
}
return new self(self::$messages[$code], $code);
} | php | {
"resource": ""
} |
q28591 | SettingsModel.getAllSettings | train | public static function getAllSettings()
{
$settings = Settings::all();
$settingsList = [];
foreach($settings as $setting){
$settingsList[$setting->settingsKey] = $setting->value;
}
return $settingsList;
} | php | {
"resource": ""
} |
q28592 | SettingsModel.getSetting | train | public static function getSetting($key)
{
$setting = Settings::all()->where('settingsKey', $key)->first();
if($setting) {
return $setting->value;
}
return;
} | php | {
"resource": ""
} |
q28593 | Lead.getLeads | train | public function getLeads($startDate, $endDate, array $params = array())
{
$isValidStartDate = $this->utils->isSystemDatetime($startDate);
$isValidEndDate = $this->utils->isSystemDatetime($endDate);
if (!$isValidEndDate || !$isValidStartDate) {
throw new InvalidArgumentExcept... | php | {
"resource": ""
} |
q28594 | DataTrait.setArray | train | public function setArray(array $data, bool $doMerge = false): self
{
if ($doMerge) {
foreach ($data as $key => $value) {
$this->data[$key] = $value;
}
} else {
$this->data = $data;
}
return $this;
} | php | {
"resource": ""
} |
q28595 | DataTrait.setInt | train | public function setInt(string $key, int $value): self
{
$this->set($key, intval($value));
return $this;
} | php | {
"resource": ""
} |
q28596 | DataTrait.setBool | train | public function setBool(string $key, $value)
{
if (is_string($value)) {
$value = strtolower($value);
}
$this->set($key, in_array($value, [1, true, '1', 'true', 'yes', 'on'], true));
return $this;
} | php | {
"resource": ""
} |
q28597 | BaseController.handleException | train | protected function handleException(EditorExceptionInterface $exception)
{
if ($this->getParameter('kernel.debug')) {
throw $exception;
}
return $this->buildResponse([
'error' => $exception->getMessage(),
]);
} | php | {
"resource": ""
} |
q28598 | BaseController.persist | train | protected function persist($entity)
{
$manager = $this->getDoctrine()->getManager();
$manager->persist($entity);
$manager->flush();
} | php | {
"resource": ""
} |
q28599 | BaseController.validate | train | protected function validate($object)
{
$errorList = $this->get('validator')->validate($object);
if (0 < $errorList->count()) {
$message = 'Row validation failed.';
if ($this->getParameter('kernel.debug')) {
$messages = [];
/** @var \Symfony\Com... | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.