_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
33
8k
language
stringclasses
1 value
meta_information
dict
q19700
InteractsWithElements.value
train
public function value($selector, $value = null) { if (is_null($value)) { return $this->resolver->findOrFail($selector)->getAttribute('value'); }
php
{ "resource": "" }
q19701
InteractsWithElements.keys
train
public function keys($selector, ...$keys) { $this->resolver->findOrFail($selector)->sen
php
{ "resource": "" }
q19702
InteractsWithElements.parseKeys
train
protected function parseKeys($keys) { return collect($keys)->map(function ($key) { if (is_string($key) && Str::startsWith($key, '{') && Str::endsWith($key, '}')) { $key = constant(WebDriverKeys::class.'::'.strtoupper(trim($key, '{}'))); } if (is_array($ke...
php
{ "resource": "" }
q19703
InteractsWithElements.type
train
public function type($field, $value) { $this->resolver->resolveForTyping($field)->c
php
{ "resource": "" }
q19704
InteractsWithElements.append
train
public function append($field, $value) { $this->resolver->resolveForTyping($fiel
php
{ "resource": "" }
q19705
InteractsWithElements.select
train
public function select($field, $value = null) { $element = $this->resolver->resolveForSelection($field); $options = $element->findElements(WebDriverBy::cssSelector('option:not([disabled])')); if (is_null($value)) { $options[array_rand($options)]->click(); } else { ...
php
{ "resource": "" }
q19706
InteractsWithElements.radio
train
public function radio($field, $value) { $this->resolver->resolveForRadioSelection($field,
php
{ "resource": "" }
q19707
InteractsWithElements.check
train
public function check($field, $value = null) { $element = $this->resolver->resolveForChecking($field, $value);
php
{ "resource": "" }
q19708
InteractsWithElements.attach
train
public function attach($field, $path) { $element = $this->resolver->resolveForAttachment($field);
php
{ "resource": "" }
q19709
InteractsWithElements.pressAndWaitFor
train
public function pressAndWaitFor($button, $seconds = 5) { $element = $this->resolver->resolveForButtonPress($button); $element->click();
php
{ "resource": "" }
q19710
InteractsWithElements.drag
train
public function drag($from, $to) { (new WebDriverActions($this->driver))->dragAndDrop(
php
{ "resource": "" }
q19711
InteractsWithElements.dragOffset
train
public function dragOffset($selector, $x = 0, $y = 0) { (new WebDriverActions($this->driver))->dragAndDropBy(
php
{ "resource": "" }
q19712
Browser.onWithoutAssert
train
public function onWithoutAssert($page) { $this->page = $page; // Here we will set the page elements on the resolver instance, which will allow // the developer to access short-cuts
php
{ "resource": "" }
q19713
Browser.resize
train
public function resize($width, $height) { $this->driver->manage()->window()->setSize(
php
{ "resource": "" }
q19714
Browser.move
train
public function move($x, $y) { $this->driver->manage()->window()->setPosition(
php
{ "resource": "" }
q19715
Browser.screenshot
train
public function screenshot($name) { $this->driver->takeScreenshot(
php
{ "resource": "" }
q19716
Browser.storeConsoleLog
train
public function storeConsoleLog($name) { if (in_array($this->driver->getCapabilities()->getBrowserName(), static::$supportsRemoteLogs)) { $console = $this->driver->manage()->getLog('browser'); if (! empty($console)) { file_put_contents(
php
{ "resource": "" }
q19717
Browser.withinFrame
train
public function withinFrame($selector, Closure $callback) { $this->driver->switchTo()->frame($this->resolver->findOrFail($selector));
php
{ "resource": "" }
q19718
Browser.with
train
public function with($selector, Closure $callback) { $browser = new static( $this->driver, new ElementResolver($this->driver, $this->resolver->format($selector)) ); if ($this->page) { $browser->onWithoutAssert($this->page); }
php
{ "resource": "" }
q19719
Browser.onComponent
train
public function onComponent($component, $parentResolver) { $this->component = $component; // Here we will set the component elements on the resolver instance, which will allow // the developer to access short-cuts for CSS selectors on the component which can // allow for more expres...
php
{ "resource": "" }
q19720
ElementResolver.resolveForTyping
train
public function resolveForTyping($field) { if (! is_null($element = $this->findById($field))) { return $element; } return $this->firstOrFail([
php
{ "resource": "" }
q19721
ElementResolver.resolveForSelection
train
public function resolveForSelection($field) { if (! is_null($element = $this->findById($field))) {
php
{ "resource": "" }
q19722
ElementResolver.resolveSelectOptions
train
public function resolveSelectOptions($field, array $values) { $options = $this->resolveForSelection($field) ->findElements(WebDriverBy::tagName('option')); if (empty($options)) { return []; }
php
{ "resource": "" }
q19723
ElementResolver.resolveForChecking
train
public function resolveForChecking($field, $value = null) { if (! is_null($element = $this->findById($field))) { return $element; } $selector = 'input[type=checkbox]'; if (! is_null($field)) { $selector .= "[name='{$field}']";
php
{ "resource": "" }
q19724
ElementResolver.resolveForAttachment
train
public function resolveForAttachment($field) { if (! is_null($element = $this->findById($field))) {
php
{ "resource": "" }
q19725
ElementResolver.resolveForField
train
public function resolveForField($field) { if (! is_null($element = $this->findById($field))) { return $element;
php
{ "resource": "" }
q19726
ElementResolver.resolveForButtonPress
train
public function resolveForButtonPress($button) { foreach ($this->buttonFinders as $method) { if (! is_null($element = $this->{$method}($button))) { return $element; }
php
{ "resource": "" }
q19727
ElementResolver.findButtonByName
train
protected function findButtonByName($button) { if (! is_null($element = $this->find("input[type=submit][name='{$button}']")) || ! is_null($element = $this->find("input[type=button][value='{$button}']")) ||
php
{ "resource": "" }
q19728
ElementResolver.findButtonByValue
train
protected function findButtonByValue($button) { foreach ($this->all('input[type=submit]') as $element) { if ($element->getAttribute('value') ===
php
{ "resource": "" }
q19729
ElementResolver.findButtonByText
train
protected function findButtonByText($button) { foreach ($this->all('button') as $element)
php
{ "resource": "" }
q19730
ElementResolver.findById
train
protected function findById($selector) { if (preg_match('/^#[\w\-:]+$/', $selector))
php
{ "resource": "" }
q19731
ElementResolver.firstOrFail
train
public function firstOrFail($selectors) { foreach ((array) $selectors as $selector) { try {
php
{ "resource": "" }
q19732
ElementResolver.findOrFail
train
public function findOrFail($selector) { if (! is_null($element = $this->findById($selector))) {
php
{ "resource": "" }
q19733
ElementResolver.all
train
public function all($selector) { try { return $this->driver->findElements( WebDriverBy::cssSelector($this->format($selector))
php
{ "resource": "" }
q19734
ElementResolver.format
train
public function format($selector) { $sortedElements = collect($this->elements)->sortByDesc(function ($element, $key) { return strlen($key); })->toArray(); $selector = str_replace( array_keys($sortedElements), array_values($sortedElements), $originalSelector = $select...
php
{ "resource": "" }
q19735
InteractsWithJavascript.script
train
public function script($scripts) { return collect((array) $scripts)->map(function ($script)
php
{ "resource": "" }
q19736
InteractsWithCookies.cookie
train
public function cookie($name, $value = null, $expiry = null, array $options = []) { if (! is_null($value)) { return $this->addCookie($name, $value, $expiry, $options); }
php
{ "resource": "" }
q19737
InteractsWithCookies.addCookie
train
public function addCookie($name, $value, $expiry = null, array $options = [], $encrypt = true) { if ($encrypt) { $value = encrypt($value, $serialize = false); } if ($expiry instanceof DateTimeInterface) { $expiry
php
{ "resource": "" }
q19738
MakesUrlAssertions.assertUrlIs
train
public function assertUrlIs($url) { $pattern = str_replace('\*', '.*', preg_quote($url, '/')); $segments = parse_url($this->driver->getCurrentURL()); $currentUrl = sprintf( '%s://%s%s%s', $segments['scheme'],
php
{ "resource": "" }
q19739
MakesUrlAssertions.assertSchemeIs
train
public function assertSchemeIs($scheme) { $pattern = str_replace('\*', '.*', preg_quote($scheme, '/')); $actual = parse_url($this->driver->getCurrentURL(), PHP_URL_SCHEME) ??
php
{ "resource": "" }
q19740
MakesUrlAssertions.assertSchemeIsNot
train
public function assertSchemeIsNot($scheme) { $actual = parse_url($this->driver->getCurrentURL(), PHP_URL_SCHEME) ?? ''; PHPUnit::assertNotEquals( $scheme, $actual,
php
{ "resource": "" }
q19741
MakesUrlAssertions.assertHostIs
train
public function assertHostIs($host) { $pattern = str_replace('\*', '.*', preg_quote($host, '/')); $actual = parse_url($this->driver->getCurrentURL(), PHP_URL_HOST) ??
php
{ "resource": "" }
q19742
MakesUrlAssertions.assertPortIs
train
public function assertPortIs($port) { $pattern = str_replace('\*', '.*', preg_quote($port, '/')); $actual = parse_url($this->driver->getCurrentURL(), PHP_URL_PORT) ??
php
{ "resource": "" }
q19743
MakesUrlAssertions.assertPathIs
train
public function assertPathIs($path) { $pattern = str_replace('\*', '.*', preg_quote($path, '/')); $actualPath = parse_url($this->driver->getCurrentURL(), PHP_URL_PATH) ?? ''; PHPUnit::assertRegExp(
php
{ "resource": "" }
q19744
MakesUrlAssertions.assertPathBeginsWith
train
public function assertPathBeginsWith($path) { $actualPath = parse_url($this->driver->getCurrentURL(), PHP_URL_PATH) ?? ''; PHPUnit::assertStringStartsWith( $path, $actualPath,
php
{ "resource": "" }
q19745
MakesUrlAssertions.assertPathIsNot
train
public function assertPathIsNot($path) { $actualPath = parse_url($this->driver->getCurrentURL(), PHP_URL_PATH) ?? ''; PHPUnit::assertNotEquals( $path, $actualPath,
php
{ "resource": "" }
q19746
MakesUrlAssertions.assertFragmentIs
train
public function assertFragmentIs($fragment) { $pattern = preg_quote($fragment, '/'); $actualFragment = (string) parse_url($this->driver->executeScript('return window.location.href;'), PHP_URL_FRAGMENT); PHPUnit::assertRegExp(
php
{ "resource": "" }
q19747
MakesUrlAssertions.assertFragmentBeginsWith
train
public function assertFragmentBeginsWith($fragment) { $actualFragment = (string) parse_url($this->driver->executeScript('return window.location.href;'), PHP_URL_FRAGMENT); PHPUnit::assertStringStartsWith( $fragment, $actualFragment,
php
{ "resource": "" }
q19748
MakesUrlAssertions.assertFragmentIsNot
train
public function assertFragmentIsNot($fragment) { $actualFragment = (string) parse_url($this->driver->executeScript('return window.location.href;'), PHP_URL_FRAGMENT); PHPUnit::assertNotEquals(
php
{ "resource": "" }
q19749
MakesUrlAssertions.assertQueryStringHas
train
public function assertQueryStringHas($name, $value = null) { $output = $this->assertHasQueryStringParameter($name); if (is_null($value)) { return $this; } $parsedOutputName = is_array($output[$name]) ? implode(',', $output[$name]) : $output[$name]; $parsedValue...
php
{ "resource": "" }
q19750
MakesUrlAssertions.assertQueryStringMissing
train
public function assertQueryStringMissing($name) { $parsedUrl = parse_url($this->driver->getCurrentURL()); if (! array_key_exists('query', $parsedUrl)) { PHPUnit::assertTrue(true); return $this; } parse_str($parsedUrl['query'], $output);
php
{ "resource": "" }
q19751
MakesUrlAssertions.assertHasQueryStringParameter
train
protected function assertHasQueryStringParameter($name) { $parsedUrl = parse_url($this->driver->getCurrentURL()); PHPUnit::assertArrayHasKey( 'query', $parsedUrl, 'Did not see expected query string in ['.$this->driver->getCurrentURL().'].' ); parse_str($pars...
php
{ "resource": "" }
q19752
CrawlerDetect.setUserAgent
train
public function setUserAgent($userAgent) { if (is_null($userAgent)) { foreach ($this->getUaHttpHeaders() as $altHeader) { if (isset($this->httpHeaders[$altHeader])) {
php
{ "resource": "" }
q19753
CrawlerDetect.isCrawler
train
public function isCrawler($userAgent = null) { $agent = trim(preg_replace( "/{$this->compiledExclusions}/i", '', $userAgent ?: $this->userAgent )); if ($agent == '') { return
php
{ "resource": "" }
q19754
Command.triggerCommand
train
protected function triggerCommand($command, $arguments = null) {
php
{ "resource": "" }
q19755
Keyboard.row
train
public function row() { $property = 'keyboard'; if ($this->isInlineKeyboard()) {
php
{ "resource": "" }
q19756
AnswerBus.buildDependencyInjectedAnswer
train
protected function buildDependencyInjectedAnswer($answerClass) { // check if the command has a constructor if (!method_exists($answerClass, '__construct')) { return new $answerClass(); } // get constructor params $constructorReflector = new \ReflectionMethod($ans...
php
{ "resource": "" }
q19757
GuzzleHttpClient.getOptions
train
private function getOptions(array $headers, $body, $options, $timeOut, $isAsyncRequest = false, $connectTimeOut = 10) { $default_options = [ RequestOptions::HEADERS => $headers, RequestOptions::BODY => $body,
php
{ "resource": "" }
q19758
BotsManager.getBotConfig
train
public function getBotConfig($name = null) { $name = $name ?: $this->getDefaultBot(); $bots = $this->getConfig('bots'); if (!is_array($config = array_get($bots, $name)) && !$config) {
php
{ "resource": "" }
q19759
BotsManager.bot
train
public function bot($name = null) { $name = $name ?: $this->getDefaultBot(); if (!isset($this->bots[$name])) { $this->bots[$name]
php
{ "resource": "" }
q19760
BotsManager.reconnect
train
public function reconnect($name = null) { $name = $name ?: $this->getDefaultBot();
php
{ "resource": "" }
q19761
BotsManager.disconnect
train
public function disconnect($name = null) { $name = $name ?:
php
{ "resource": "" }
q19762
BotsManager.parseBotCommands
train
protected function parseBotCommands(array $commands) { $globalCommands = $this->getConfig('commands', []); $parsedCommands = $this->parseCommands($commands);
php
{ "resource": "" }
q19763
BotsManager.parseCommands
train
protected function parseCommands(array $commands) { if (!is_array($commands)) { return $commands; } $commandGroups = $this->getConfig('command_groups'); $sharedCommands = $this->getConfig('shared_commands'); $results = []; foreach ($commands as $command)...
php
{ "resource": "" }
q19764
Api.sendSticker
train
public function sendSticker(array $params) { if (is_file($params['sticker']) && (pathinfo($params['sticker'], PATHINFO_EXTENSION) !== 'webp')) { throw new TelegramSDKException('Invalid Sticker Provided. Supported Format: Webp'); }
php
{ "resource": "" }
q19765
Api.sendChatAction
train
public function sendChatAction(array $params) { $validActions = [ 'typing', 'upload_photo', 'record_video', 'upload_video', 'record_audio', 'upload_audio', 'upload_document', 'find_location', ];
php
{ "resource": "" }
q19766
Api.getChatAdministrators
train
public function getChatAdministrators(array $params) { $response = $this->post('getChatAdministrators', $params); return collect($response->getResult())
php
{ "resource": "" }
q19767
Api.answerInlineQuery
train
public function answerInlineQuery(array $params = []) { if (is_array($params['results'])) { $params['results'] = json_encode($params['results']);
php
{ "resource": "" }
q19768
Api.setWebhook
train
public function setWebhook(array $params) { if (filter_var($params['url'], FILTER_VALIDATE_URL) === false) { throw new TelegramSDKException('Invalid URL Provided'); } if (parse_url($params['url'], PHP_URL_SCHEME) !== 'https') {
php
{ "resource": "" }
q19769
Api.getWebhookUpdate
train
public function getWebhookUpdate($shouldEmitEvent = true) { $body = json_decode(file_get_contents('php://input'), true); $update = new Update($body); if ($shouldEmitEvent) {
php
{ "resource": "" }
q19770
Api.commandsHandler
train
public function commandsHandler($webhook = false, array $params = []) { if ($webhook) { $update = $this->getWebhookUpdate(); $this->processCommand($update); return $update; } $updates = $this->getUpdates($params); $highestId = -1; foreac...
php
{ "resource": "" }
q19771
Api.triggerCommand
train
public function triggerCommand($name, Update $update) { return $this->getCommandBus()->execute($name,
php
{ "resource": "" }
q19772
Api.get
train
protected function get($endpoint, $params = []) { if (array_key_exists('reply_markup', $params)) { $params['reply_markup'] = (string)$params['reply_markup']; }
php
{ "resource": "" }
q19773
Api.post
train
protected function post($endpoint, array $params = [], $fileUpload = false) { if ($fileUpload) { $params = ['multipart' => $params]; } else { if (array_key_exists('reply_markup', $params)) { $params['reply_markup'] = (string)$params['reply_markup']; ...
php
{ "resource": "" }
q19774
Api.sendRequest
train
protected function sendRequest( $method, $endpoint, array $params = [] ) { $request = $this->request($method, $endpoint, $params);
php
{ "resource": "" }
q19775
Api.request
train
protected function request( $method, $endpoint, array $params = [] ) { return new TelegramRequest( $this->getAccessToken(), $method, $endpoint,
php
{ "resource": "" }
q19776
Api.isValidFileOrUrl
train
protected function isValidFileOrUrl($name, $contents) { //Don't try to open a url as an actual file when using this method to setWebhook. if ($name == 'url') { return false; } //If a certificate name is passed, we must check for the file existing on the local server, ...
php
{ "resource": "" }
q19777
Emojify.wordToEmojiReplace
train
protected function wordToEmojiReplace($line, $replace, $delimiter) { foreach ($replace as $key => $value) { $line
php
{ "resource": "" }
q19778
Emojify.emojiToWordReplace
train
protected function emojiToWordReplace($line, $replace, $delimiter) { foreach ($replace as $key => $value) { $line
php
{ "resource": "" }
q19779
Emojify.getEmojiMap
train
protected function getEmojiMap() { if (!isset($this->emojiMapFile)) { $this->emojiMapFile = realpath(__DIR__.self::DEFAULT_EMOJI_MAP_FILE);
php
{ "resource": "" }
q19780
Emojify.setupEmojiMaps
train
protected function setupEmojiMaps() { $this->emojiMap = $this->getEmojiMap();
php
{ "resource": "" }
q19781
TelegramResponse.decodeBody
train
public function decodeBody() { $this->decodedBody = json_decode($this->body, true); if ($this->decodedBody === null) { $this->decodedBody = []; parse_str($this->body, $this->decodedBody); } if (!is_array($this->decodedBody))
php
{ "resource": "" }
q19782
Message.isType
train
public function isType($type) { if ($this->has(strtolower($type))) { return true;
php
{ "resource": "" }
q19783
TelegramResponseException.create
train
public static function create(TelegramResponse $response) { $data = $response->getDecodedBody(); $code = null; $message = null; if (isset($data['ok'], $data['error_code']) && $data['ok'] === false) { $code = $data['error_code']; $message = isset($data['descri...
php
{ "resource": "" }
q19784
InputFile.open
train
public function open() { if (is_resource($this->path)) { return $this->path; } if (!$this->isRemoteFile() && !is_readable($this->path)) { throw new TelegramSDKException('Failed to
php
{ "resource": "" }
q19785
TelegramClient.prepareRequest
train
public function prepareRequest(TelegramRequest $request) { $url = $this->getBaseBotUrl().$request->getAccessToken().'/'.$request->getEndpoint(); return [ $url,
php
{ "resource": "" }
q19786
TelegramClient.sendRequest
train
public function sendRequest(TelegramRequest $request) { list($url, $method, $headers, $isAsyncRequest) = $this->prepareRequest($request); $timeOut = $request->getTimeOut(); $connectTimeOut = $request->getConnectTimeOut(); $options = $this->getOptions($request, $method); $r...
php
{ "resource": "" }
q19787
Startup.run
train
public static function run(array &$config) { self::$config = $config; self::startTemplateEngine ( $config ); if (isset ( $config
php
{ "resource": "" }
q19788
Startup.forward
train
public static function forward($url, $initialize = true, $finalize = true) { $u = self::parseUrl ( $url ); if (is_array ( Router::getRoutes () ) && ($ru = Router::getRoute ( $url )) !== false) { if (\is_array ( $ru )) { if (is_callable ( $ru [0] )) { self::runCallable ( $ru ); } else { self::_p...
php
{ "resource": "" }
q19789
Startup.runAction
train
public static function runAction(array &$u, $initialize = true, $finalize = true) { $ctrl = $u [0]; self::$controller = $ctrl; self::$action = "index"; self::$actionParams = [ ]; if (\sizeof ( $u ) > 1) self::$action = $u [1]; if (\sizeof ( $u ) > 2) self::$actionParams = array_slice ( $u, 2 ); $co...
php
{ "resource": "" }
q19790
Startup.runCallable
train
public static function runCallable(array &$u) { self::$actionParams = [ ]; if (\sizeof ( $u ) > 1) { self::$actionParams = array_slice ( $u, 1 ); } if (isset ( self::$config ['di'] )) { $di = self::$config ['di'];
php
{ "resource": "" }
q19791
Startup.runAsString
train
public static function runAsString(array &$u, $initialize = true, $finalize = true) { \ob_start ();
php
{ "resource": "" }
q19792
AuthController.noAccess
train
public function noAccess($urlParts) { if (! is_array ( $urlParts )) { $urlParts = explode ( ".", $urlParts ); } USession::set ( "urlParts", $urlParts ); $fMessage = $this->_noAccessMsg; $this->noAccessMessage ( $fMessage ); $message = $this->fMessage ( $fMessage->parseContent ( [ "url" => implode ( "/", ...
php
{ "resource": "" }
q19793
AuthController.connect
train
public function connect() { if (URequest::isPost ()) { if ($connected = $this->_connect ()) { if (isset ( $_POST ["ck-remember"] )) { $this->rememberMe ( $connected ); } if (USession::exists ( $this->_attemptsSessionKey )) {
php
{ "resource": "" }
q19794
AuthController.badLogin
train
public function badLogin() { $fMessage = new FlashMessage ( "Invalid creditentials!", "Connection problem", "warning", "warning circle" ); $this->badLoginMessage ( $fMessage ); $attemptsMessage = ""; if (($nbAttempsMax = $this->attemptsNumber ()) !== null) { $nb = USession::getTmp ( $this->_attemptsSessionKe...
php
{ "resource": "" }
q19795
AuthController.terminate
train
public function terminate() { USession::terminate (); $fMessage = new FlashMessage ( "You have been properly disconnected!", "Logout", "success", "checkmark" ); $this->terminateMessage ( $fMessage ); $message = $this->fMessage ( $fMessage ); $this->authLoadView ( $this->_getFiles ()->getViewNoAccess (),
php
{ "resource": "" }
q19796
AuthController.info
train
public function info($force = null) { if (isset ( $force )) { $displayInfoAsString = ($force === true) ? true : false; } else { $displayInfoAsString = $this->_displayInfoAsString ();
php
{ "resource": "" }
q19797
AuthController._autoConnect
train
public function _autoConnect() { $cookie = $this->getCookieUser (); if (isset ( $cookie )) { $user = $this->fromCookie ( $cookie ); if (isset ( $user ))
php
{ "resource": "" }
q19798
TransformersManager.start
train
public static function start() { $transformers = [ ]; if (CacheManager::$cache->exists ( self::$key ))
php
{ "resource": "" }
q19799
CacheManager.start
train
public static function start(&$config) { self::$cacheDirectory = self::initialGetCacheDirectory ( $config ); $cacheDirectory = \ROOT . \DS . self::$cacheDirectory; Annotations::$config ['cache'] = new AnnotationCache ( $cacheDirectory
php
{ "resource": "" }