repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
ezsystems/BehatBundle
Context/Resolver/AnnotationArgumentResolver.php
AnnotationArgumentResolver.getMethodAnnotations
private function getMethodAnnotations($refClass, $method = '__construct') { $refMethod = $refClass->getMethod($method); preg_match_all('#@(.*?)\n#s', $refMethod->getDocComment(), $matches); return $matches[1]; }
php
private function getMethodAnnotations($refClass, $method = '__construct') { $refMethod = $refClass->getMethod($method); preg_match_all('#@(.*?)\n#s', $refMethod->getDocComment(), $matches); return $matches[1]; }
[ "private", "function", "getMethodAnnotations", "(", "$", "refClass", ",", "$", "method", "=", "'__construct'", ")", "{", "$", "refMethod", "=", "$", "refClass", "->", "getMethod", "(", "$", "method", ")", ";", "preg_match_all", "(", "'#@(.*?)\\n#s'", ",", "$...
Returns a array with the method annotations @return array array annotations
[ "Returns", "a", "array", "with", "the", "method", "annotations" ]
train
https://github.com/ezsystems/BehatBundle/blob/7d6d409545ec7cb69a3ab6636a59159df033695d/Context/Resolver/AnnotationArgumentResolver.php#L50-L56
ezsystems/BehatBundle
ObjectManager/Role.php
Role.ensureRoleExists
public function ensureRoleExists( $name ) { /** @var \eZ\Publish\API\Repository\Repository $repository */ $repository = $this->getRepository(); $that = $this; $role = $repository->sudo( function() use( $repository, $name, $that ) { $role = nul...
php
public function ensureRoleExists( $name ) { /** @var \eZ\Publish\API\Repository\Repository $repository */ $repository = $this->getRepository(); $that = $this; $role = $repository->sudo( function() use( $repository, $name, $that ) { $role = nul...
[ "public", "function", "ensureRoleExists", "(", "$", "name", ")", "{", "/** @var \\eZ\\Publish\\API\\Repository\\Repository $repository */", "$", "repository", "=", "$", "this", "->", "getRepository", "(", ")", ";", "$", "that", "=", "$", "this", ";", "$", "role", ...
Make sure a Role with name $name exists in parent group @param string $name Role identifier @return \eZ\Publish\API\Repository\Values\User\Role
[ "Make", "sure", "a", "Role", "with", "name", "$name", "exists", "in", "parent", "group" ]
train
https://github.com/ezsystems/BehatBundle/blob/7d6d409545ec7cb69a3ab6636a59159df033695d/ObjectManager/Role.php#L29-L66
ezsystems/BehatBundle
ObjectManager/Role.php
Role.getRole
public function getRole( $identifier ) { /** @var \eZ\Publish\API\Repository\Repository $repository */ $repository = $this->getRepository(); $role = $repository->sudo( function() use( $repository, $identifier ) { $role = null; $roleSer...
php
public function getRole( $identifier ) { /** @var \eZ\Publish\API\Repository\Repository $repository */ $repository = $this->getRepository(); $role = $repository->sudo( function() use( $repository, $identifier ) { $role = null; $roleSer...
[ "public", "function", "getRole", "(", "$", "identifier", ")", "{", "/** @var \\eZ\\Publish\\API\\Repository\\Repository $repository */", "$", "repository", "=", "$", "this", "->", "getRepository", "(", ")", ";", "$", "role", "=", "$", "repository", "->", "sudo", "...
Fetches the role with identifier @param string $identifier Role identifier @return \eZ\Publish\API\Repository\Values\User\Role
[ "Fetches", "the", "role", "with", "identifier" ]
train
https://github.com/ezsystems/BehatBundle/blob/7d6d409545ec7cb69a3ab6636a59159df033695d/ObjectManager/Role.php#L75-L105
ezsystems/BehatBundle
ObjectManager/Role.php
Role.destroy
protected function destroy( ValueObject $object ) { // Ignore warnings about not empty cache directory. See: https://github.com/ezsystems/BehatBundle/pull/71 $currentErrorReportingLevel = error_reporting(); error_reporting($currentErrorReportingLevel & ~E_WARNING); /** @var \eZ\Publ...
php
protected function destroy( ValueObject $object ) { // Ignore warnings about not empty cache directory. See: https://github.com/ezsystems/BehatBundle/pull/71 $currentErrorReportingLevel = error_reporting(); error_reporting($currentErrorReportingLevel & ~E_WARNING); /** @var \eZ\Publ...
[ "protected", "function", "destroy", "(", "ValueObject", "$", "object", ")", "{", "// Ignore warnings about not empty cache directory. See: https://github.com/ezsystems/BehatBundle/pull/71", "$", "currentErrorReportingLevel", "=", "error_reporting", "(", ")", ";", "error_reporting",...
[destroy description] @param ValueObject $object [description] @return [type] [description]
[ "[", "destroy", "description", "]" ]
train
https://github.com/ezsystems/BehatBundle/blob/7d6d409545ec7cb69a3ab6636a59159df033695d/ObjectManager/Role.php#L112-L137
ezsystems/BehatBundle
Context/EzContext.php
EzContext.prepareKernel
public function prepareKernel( $event ) { // temporary class alias // for PHPUnit v6 adoption time if (!class_exists('PHPUnit_Framework_Assert')) { class_alias('PHPUnit\Framework\Assert', 'PHPUnit_Framework_Assert'); } $container = $this->getKernel()->getContaine...
php
public function prepareKernel( $event ) { // temporary class alias // for PHPUnit v6 adoption time if (!class_exists('PHPUnit_Framework_Assert')) { class_alias('PHPUnit\Framework\Assert', 'PHPUnit_Framework_Assert'); } $container = $this->getKernel()->getContaine...
[ "public", "function", "prepareKernel", "(", "$", "event", ")", "{", "// temporary class alias", "// for PHPUnit v6 adoption time", "if", "(", "!", "class_exists", "(", "'PHPUnit_Framework_Assert'", ")", ")", "{", "class_alias", "(", "'PHPUnit\\Framework\\Assert'", ",", ...
@BeforeScenario @param \Behat\Behat\Event\ScenarioEvent|\Behat\Behat\Event\OutlineExampleEvent $event
[ "@BeforeScenario" ]
train
https://github.com/ezsystems/BehatBundle/blob/7d6d409545ec7cb69a3ab6636a59159df033695d/Context/EzContext.php#L106-L118
ezsystems/BehatBundle
Context/EzContext.php
EzContext.getObjectManager
protected function getObjectManager( $object ) { $namespace = '\\EzSystems\\BehatBundle\\ObjectManager\\'; if ( empty( $this->objectManagers[$object] ) ) { $class = $namespace . $object; if ( ! class_exists( $class ) && is_subclass_of(...
php
protected function getObjectManager( $object ) { $namespace = '\\EzSystems\\BehatBundle\\ObjectManager\\'; if ( empty( $this->objectManagers[$object] ) ) { $class = $namespace . $object; if ( ! class_exists( $class ) && is_subclass_of(...
[ "protected", "function", "getObjectManager", "(", "$", "object", ")", "{", "$", "namespace", "=", "'\\\\EzSystems\\\\BehatBundle\\\\ObjectManager\\\\'", ";", "if", "(", "empty", "(", "$", "this", "->", "objectManagers", "[", "$", "object", "]", ")", ")", "{", ...
Get a specific object manager @param string $object Name of the object manager @return \EzSystems\BehatBundle\ObjectManager\ObjectManagerInterface @throws \Exception $object isn't found or doesn't implement \EzSystems\BehatBundle\ObjectManager\ObjectManagerInterface
[ "Get", "a", "specific", "object", "manager" ]
train
https://github.com/ezsystems/BehatBundle/blob/7d6d409545ec7cb69a3ab6636a59159df033695d/Context/EzContext.php#L148-L167
ezsystems/BehatBundle
Context/EzContext.php
EzContext.addValuesToKeyMap
protected function addValuesToKeyMap( $key, $values ) { if ( empty( $key ) ) { throw new InvalidArgumentException( 'key', "can't be empty" ); } if ( ! empty( $this->keyMap[$key] ) ) { throw new InvalidArgumentException( 'key', 'key exists' ); ...
php
protected function addValuesToKeyMap( $key, $values ) { if ( empty( $key ) ) { throw new InvalidArgumentException( 'key', "can't be empty" ); } if ( ! empty( $this->keyMap[$key] ) ) { throw new InvalidArgumentException( 'key', 'key exists' ); ...
[ "protected", "function", "addValuesToKeyMap", "(", "$", "key", ",", "$", "values", ")", "{", "if", "(", "empty", "(", "$", "key", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'key'", ",", "\"can't be empty\"", ")", ";", "}", "if", "("...
Store (map) values needed for testing that can't be passed through gherkin @param string $key (Unique) Identifier key on the array @param mixed $values Any kind of value/object to store @throws \eZ\Publish\Core\Base\Exceptions\InvalidArgumentException if $key is empty
[ "Store", "(", "map", ")", "values", "needed", "for", "testing", "that", "can", "t", "be", "passed", "through", "gherkin" ]
train
https://github.com/ezsystems/BehatBundle/blob/7d6d409545ec7cb69a3ab6636a59159df033695d/Context/EzContext.php#L177-L190
ezsystems/BehatBundle
Context/EzContext.php
EzContext.getValuesFromKeyMap
protected function getValuesFromKeyMap( $key ) { if ( empty( $key ) || empty( $this->keyMap[$key] ) ) { return null; } return $this->keyMap[$key]; }
php
protected function getValuesFromKeyMap( $key ) { if ( empty( $key ) || empty( $this->keyMap[$key] ) ) { return null; } return $this->keyMap[$key]; }
[ "protected", "function", "getValuesFromKeyMap", "(", "$", "key", ")", "{", "if", "(", "empty", "(", "$", "key", ")", "||", "empty", "(", "$", "this", "->", "keyMap", "[", "$", "key", "]", ")", ")", "{", "return", "null", ";", "}", "return", "$", ...
Fetches values needed for testing stored on mapping @param string $key (Unique) Identifier key on the array @return mixed|null Mapped value or null if not found
[ "Fetches", "values", "needed", "for", "testing", "stored", "on", "mapping" ]
train
https://github.com/ezsystems/BehatBundle/blob/7d6d409545ec7cb69a3ab6636a59159df033695d/Context/EzContext.php#L199-L207
ezsystems/BehatBundle
Context/EzContext.php
EzContext.changeMappedValuesOnUrl
protected function changeMappedValuesOnUrl( $url ) { $newUrl = ""; foreach ( explode( '/', $url ) as $chunk ) { $newChunk = $this->getValuesFromKeyMap( $chunk ); if ( empty( $newChunk ) ) { $newChunk = $chunk; } $ne...
php
protected function changeMappedValuesOnUrl( $url ) { $newUrl = ""; foreach ( explode( '/', $url ) as $chunk ) { $newChunk = $this->getValuesFromKeyMap( $chunk ); if ( empty( $newChunk ) ) { $newChunk = $chunk; } $ne...
[ "protected", "function", "changeMappedValuesOnUrl", "(", "$", "url", ")", "{", "$", "newUrl", "=", "\"\"", ";", "foreach", "(", "explode", "(", "'/'", ",", "$", "url", ")", "as", "$", "chunk", ")", "{", "$", "newChunk", "=", "$", "this", "->", "getVa...
Change the mapped values in key map into the intended URL ex: $keyMap = array( '{id}' => 123, 'another' => 'test', '{extraId}' => 321 ); URL: before: '/some/url/with/another/and/{id}' after: '/some/url/with/test/and/123' @param string $url URL to update key mapped values @return string Updated URL
[ "Change", "the", "mapped", "values", "in", "key", "map", "into", "the", "intended", "URL" ]
train
https://github.com/ezsystems/BehatBundle/blob/7d6d409545ec7cb69a3ab6636a59159df033695d/Context/EzContext.php#L226-L241
ezsystems/BehatBundle
Context/EzContext.php
EzContext.getCredentialsFor
protected function getCredentialsFor( $roleIdentifier ) { $roleService = $this->getRepository()->getRoleService(); // First try to load role, throws exception if not found. $role = $this->getRepository()->sudo( function() use ( $roleService, $roleIdentifier ) { ...
php
protected function getCredentialsFor( $roleIdentifier ) { $roleService = $this->getRepository()->getRoleService(); // First try to load role, throws exception if not found. $role = $this->getRepository()->sudo( function() use ( $roleService, $roleIdentifier ) { ...
[ "protected", "function", "getCredentialsFor", "(", "$", "roleIdentifier", ")", "{", "$", "roleService", "=", "$", "this", "->", "getRepository", "(", ")", "->", "getRoleService", "(", ")", ";", "// First try to load role, throws exception if not found.", "$", "role", ...
Get credentials for a specific role @uses \EzSystems\BehatBundle\Context\Object\User @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException @param string $role Role intended for testing @return array Associative with 'login' and 'password'
[ "Get", "credentials", "for", "a", "specific", "role" ]
train
https://github.com/ezsystems/BehatBundle/blob/7d6d409545ec7cb69a3ab6636a59159df033695d/Context/EzContext.php#L253-L294
ezsystems/BehatBundle
ObjectManager/UserGroup.php
UserGroup.loadUserGroup
public function loadUserGroup( $id ) { /** @var \eZ\Publish\API\Repository\Repository $repository */ $repository = $this->getRepository(); $userService = $repository->getUserService(); $userGroup = $repository->sudo( function() use( $id, $userService ) { ...
php
public function loadUserGroup( $id ) { /** @var \eZ\Publish\API\Repository\Repository $repository */ $repository = $this->getRepository(); $userService = $repository->getUserService(); $userGroup = $repository->sudo( function() use( $id, $userService ) { ...
[ "public", "function", "loadUserGroup", "(", "$", "id", ")", "{", "/** @var \\eZ\\Publish\\API\\Repository\\Repository $repository */", "$", "repository", "=", "$", "this", "->", "getRepository", "(", ")", ";", "$", "userService", "=", "$", "repository", "->", "getUs...
Load a User Group by id @param int $id User Group content identifier @return \eZ\Publish\API\Repository\Values\User\UserGroup
[ "Load", "a", "User", "Group", "by", "id" ]
train
https://github.com/ezsystems/BehatBundle/blob/7d6d409545ec7cb69a3ab6636a59159df033695d/ObjectManager/UserGroup.php#L36-L50
ezsystems/BehatBundle
ObjectManager/UserGroup.php
UserGroup.createUserGroup
public function createUserGroup( $name, $parentGroup = null ) { $repository = $this->getRepository(); $userService = $repository->getUserService(); if ( !$parentGroup ) { $parentGroup = $this->loadUserGroup( self::USERGROUP_ROOT_CONTENT_ID ); } $userGrou...
php
public function createUserGroup( $name, $parentGroup = null ) { $repository = $this->getRepository(); $userService = $repository->getUserService(); if ( !$parentGroup ) { $parentGroup = $this->loadUserGroup( self::USERGROUP_ROOT_CONTENT_ID ); } $userGrou...
[ "public", "function", "createUserGroup", "(", "$", "name", ",", "$", "parentGroup", "=", "null", ")", "{", "$", "repository", "=", "$", "this", "->", "getRepository", "(", ")", ";", "$", "userService", "=", "$", "repository", "->", "getUserService", "(", ...
Create new User Group inside existing parent User Group @param string $name User Group name @param \eZ\Publish\API\Repository\Values\User\UserGroup $parentGroup (optional) parent user group, defaults to UserGroup "/Users" @return \eZ\Publish\API\Repository\Values\User\UserGroup
[ "Create", "new", "User", "Group", "inside", "existing", "parent", "User", "Group" ]
train
https://github.com/ezsystems/BehatBundle/blob/7d6d409545ec7cb69a3ab6636a59159df033695d/ObjectManager/UserGroup.php#L94-L114
ezsystems/BehatBundle
ObjectManager/UserGroup.php
UserGroup.ensureUserGroupExists
public function ensureUserGroupExists( $name, $parentGroupName = null ) { if ( $parentGroupName ) { // find parent group name $searchResults = $this->searchUserGroups( $parentGroupName ); if ( !empty( $searchResults ) ) { $parentGroup =...
php
public function ensureUserGroupExists( $name, $parentGroupName = null ) { if ( $parentGroupName ) { // find parent group name $searchResults = $this->searchUserGroups( $parentGroupName ); if ( !empty( $searchResults ) ) { $parentGroup =...
[ "public", "function", "ensureUserGroupExists", "(", "$", "name", ",", "$", "parentGroupName", "=", "null", ")", "{", "if", "(", "$", "parentGroupName", ")", "{", "// find parent group name", "$", "searchResults", "=", "$", "this", "->", "searchUserGroups", "(", ...
Make sure a User Group with name $name exists in parent group @param string $name User Group name @param string $parentGroupName (optional) name of the parent group to check @return \eZ\Publish\API\Repository\Values\User\UserGroup
[ "Make", "sure", "a", "User", "Group", "with", "name", "$name", "exists", "in", "parent", "group" ]
train
https://github.com/ezsystems/BehatBundle/blob/7d6d409545ec7cb69a3ab6636a59159df033695d/ObjectManager/UserGroup.php#L124-L157
ezsystems/BehatBundle
ObjectManager/UserGroup.php
UserGroup.ensureUserGroupDoesntExist
public function ensureUserGroupDoesntExist( $name, $parentGroupName = null ) { $repository = $this->getRepository(); $userService = $repository->getUserService(); if ( $parentGroupName ) { // find parent group name $searchResults = $this->searchUserGroups( $p...
php
public function ensureUserGroupDoesntExist( $name, $parentGroupName = null ) { $repository = $this->getRepository(); $userService = $repository->getUserService(); if ( $parentGroupName ) { // find parent group name $searchResults = $this->searchUserGroups( $p...
[ "public", "function", "ensureUserGroupDoesntExist", "(", "$", "name", ",", "$", "parentGroupName", "=", "null", ")", "{", "$", "repository", "=", "$", "this", "->", "getRepository", "(", ")", ";", "$", "userService", "=", "$", "repository", "->", "getUserSer...
Make sure a User Group with name $name doesn't exist in parent group @param string $name name of the User Group to check/remove @param string $parentGroupName (optional) parent group to search in
[ "Make", "sure", "a", "User", "Group", "with", "name", "$name", "doesn", "t", "exist", "in", "parent", "group" ]
train
https://github.com/ezsystems/BehatBundle/blob/7d6d409545ec7cb69a3ab6636a59159df033695d/ObjectManager/UserGroup.php#L165-L212
ezsystems/BehatBundle
ObjectManager/UserGroup.php
UserGroup.checkUserGroupExistence
public function checkUserGroupExistence( $id ) { /** @var \eZ\Publish\API\Repository\Repository $repository */ $repository = $this->getRepository(); $userService = $repository->getUserService(); return $repository->sudo( function() use( $id, $userService ) { ...
php
public function checkUserGroupExistence( $id ) { /** @var \eZ\Publish\API\Repository\Repository $repository */ $repository = $this->getRepository(); $userService = $repository->getUserService(); return $repository->sudo( function() use( $id, $userService ) { ...
[ "public", "function", "checkUserGroupExistence", "(", "$", "id", ")", "{", "/** @var \\eZ\\Publish\\API\\Repository\\Repository $repository */", "$", "repository", "=", "$", "this", "->", "getRepository", "(", ")", ";", "$", "userService", "=", "$", "repository", "->"...
Checks if the UserGroup with $id exists @param string $id Identifier of the possible content @return boolean true if it exists, false if not
[ "Checks", "if", "the", "UserGroup", "with", "$id", "exists" ]
train
https://github.com/ezsystems/BehatBundle/blob/7d6d409545ec7cb69a3ab6636a59159df033695d/ObjectManager/UserGroup.php#L221-L242
ezsystems/BehatBundle
ObjectManager/UserGroup.php
UserGroup.checkUserGroupExistenceByName
public function checkUserGroupExistenceByName( $name, $parentGroupName = null ) { if ( $parentGroupName ) { // find parent group name $searchResults = $this->searchUserGroups( $parentGroupName ); if ( empty( $searchResults ) ) { throw n...
php
public function checkUserGroupExistenceByName( $name, $parentGroupName = null ) { if ( $parentGroupName ) { // find parent group name $searchResults = $this->searchUserGroups( $parentGroupName ); if ( empty( $searchResults ) ) { throw n...
[ "public", "function", "checkUserGroupExistenceByName", "(", "$", "name", ",", "$", "parentGroupName", "=", "null", ")", "{", "if", "(", "$", "parentGroupName", ")", "{", "// find parent group name", "$", "searchResults", "=", "$", "this", "->", "searchUserGroups",...
Checks if the UserGroup with name $name exists @param string $name User Group name @return boolean true if it exists, false if not
[ "Checks", "if", "the", "UserGroup", "with", "name", "$name", "exists" ]
train
https://github.com/ezsystems/BehatBundle/blob/7d6d409545ec7cb69a3ab6636a59159df033695d/ObjectManager/UserGroup.php#L251-L271
ezsystems/BehatBundle
ObjectManager/UserGroup.php
UserGroup.destroy
protected function destroy( ValueObject $object ) { /** @var \eZ\Publish\API\Repository\Repository $repository */ $repository = $this->getRepository(); $repository->sudo( function() use( $repository, $object ) { $userService = $repository->getUserServi...
php
protected function destroy( ValueObject $object ) { /** @var \eZ\Publish\API\Repository\Repository $repository */ $repository = $this->getRepository(); $repository->sudo( function() use( $repository, $object ) { $userService = $repository->getUserServi...
[ "protected", "function", "destroy", "(", "ValueObject", "$", "object", ")", "{", "/** @var \\eZ\\Publish\\API\\Repository\\Repository $repository */", "$", "repository", "=", "$", "this", "->", "getRepository", "(", ")", ";", "$", "repository", "->", "sudo", "(", "f...
[destroy description] @param ValueObject $object [description] @return [type] [description]
[ "[", "destroy", "description", "]" ]
train
https://github.com/ezsystems/BehatBundle/blob/7d6d409545ec7cb69a3ab6636a59159df033695d/ObjectManager/UserGroup.php#L278-L297
ezsystems/BehatBundle
Helper/Gherkin.php
Gherkin.convertTableToArrayOfData
static function convertTableToArrayOfData( TableNode $table, array $data = null ) { if( empty( $data ) ) $data = array(); // prepare given data $i = 0; $rows = $table->getRows(); $headers = array_shift( $rows ); // this is needed to take the first row ( readabi...
php
static function convertTableToArrayOfData( TableNode $table, array $data = null ) { if( empty( $data ) ) $data = array(); // prepare given data $i = 0; $rows = $table->getRows(); $headers = array_shift( $rows ); // this is needed to take the first row ( readabi...
[ "static", "function", "convertTableToArrayOfData", "(", "TableNode", "$", "table", ",", "array", "$", "data", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "data", ")", ")", "$", "data", "=", "array", "(", ")", ";", "// prepare given data", "$", ...
This function will convert Gherkin tables into structure array of data if Gherkin table look like | field | value1 | value2 | ... | valueN | | field1 | single value 1 | | ... | | | field2 | single value 2 | | ... | | | field3 | multiple | value | ... | here | the returne...
[ "This", "function", "will", "convert", "Gherkin", "tables", "into", "structure", "array", "of", "data" ]
train
https://github.com/ezsystems/BehatBundle/blob/7d6d409545ec7cb69a3ab6636a59159df033695d/Helper/Gherkin.php#L63-L122
ezsystems/BehatBundle
ObjectManager/Base.php
Base.setContext
protected function setContext( KernelAwareContext $context ) { $this->context = $context; $this->kernel = $context->getKernel(); }
php
protected function setContext( KernelAwareContext $context ) { $this->context = $context; $this->kernel = $context->getKernel(); }
[ "protected", "function", "setContext", "(", "KernelAwareContext", "$", "context", ")", "{", "$", "this", "->", "context", "=", "$", "context", ";", "$", "this", "->", "kernel", "=", "$", "context", "->", "getKernel", "(", ")", ";", "}" ]
Set kernel @param \Symfony\Component\HttpKernel\KernelInterface $kernel
[ "Set", "kernel" ]
train
https://github.com/ezsystems/BehatBundle/blob/7d6d409545ec7cb69a3ab6636a59159df033695d/ObjectManager/Base.php#L45-L49
ezsystems/BehatBundle
ObjectManager/Base.php
Base.instance
static public function instance( KernelAwareContext $context ) { static $instance = null; if ( $instance === null ) { $class = get_called_class(); $instance = new $class(); $instance->setContext( $context ); } return $instance; }
php
static public function instance( KernelAwareContext $context ) { static $instance = null; if ( $instance === null ) { $class = get_called_class(); $instance = new $class(); $instance->setContext( $context ); } return $instance; }
[ "static", "public", "function", "instance", "(", "KernelAwareContext", "$", "context", ")", "{", "static", "$", "instance", "=", "null", ";", "if", "(", "$", "instance", "===", "null", ")", "{", "$", "class", "=", "get_called_class", "(", ")", ";", "$", ...
Get instance These objects should be singletons, so Object::instance() should take care of returning the instance and create it when it's not created @param \Symfony\Component\HttpKernel\KernelInterface @return \EzSystems\BehatBundle\ObjectManager\Base
[ "Get", "instance" ]
train
https://github.com/ezsystems/BehatBundle/blob/7d6d409545ec7cb69a3ab6636a59159df033695d/ObjectManager/Base.php#L61-L72
ezsystems/BehatBundle
ObjectManager/Base.php
Base.clean
public function clean() { foreach ( $this->createdObjects as $object ) { $this->destroy( $object ); } $this->createdObjects = array(); }
php
public function clean() { foreach ( $this->createdObjects as $object ) { $this->destroy( $object ); } $this->createdObjects = array(); }
[ "public", "function", "clean", "(", ")", "{", "foreach", "(", "$", "this", "->", "createdObjects", "as", "$", "object", ")", "{", "$", "this", "->", "destroy", "(", "$", "object", ")", ";", "}", "$", "this", "->", "createdObjects", "=", "array", "(",...
Destroy/remove/delete all created objects (from given steps)
[ "Destroy", "/", "remove", "/", "delete", "all", "created", "objects", "(", "from", "given", "steps", ")" ]
train
https://github.com/ezsystems/BehatBundle/blob/7d6d409545ec7cb69a3ab6636a59159df033695d/ObjectManager/Base.php#L122-L130
ezsystems/BehatBundle
Context/Browser/Context.php
Context.getPathByPageIdentifier
public function getPathByPageIdentifier( $pageIdentifier ) { if ( !isset( $this->pageIdentifierMap[strtolower( $pageIdentifier )] ) ) { throw new \RuntimeException( "Unknown page identifier '{$pageIdentifier}'." ); } return $this->pageIdentifierMap[strtolower( $pageIdent...
php
public function getPathByPageIdentifier( $pageIdentifier ) { if ( !isset( $this->pageIdentifierMap[strtolower( $pageIdentifier )] ) ) { throw new \RuntimeException( "Unknown page identifier '{$pageIdentifier}'." ); } return $this->pageIdentifierMap[strtolower( $pageIdent...
[ "public", "function", "getPathByPageIdentifier", "(", "$", "pageIdentifier", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "pageIdentifierMap", "[", "strtolower", "(", "$", "pageIdentifier", ")", "]", ")", ")", "{", "throw", "new", "\\", "Runt...
Returns the path associated with $pageIdentifier @param string $pageIdentifier @return string URL path @throws \RuntimeException If $pageIdentifier is not set
[ "Returns", "the", "path", "associated", "with", "$pageIdentifier" ]
train
https://github.com/ezsystems/BehatBundle/blob/7d6d409545ec7cb69a3ab6636a59159df033695d/Context/Browser/Context.php#L103-L111
ezsystems/BehatBundle
Context/Browser/Context.php
Context.concatTagsWithXpath
public function concatTagsWithXpath( array $tags, $xpath = null ) { $finalXpath = ""; for ( $i = 0; !empty( $tags[$i] ); $i++ ) { $finalXpath .= "//{$tags[$i]}$xpath"; if ( !empty( $tags[$i + 1] ) ) { $finalXpath .= " | "; } ...
php
public function concatTagsWithXpath( array $tags, $xpath = null ) { $finalXpath = ""; for ( $i = 0; !empty( $tags[$i] ); $i++ ) { $finalXpath .= "//{$tags[$i]}$xpath"; if ( !empty( $tags[$i + 1] ) ) { $finalXpath .= " | "; } ...
[ "public", "function", "concatTagsWithXpath", "(", "array", "$", "tags", ",", "$", "xpath", "=", "null", ")", "{", "$", "finalXpath", "=", "\"\"", ";", "for", "(", "$", "i", "=", "0", ";", "!", "empty", "(", "$", "tags", "[", "$", "i", "]", ")", ...
This should be seen as a complement to self::getTagsFor() where it will get the respective tags from there and will make a valid Xpath string with all OR's needed @param array $tags Array of tags strings (ex: array( "a", "p", "h3", "table" ) ) @param string $xpath String to be concatenated to each tag @return strin...
[ "This", "should", "be", "seen", "as", "a", "complement", "to", "self", "::", "getTagsFor", "()", "where", "it", "will", "get", "the", "respective", "tags", "from", "there", "and", "will", "make", "a", "valid", "Xpath", "string", "with", "all", "OR", "s",...
train
https://github.com/ezsystems/BehatBundle/blob/7d6d409545ec7cb69a3ab6636a59159df033695d/Context/Browser/Context.php#L123-L136
ezsystems/BehatBundle
Context/Browser/Context.php
Context.getUrlWithoutQueryString
public function getUrlWithoutQueryString( $url ) { if ( strpos( $url, '?' ) !== false ) { $url = substr( $url, 0, strpos( $url, '?' ) ); } return $url; }
php
public function getUrlWithoutQueryString( $url ) { if ( strpos( $url, '?' ) !== false ) { $url = substr( $url, 0, strpos( $url, '?' ) ); } return $url; }
[ "public", "function", "getUrlWithoutQueryString", "(", "$", "url", ")", "{", "if", "(", "strpos", "(", "$", "url", ",", "'?'", ")", "!==", "false", ")", "{", "$", "url", "=", "substr", "(", "$", "url", ",", "0", ",", "strpos", "(", "$", "url", ",...
Returns $url without its query string @param string $url @return string Complete url without the query string
[ "Returns", "$url", "without", "its", "query", "string" ]
train
https://github.com/ezsystems/BehatBundle/blob/7d6d409545ec7cb69a3ab6636a59159df033695d/Context/Browser/Context.php#L172-L180
ezsystems/BehatBundle
Context/Browser/Context.php
Context.checkLinksExistence
protected function checkLinksExistence( array $links, array $available, $checkOrder = false ) { $i = $passed = 0; $last = ''; $messageAfter = ''; foreach ( $links as $link ) { if ( ! $checkOrder ) { $i = 0; } //...
php
protected function checkLinksExistence( array $links, array $available, $checkOrder = false ) { $i = $passed = 0; $last = ''; $messageAfter = ''; foreach ( $links as $link ) { if ( ! $checkOrder ) { $i = 0; } //...
[ "protected", "function", "checkLinksExistence", "(", "array", "$", "links", ",", "array", "$", "available", ",", "$", "checkOrder", "=", "false", ")", "{", "$", "i", "=", "$", "passed", "=", "0", ";", "$", "last", "=", "''", ";", "$", "messageAfter", ...
Checks if links exist and in the following order (if intended) Notice: if there are 3 links and we omit the middle link it will also be correct. It only checks order, not if there should be anything in between them @param array $links Array with link text/title @param Behat\Mink\Element\NodeElement[] $available @param...
[ "Checks", "if", "links", "exist", "and", "in", "the", "following", "order", "(", "if", "intended", ")", "Notice", ":", "if", "there", "are", "3", "links", "and", "we", "omit", "the", "middle", "link", "it", "will", "also", "be", "correct", ".", "It", ...
train
https://github.com/ezsystems/BehatBundle/blob/7d6d409545ec7cb69a3ab6636a59159df033695d/Context/Browser/Context.php#L196-L237
ezsystems/BehatBundle
Context/Browser/Context.php
Context.getNumberFromString
public function getNumberFromString( $string ) { preg_match( '/(?P<digit>\d+)/', $string, $result ); Assertion::assertNotEmpty( $result['digit'], "Expected to find a number in '$string' found none" ); return (int)$result['digit']; }
php
public function getNumberFromString( $string ) { preg_match( '/(?P<digit>\d+)/', $string, $result ); Assertion::assertNotEmpty( $result['digit'], "Expected to find a number in '$string' found none" ); return (int)$result['digit']; }
[ "public", "function", "getNumberFromString", "(", "$", "string", ")", "{", "preg_match", "(", "'/(?P<digit>\\d+)/'", ",", "$", "string", ",", "$", "result", ")", ";", "Assertion", "::", "assertNotEmpty", "(", "$", "result", "[", "'digit'", "]", ",", "\"Expec...
Fetchs the first integer in the string @param string $string Text @return int Integer found on text @throws \PHPUnit_Framework_AssertionFailedError
[ "Fetchs", "the", "first", "integer", "in", "the", "string" ]
train
https://github.com/ezsystems/BehatBundle/blob/7d6d409545ec7cb69a3ab6636a59159df033695d/Context/Browser/Context.php#L248-L253
ezsystems/BehatBundle
Context/Browser/Context.php
Context.existTableRow
public function existTableRow( NodeElement $row, array $columns, array $columnsPositions = null ) { // find which kind of column is in this row $elType = $row->find( 'xpath', "/th" ); $type = ( empty( $elType ) ) ? '/td' : '/th'; $max = count( $columns ); for ( $i = 0; $i < ...
php
public function existTableRow( NodeElement $row, array $columns, array $columnsPositions = null ) { // find which kind of column is in this row $elType = $row->find( 'xpath', "/th" ); $type = ( empty( $elType ) ) ? '/td' : '/th'; $max = count( $columns ); for ( $i = 0; $i < ...
[ "public", "function", "existTableRow", "(", "NodeElement", "$", "row", ",", "array", "$", "columns", ",", "array", "$", "columnsPositions", "=", "null", ")", "{", "// find which kind of column is in this row", "$", "elType", "=", "$", "row", "->", "find", "(", ...
Verifies if a row as the expected columns, position of columns can be added for a more accurated assertion @param \Behat\Mink\Element\NodeElement $row Table row node element @param string[] $columns Column text to assert @param string[]|int[] $columnsPositions Columns positions in int or string (number must be in stri...
[ "Verifies", "if", "a", "row", "as", "the", "expected", "columns", "position", "of", "columns", "can", "be", "added", "for", "a", "more", "accurated", "assertion" ]
train
https://github.com/ezsystems/BehatBundle/blob/7d6d409545ec7cb69a3ab6636a59159df033695d/Context/Browser/Context.php#L267-L293
ezsystems/BehatBundle
Context/Browser/Context.php
Context.getTableRow
public function getTableRow( $text, $column = null, $tableXpath = null ) { // check column if ( !empty( $column ) ) { if ( is_integer( $column ) ) { $columnNumber = "[$column]"; } else { $columnNumber...
php
public function getTableRow( $text, $column = null, $tableXpath = null ) { // check column if ( !empty( $column ) ) { if ( is_integer( $column ) ) { $columnNumber = "[$column]"; } else { $columnNumber...
[ "public", "function", "getTableRow", "(", "$", "text", ",", "$", "column", "=", "null", ",", "$", "tableXpath", "=", "null", ")", "{", "// check column", "if", "(", "!", "empty", "(", "$", "column", ")", ")", "{", "if", "(", "is_integer", "(", "$", ...
Find a(all) table row(s) that match the column text @param string $text Text to be found @param string|int $column In which column the text should be found @param string $tableXpath If there is a specific table @return \Behat\Mink\Element\NodeElement[]
[ "Find", "a", "(", "all", ")", "table", "row", "(", "s", ")", "that", "match", "the", "column", "text" ]
train
https://github.com/ezsystems/BehatBundle/blob/7d6d409545ec7cb69a3ab6636a59159df033695d/Context/Browser/Context.php#L304-L343
ezsystems/BehatBundle
Context/Browser/Context.php
Context.findRow
public function findRow( NodeElement $element ) { $initialTag = $element->getTagName(); while ( strtolower( $element->getTagName() ) !== "tr" && strtolower( $element->getTagName() ) !== "body" ) { $element = $element->getParent(); } ...
php
public function findRow( NodeElement $element ) { $initialTag = $element->getTagName(); while ( strtolower( $element->getTagName() ) !== "tr" && strtolower( $element->getTagName() ) !== "body" ) { $element = $element->getParent(); } ...
[ "public", "function", "findRow", "(", "NodeElement", "$", "element", ")", "{", "$", "initialTag", "=", "$", "element", "->", "getTagName", "(", ")", ";", "while", "(", "strtolower", "(", "$", "element", "->", "getTagName", "(", ")", ")", "!==", "\"tr\"",...
Find and return the row (<tr>) where the passed element is This is useful when you intend to know if another element is in the same row @param \Behat\Mink\Element\NodeElement $element The element in the intended row @return \Behat\Mink\Element\NodeElement The <tr> element node @throws \PHPUnit_Framework_AssertionFai...
[ "Find", "and", "return", "the", "row", "(", "<tr", ">", ")", "where", "the", "passed", "element", "is", "This", "is", "useful", "when", "you", "intend", "to", "know", "if", "another", "element", "is", "in", "the", "same", "row" ]
train
https://github.com/ezsystems/BehatBundle/blob/7d6d409545ec7cb69a3ab6636a59159df033695d/Context/Browser/Context.php#L356-L375
ezsystems/BehatBundle
Context/Browser/Context.php
Context.findElementAfterElement
public function findElementAfterElement( array $elements, $firstXpath, $secondXpath ) { $foundFirstXpath = false; foreach ( $elements as $element ) { // choose what xpath to use if ( ! $foundFirstXpath ) { $xpath = $firstXpath; ...
php
public function findElementAfterElement( array $elements, $firstXpath, $secondXpath ) { $foundFirstXpath = false; foreach ( $elements as $element ) { // choose what xpath to use if ( ! $foundFirstXpath ) { $xpath = $firstXpath; ...
[ "public", "function", "findElementAfterElement", "(", "array", "$", "elements", ",", "$", "firstXpath", ",", "$", "secondXpath", ")", "{", "$", "foundFirstXpath", "=", "false", ";", "foreach", "(", "$", "elements", "as", "$", "element", ")", "{", "// choose ...
In a list of elements returns a certain element (found through xpath) that is after a specific element (that is also found through xpath) <code> findElementAfterElement( $arrayWithAllCellsOfARow, $xpathForALabel $xpathForAnInput ); </code> @param array $elements @param string $firstXpath @param string $secondXpath ...
[ "In", "a", "list", "of", "elements", "returns", "a", "certain", "element", "(", "found", "through", "xpath", ")", "that", "is", "after", "a", "specific", "element", "(", "that", "is", "also", "found", "through", "xpath", ")" ]
train
https://github.com/ezsystems/BehatBundle/blob/7d6d409545ec7cb69a3ab6636a59159df033695d/Context/Browser/Context.php#L395-L428
ezsystems/BehatBundle
Context/Browser/Context.php
Context.isElementEmphasized
public function isElementEmphasized( NodeElement $el, $characteristic = null, $attribute = "style" ) { // verify it has the attribute we're looking for if ( !$el->hasAttribute( $attribute ) ) { return false; } // get the attribute $attr = $el->getAttribut...
php
public function isElementEmphasized( NodeElement $el, $characteristic = null, $attribute = "style" ) { // verify it has the attribute we're looking for if ( !$el->hasAttribute( $attribute ) ) { return false; } // get the attribute $attr = $el->getAttribut...
[ "public", "function", "isElementEmphasized", "(", "NodeElement", "$", "el", ",", "$", "characteristic", "=", "null", ",", "$", "attribute", "=", "\"style\"", ")", "{", "// verify it has the attribute we're looking for", "if", "(", "!", "$", "el", "->", "hasAttribu...
Verifies if the element has 'special' configuration on a attribute (default -> style) @param \Behat\Mink\Element\NodeElement $el The element that we want to test @param string $characteristic Verify a specific characteristic from attribute @param string $attribute Verify a specific attribute @return boolean
[ "Verifies", "if", "the", "element", "has", "special", "configuration", "on", "a", "attribute", "(", "default", "-", ">", "style", ")" ]
train
https://github.com/ezsystems/BehatBundle/blob/7d6d409545ec7cb69a3ab6636a59159df033695d/Context/Browser/Context.php#L439-L458
ezsystems/BehatBundle
Context/Browser/Context.php
Context.makeXpathForBlock
public function makeXpathForBlock( $block = null ) { if ( empty( $block ) ) { return null; } $parameter = ( isset( $this->mainAttributes[strtolower( $block )] ) ) ? $this->mainAttributes[strtolower( $block )] : NULL; Assertion::assertNotN...
php
public function makeXpathForBlock( $block = null ) { if ( empty( $block ) ) { return null; } $parameter = ( isset( $this->mainAttributes[strtolower( $block )] ) ) ? $this->mainAttributes[strtolower( $block )] : NULL; Assertion::assertNotN...
[ "public", "function", "makeXpathForBlock", "(", "$", "block", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "block", ")", ")", "{", "return", "null", ";", "}", "$", "parameter", "=", "(", "isset", "(", "$", "this", "->", "mainAttributes", "[",...
This method works is a complement to the $mainAttributes var @param string $block This should be an identifier for the block to use @return null|string XPath for the @see $this->mainAttributes
[ "This", "method", "works", "is", "a", "complement", "to", "the", "$mainAttributes", "var" ]
train
https://github.com/ezsystems/BehatBundle/blob/7d6d409545ec7cb69a3ab6636a59159df033695d/Context/Browser/Context.php#L469-L536
ezsystems/BehatBundle
Context/Browser/SubContext/Authentication.php
Authentication.iAmLoggedInAsAn
public function iAmLoggedInAsAn( $role ) { trigger_error( "iAmLoggedInAsAn is deprecated since v6.3.0 and will be removed in v7.0.0", E_USER_DEPRECATED ); if ( $role == 'Anonymous' ) { $this->iAmNotLoggedIn(); } else { ...
php
public function iAmLoggedInAsAn( $role ) { trigger_error( "iAmLoggedInAsAn is deprecated since v6.3.0 and will be removed in v7.0.0", E_USER_DEPRECATED ); if ( $role == 'Anonymous' ) { $this->iAmNotLoggedIn(); } else { ...
[ "public", "function", "iAmLoggedInAsAn", "(", "$", "role", ")", "{", "trigger_error", "(", "\"iAmLoggedInAsAn is deprecated since v6.3.0 and will be removed in v7.0.0\"", ",", "E_USER_DEPRECATED", ")", ";", "if", "(", "$", "role", "==", "'Anonymous'", ")", "{", "$", "...
@Given I am logged (in) as a(n) :role @Given I have :role permissions Logs in a (new) user with the role identified by ':role' assigned. @deprecated deprecated since version 6.3.0
[ "@Given", "I", "am", "logged", "(", "in", ")", "as", "a", "(", "n", ")", ":", "role", "@Given", "I", "have", ":", "role", "permissions" ]
train
https://github.com/ezsystems/BehatBundle/blob/7d6d409545ec7cb69a3ab6636a59159df033695d/Context/Browser/SubContext/Authentication.php#L25-L41
ezsystems/BehatBundle
Context/Browser/SubContext/Authentication.php
Authentication.iAmLoggedInAsWithPassword
public function iAmLoggedInAsWithPassword( $user, $password ) { trigger_error( "iAmLoggedInAsWithPassword is deprecated since v6.3.0 and will be removed in v7.0.0", E_USER_DEPRECATED ); $this->iAmOnPage( 'login' ); $this->fillFieldWithValue( 'Username', $user...
php
public function iAmLoggedInAsWithPassword( $user, $password ) { trigger_error( "iAmLoggedInAsWithPassword is deprecated since v6.3.0 and will be removed in v7.0.0", E_USER_DEPRECATED ); $this->iAmOnPage( 'login' ); $this->fillFieldWithValue( 'Username', $user...
[ "public", "function", "iAmLoggedInAsWithPassword", "(", "$", "user", ",", "$", "password", ")", "{", "trigger_error", "(", "\"iAmLoggedInAsWithPassword is deprecated since v6.3.0 and will be removed in v7.0.0\"", ",", "E_USER_DEPRECATED", ")", ";", "$", "this", "->", "iAmOn...
@Given I am logged in as :user with password :password Performs the login action with username ':user' and password ':password'. Checks that the resulting page is the homepage. @deprecated deprecated since version 6.3.0
[ "@Given", "I", "am", "logged", "in", "as", ":", "user", "with", "password", ":", "password" ]
train
https://github.com/ezsystems/BehatBundle/blob/7d6d409545ec7cb69a3ab6636a59159df033695d/Context/Browser/SubContext/Authentication.php#L51-L63
ezsystems/BehatBundle
Helper/EzAssertion.php
EzAssertion.assertSingleElement
static function assertSingleElement( $search, $element, $pageSection = null, $type = 'element' ) { $section = ( $pageSection === null ) ? "" : " in '$pageSection' page section"; Assertion::assertNotEmpty( $element, "Couldn't find '$search' $type" . $section ); Assertion::assertEquals( ...
php
static function assertSingleElement( $search, $element, $pageSection = null, $type = 'element' ) { $section = ( $pageSection === null ) ? "" : " in '$pageSection' page section"; Assertion::assertNotEmpty( $element, "Couldn't find '$search' $type" . $section ); Assertion::assertEquals( ...
[ "static", "function", "assertSingleElement", "(", "$", "search", ",", "$", "element", ",", "$", "pageSection", "=", "null", ",", "$", "type", "=", "'element'", ")", "{", "$", "section", "=", "(", "$", "pageSection", "===", "null", ")", "?", "\"\"", ":"...
Assert that 1 page element was found @param string $search Search text @param mixed $element Elements found @param null|string $pageSection Page section @param null|string $type HTML element (ex: link, button, input, ...) @return void
[ "Assert", "that", "1", "page", "element", "was", "found" ]
train
https://github.com/ezsystems/BehatBundle/blob/7d6d409545ec7cb69a3ab6636a59159df033695d/Helper/EzAssertion.php#L29-L38
ezsystems/BehatBundle
Helper/EzAssertion.php
EzAssertion.assertElementFound
static function assertElementFound( $search, $element, $pageSection = null, $type = 'element' ) { $section = ( $pageSection === null ) ? "" : " in '$pageSection' page section"; Assertion::assertNotEmpty( $element, "Couldn't find '$search' $type" . $section ); }
php
static function assertElementFound( $search, $element, $pageSection = null, $type = 'element' ) { $section = ( $pageSection === null ) ? "" : " in '$pageSection' page section"; Assertion::assertNotEmpty( $element, "Couldn't find '$search' $type" . $section ); }
[ "static", "function", "assertElementFound", "(", "$", "search", ",", "$", "element", ",", "$", "pageSection", "=", "null", ",", "$", "type", "=", "'element'", ")", "{", "$", "section", "=", "(", "$", "pageSection", "===", "null", ")", "?", "\"\"", ":",...
Assert that at least 1 page element was found @param string $search Search text @param mixed $element Elements found @param null|string $pageSection Page section @param null|string $type HTML element (ex: link, button, input, ...) @return void
[ "Assert", "that", "at", "least", "1", "page", "element", "was", "found" ]
train
https://github.com/ezsystems/BehatBundle/blob/7d6d409545ec7cb69a3ab6636a59159df033695d/Helper/EzAssertion.php#L50-L54
ezsystems/BehatBundle
Helper/EzAssertion.php
EzAssertion.assertElementNotFound
static function assertElementNotFound( $search, $element, $pageSection = null, $type = 'element' ) { $section = ( $pageSection === null ) ? "" : " in '$pageSection' page section"; Assertion::assertEmpty( $element, "Found '$search' $type" . $section ); }
php
static function assertElementNotFound( $search, $element, $pageSection = null, $type = 'element' ) { $section = ( $pageSection === null ) ? "" : " in '$pageSection' page section"; Assertion::assertEmpty( $element, "Found '$search' $type" . $section ); }
[ "static", "function", "assertElementNotFound", "(", "$", "search", ",", "$", "element", ",", "$", "pageSection", "=", "null", ",", "$", "type", "=", "'element'", ")", "{", "$", "section", "=", "(", "$", "pageSection", "===", "null", ")", "?", "\"\"", "...
Assert that no page element was found @param string $search Search text @param mixed $element Elements found @param null|string $pageSection Page section @param null|string $type HTML element (ex: link, button, input, ...) @return void
[ "Assert", "that", "no", "page", "element", "was", "found" ]
train
https://github.com/ezsystems/BehatBundle/blob/7d6d409545ec7cb69a3ab6636a59159df033695d/Helper/EzAssertion.php#L66-L70
GaretJax/phpbrowscap
src/phpbrowscap/Browscap.php
Browscap.getBrowser
public function getBrowser($user_agent = null, $return_array = false) { // Load the cache at the first request if (!$this->_cacheLoaded) { $cache_file = $this->cacheDir . $this->cacheFilename; $ini_file = $this->cacheDir . $this->iniFilename; // Set the interval ...
php
public function getBrowser($user_agent = null, $return_array = false) { // Load the cache at the first request if (!$this->_cacheLoaded) { $cache_file = $this->cacheDir . $this->cacheFilename; $ini_file = $this->cacheDir . $this->iniFilename; // Set the interval ...
[ "public", "function", "getBrowser", "(", "$", "user_agent", "=", "null", ",", "$", "return_array", "=", "false", ")", "{", "// Load the cache at the first request", "if", "(", "!", "$", "this", "->", "_cacheLoaded", ")", "{", "$", "cache_file", "=", "$", "th...
XXX parse Gets the information about the browser by User Agent @param string $user_agent the user agent string @param bool $return_array whether return an array or an object @throws Exception @return stdClass|array the object containing the browsers details. Array if $return_array is set to true.
[ "XXX", "parse" ]
train
https://github.com/GaretJax/phpbrowscap/blob/ed661716d0d9158bac6ab3b074b18b70f8d18bef/src/phpbrowscap/Browscap.php#L262-L379
GaretJax/phpbrowscap
src/phpbrowscap/Browscap.php
Browscap.autodetectProxySettings
public function autodetectProxySettings() { $wrappers = array('http', 'https', 'ftp'); foreach ($wrappers as $wrapper) { $url = getenv($wrapper.'_proxy'); if (!empty($url)) { $params = array_merge(array( 'port' => null, ...
php
public function autodetectProxySettings() { $wrappers = array('http', 'https', 'ftp'); foreach ($wrappers as $wrapper) { $url = getenv($wrapper.'_proxy'); if (!empty($url)) { $params = array_merge(array( 'port' => null, ...
[ "public", "function", "autodetectProxySettings", "(", ")", "{", "$", "wrappers", "=", "array", "(", "'http'", ",", "'https'", ",", "'ftp'", ")", ";", "foreach", "(", "$", "wrappers", "as", "$", "wrapper", ")", "{", "$", "url", "=", "getenv", "(", "$", ...
Load (auto-set) proxy settings from environment variables.
[ "Load", "(", "auto", "-", "set", ")", "proxy", "settings", "from", "environment", "variables", "." ]
train
https://github.com/GaretJax/phpbrowscap/blob/ed661716d0d9158bac6ab3b074b18b70f8d18bef/src/phpbrowscap/Browscap.php#L384-L399
GaretJax/phpbrowscap
src/phpbrowscap/Browscap.php
Browscap.addProxySettings
public function addProxySettings($server, $port = 3128, $wrapper = 'http', $username = null, $password = null) { $settings = array($wrapper => array( 'proxy' => sprintf('tcp://%s:%d', $server, $port), 'request_fulluri' => true, )); // Proxy authenticati...
php
public function addProxySettings($server, $port = 3128, $wrapper = 'http', $username = null, $password = null) { $settings = array($wrapper => array( 'proxy' => sprintf('tcp://%s:%d', $server, $port), 'request_fulluri' => true, )); // Proxy authenticati...
[ "public", "function", "addProxySettings", "(", "$", "server", ",", "$", "port", "=", "3128", ",", "$", "wrapper", "=", "'http'", ",", "$", "username", "=", "null", ",", "$", "password", "=", "null", ")", "{", "$", "settings", "=", "array", "(", "$", ...
Add proxy settings to the stream context array. @param string $server Proxy server/host @param int $port Port @param string $wrapper Wrapper: "http", "https", "ftp", others... @param string $username Username (when requiring authentication) @param string $password Password (when requiring authentication...
[ "Add", "proxy", "settings", "to", "the", "stream", "context", "array", "." ]
train
https://github.com/GaretJax/phpbrowscap/blob/ed661716d0d9158bac6ab3b074b18b70f8d18bef/src/phpbrowscap/Browscap.php#L412-L437
GaretJax/phpbrowscap
src/phpbrowscap/Browscap.php
Browscap.clearProxySettings
public function clearProxySettings($wrapper = null) { $wrappers = isset($wrapper) ? array($wrapper) : array_keys($this->_streamContextOptions); $clearedWrappers = array(); $options = array('proxy', 'request_fulluri', 'header'); foreach ($wrappers as $wrapper) { // remov...
php
public function clearProxySettings($wrapper = null) { $wrappers = isset($wrapper) ? array($wrapper) : array_keys($this->_streamContextOptions); $clearedWrappers = array(); $options = array('proxy', 'request_fulluri', 'header'); foreach ($wrappers as $wrapper) { // remov...
[ "public", "function", "clearProxySettings", "(", "$", "wrapper", "=", "null", ")", "{", "$", "wrappers", "=", "isset", "(", "$", "wrapper", ")", "?", "array", "(", "$", "wrapper", ")", ":", "array_keys", "(", "$", "this", "->", "_streamContextOptions", "...
Clear proxy settings from the stream context options array. @param string $wrapper Remove settings from this wrapper only @return array Wrappers cleared
[ "Clear", "proxy", "settings", "from", "the", "stream", "context", "options", "array", "." ]
train
https://github.com/GaretJax/phpbrowscap/blob/ed661716d0d9158bac6ab3b074b18b70f8d18bef/src/phpbrowscap/Browscap.php#L446-L470
GaretJax/phpbrowscap
src/phpbrowscap/Browscap.php
Browscap.updateCache
public function updateCache() { $ini_path = $this->cacheDir . $this->iniFilename; $cache_path = $this->cacheDir . $this->cacheFilename; // Choose the right url if ($this->_getUpdateMethod() == self::UPDATE_LOCAL) { $url = $this->localFile; } else { $u...
php
public function updateCache() { $ini_path = $this->cacheDir . $this->iniFilename; $cache_path = $this->cacheDir . $this->cacheFilename; // Choose the right url if ($this->_getUpdateMethod() == self::UPDATE_LOCAL) { $url = $this->localFile; } else { $u...
[ "public", "function", "updateCache", "(", ")", "{", "$", "ini_path", "=", "$", "this", "->", "cacheDir", ".", "$", "this", "->", "iniFilename", ";", "$", "cache_path", "=", "$", "this", "->", "cacheDir", ".", "$", "this", "->", "cacheFilename", ";", "/...
XXX save Parses the ini file and updates the cache files @return bool whether the file was correctly written to the disk
[ "XXX", "save" ]
train
https://github.com/GaretJax/phpbrowscap/blob/ed661716d0d9158bac6ab3b074b18b70f8d18bef/src/phpbrowscap/Browscap.php#L489-L602
GaretJax/phpbrowscap
src/phpbrowscap/Browscap.php
Browscap.deduplicateCompressionPattern
protected function deduplicateCompressionPattern($matches, &$pattern) { $tmp_matches = $matches; $first_match = array_shift($tmp_matches); $differences = array(); foreach ($tmp_matches as $some_match) { $differences += array_diff_assoc($first_match, $some_m...
php
protected function deduplicateCompressionPattern($matches, &$pattern) { $tmp_matches = $matches; $first_match = array_shift($tmp_matches); $differences = array(); foreach ($tmp_matches as $some_match) { $differences += array_diff_assoc($first_match, $some_m...
[ "protected", "function", "deduplicateCompressionPattern", "(", "$", "matches", ",", "&", "$", "pattern", ")", "{", "$", "tmp_matches", "=", "$", "matches", ";", "$", "first_match", "=", "array_shift", "(", "$", "tmp_matches", ")", ";", "$", "differences", "=...
That looks complicated... All numbers are taken out into $matches, so we check if any of those numbers are identical in all the $matches and if they are we restore them to the $pattern, removing from the $matches. This gives us patterns with "(\d)" only in places that differ for some matches. @param array $matches @p...
[ "That", "looks", "complicated", "..." ]
train
https://github.com/GaretJax/phpbrowscap/blob/ed661716d0d9158bac6ab3b074b18b70f8d18bef/src/phpbrowscap/Browscap.php#L633-L666
GaretJax/phpbrowscap
src/phpbrowscap/Browscap.php
Browscap._pregQuote
protected function _pregQuote($user_agent) { $pattern = preg_quote($user_agent, self::REGEX_DELIMITER); // the \\x replacement is a fix for "Der gro\xdfe BilderSauger 2.00u" user agent match return self::REGEX_DELIMITER . '^' . str_replace(array('\*', '\?', '\\x')...
php
protected function _pregQuote($user_agent) { $pattern = preg_quote($user_agent, self::REGEX_DELIMITER); // the \\x replacement is a fix for "Der gro\xdfe BilderSauger 2.00u" user agent match return self::REGEX_DELIMITER . '^' . str_replace(array('\*', '\?', '\\x')...
[ "protected", "function", "_pregQuote", "(", "$", "user_agent", ")", "{", "$", "pattern", "=", "preg_quote", "(", "$", "user_agent", ",", "self", "::", "REGEX_DELIMITER", ")", ";", "// the \\\\x replacement is a fix for \"Der gro\\xdfe BilderSauger 2.00u\" user agent match",...
Converts browscap match patterns into preg match patterns. @param string $user_agent @return string
[ "Converts", "browscap", "match", "patterns", "into", "preg", "match", "patterns", "." ]
train
https://github.com/GaretJax/phpbrowscap/blob/ed661716d0d9158bac6ab3b074b18b70f8d18bef/src/phpbrowscap/Browscap.php#L675-L686
GaretJax/phpbrowscap
src/phpbrowscap/Browscap.php
Browscap._pregUnQuote
protected function _pregUnQuote($pattern, $matches) { // list of escaped characters: http://www.php.net/manual/en/function.preg-quote.php // to properly unescape '?' which was changed to '.', I replace '\.' (real dot) with '\?', then change '.' to '?' and then '\?' to '.'. $search = array('\\' . s...
php
protected function _pregUnQuote($pattern, $matches) { // list of escaped characters: http://www.php.net/manual/en/function.preg-quote.php // to properly unescape '?' which was changed to '.', I replace '\.' (real dot) with '\?', then change '.' to '?' and then '\?' to '.'. $search = array('\\' . s...
[ "protected", "function", "_pregUnQuote", "(", "$", "pattern", ",", "$", "matches", ")", "{", "// list of escaped characters: http://www.php.net/manual/en/function.preg-quote.php", "// to properly unescape '?' which was changed to '.', I replace '\\.' (real dot) with '\\?', then change '.' to...
Converts preg match patterns back to browscap match patterns. @param string $pattern @param array $matches @return string
[ "Converts", "preg", "match", "patterns", "back", "to", "browscap", "match", "patterns", "." ]
train
https://github.com/GaretJax/phpbrowscap/blob/ed661716d0d9158bac6ab3b074b18b70f8d18bef/src/phpbrowscap/Browscap.php#L696-L715
GaretJax/phpbrowscap
src/phpbrowscap/Browscap.php
Browscap._loadCache
protected function _loadCache($cache_file) { require $cache_file; if (!isset($cache_version) || $cache_version != self::CACHE_FILE_VERSION) { return false; } $this->_source_version = $source_version; $this->_browsers = $browsers; $t...
php
protected function _loadCache($cache_file) { require $cache_file; if (!isset($cache_version) || $cache_version != self::CACHE_FILE_VERSION) { return false; } $this->_source_version = $source_version; $this->_browsers = $browsers; $t...
[ "protected", "function", "_loadCache", "(", "$", "cache_file", ")", "{", "require", "$", "cache_file", ";", "if", "(", "!", "isset", "(", "$", "cache_version", ")", "||", "$", "cache_version", "!=", "self", "::", "CACHE_FILE_VERSION", ")", "{", "return", "...
Loads the cache into object's properties @param $cache_file @return boolean
[ "Loads", "the", "cache", "into", "object", "s", "properties" ]
train
https://github.com/GaretJax/phpbrowscap/blob/ed661716d0d9158bac6ab3b074b18b70f8d18bef/src/phpbrowscap/Browscap.php#L724-L742
GaretJax/phpbrowscap
src/phpbrowscap/Browscap.php
Browscap._buildCache
protected function _buildCache() { $cacheTpl = "<?php\n\$source_version=%s;\n\$cache_version=%s;\n\$properties=%s;\n\$browsers=%s;\n\$userAgents=%s;\n\$patterns=%s;\n"; $propertiesArray = $this->_array2string($this->_properties); $patternsArray = $this->_array2string($this->_patterns); ...
php
protected function _buildCache() { $cacheTpl = "<?php\n\$source_version=%s;\n\$cache_version=%s;\n\$properties=%s;\n\$browsers=%s;\n\$userAgents=%s;\n\$patterns=%s;\n"; $propertiesArray = $this->_array2string($this->_properties); $patternsArray = $this->_array2string($this->_patterns); ...
[ "protected", "function", "_buildCache", "(", ")", "{", "$", "cacheTpl", "=", "\"<?php\\n\\$source_version=%s;\\n\\$cache_version=%s;\\n\\$properties=%s;\\n\\$browsers=%s;\\n\\$userAgents=%s;\\n\\$patterns=%s;\\n\"", ";", "$", "propertiesArray", "=", "$", "this", "->", "_array2strin...
Parses the array to cache and creates the PHP string to write to disk @return string the PHP string to save into the cache file
[ "Parses", "the", "array", "to", "cache", "and", "creates", "the", "PHP", "string", "to", "write", "to", "disk" ]
train
https://github.com/GaretJax/phpbrowscap/blob/ed661716d0d9158bac6ab3b074b18b70f8d18bef/src/phpbrowscap/Browscap.php#L749-L767
GaretJax/phpbrowscap
src/phpbrowscap/Browscap.php
Browscap._getStreamContext
protected function _getStreamContext($recreate = false) { if (!isset($this->_streamContext) || true === $recreate) { $this->_streamContext = stream_context_create($this->_streamContextOptions); } return $this->_streamContext; }
php
protected function _getStreamContext($recreate = false) { if (!isset($this->_streamContext) || true === $recreate) { $this->_streamContext = stream_context_create($this->_streamContextOptions); } return $this->_streamContext; }
[ "protected", "function", "_getStreamContext", "(", "$", "recreate", "=", "false", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_streamContext", ")", "||", "true", "===", "$", "recreate", ")", "{", "$", "this", "->", "_streamContext", "=", ...
Lazy getter for the stream context resource. @param bool $recreate @return resource
[ "Lazy", "getter", "for", "the", "stream", "context", "resource", "." ]
train
https://github.com/GaretJax/phpbrowscap/blob/ed661716d0d9158bac6ab3b074b18b70f8d18bef/src/phpbrowscap/Browscap.php#L776-L783
GaretJax/phpbrowscap
src/phpbrowscap/Browscap.php
Browscap._getRemoteIniFile
protected function _getRemoteIniFile($url, $path) { // Check version if (file_exists($path) && filesize($path)) { $local_tmstp = filemtime($path); if ($this->_getUpdateMethod() == self::UPDATE_LOCAL) { $remote_tmstp = $this->_getLocalMTime(); } el...
php
protected function _getRemoteIniFile($url, $path) { // Check version if (file_exists($path) && filesize($path)) { $local_tmstp = filemtime($path); if ($this->_getUpdateMethod() == self::UPDATE_LOCAL) { $remote_tmstp = $this->_getLocalMTime(); } el...
[ "protected", "function", "_getRemoteIniFile", "(", "$", "url", ",", "$", "path", ")", "{", "// Check version", "if", "(", "file_exists", "(", "$", "path", ")", "&&", "filesize", "(", "$", "path", ")", ")", "{", "$", "local_tmstp", "=", "filemtime", "(", ...
Updates the local copy of the ini file (by version checking) and adapts his syntax to the PHP ini parser @param string $url the url of the remote server @param string $path the path of the ini file to update @throws Exception @return bool if the ini file was updated
[ "Updates", "the", "local", "copy", "of", "the", "ini", "file", "(", "by", "version", "checking", ")", "and", "adapts", "his", "syntax", "to", "the", "PHP", "ini", "parser" ]
train
https://github.com/GaretJax/phpbrowscap/blob/ed661716d0d9158bac6ab3b074b18b70f8d18bef/src/phpbrowscap/Browscap.php#L794-L841
GaretJax/phpbrowscap
src/phpbrowscap/Browscap.php
Browscap._getRemoteMTime
protected function _getRemoteMTime() { $remote_datetime = $this->_getRemoteData($this->remoteVerUrl); $remote_tmstp = strtotime($remote_datetime); if (!$remote_tmstp) { throw new Exception("Bad datetime format from {$this->remoteVerUrl}"); } return $remote_tmstp...
php
protected function _getRemoteMTime() { $remote_datetime = $this->_getRemoteData($this->remoteVerUrl); $remote_tmstp = strtotime($remote_datetime); if (!$remote_tmstp) { throw new Exception("Bad datetime format from {$this->remoteVerUrl}"); } return $remote_tmstp...
[ "protected", "function", "_getRemoteMTime", "(", ")", "{", "$", "remote_datetime", "=", "$", "this", "->", "_getRemoteData", "(", "$", "this", "->", "remoteVerUrl", ")", ";", "$", "remote_tmstp", "=", "strtotime", "(", "$", "remote_datetime", ")", ";", "if",...
Gets the remote ini file update timestamp @throws Exception @return int the remote modification timestamp
[ "Gets", "the", "remote", "ini", "file", "update", "timestamp" ]
train
https://github.com/GaretJax/phpbrowscap/blob/ed661716d0d9158bac6ab3b074b18b70f8d18bef/src/phpbrowscap/Browscap.php#L849-L859
GaretJax/phpbrowscap
src/phpbrowscap/Browscap.php
Browscap._getLocalMTime
protected function _getLocalMTime() { if (!is_readable($this->localFile) || !is_file($this->localFile)) { throw new Exception("Local file is not readable"); } return filemtime($this->localFile); }
php
protected function _getLocalMTime() { if (!is_readable($this->localFile) || !is_file($this->localFile)) { throw new Exception("Local file is not readable"); } return filemtime($this->localFile); }
[ "protected", "function", "_getLocalMTime", "(", ")", "{", "if", "(", "!", "is_readable", "(", "$", "this", "->", "localFile", ")", "||", "!", "is_file", "(", "$", "this", "->", "localFile", ")", ")", "{", "throw", "new", "Exception", "(", "\"Local file i...
Gets the local ini file update timestamp @throws Exception @return int the local modification timestamp
[ "Gets", "the", "local", "ini", "file", "update", "timestamp" ]
train
https://github.com/GaretJax/phpbrowscap/blob/ed661716d0d9158bac6ab3b074b18b70f8d18bef/src/phpbrowscap/Browscap.php#L867-L874
GaretJax/phpbrowscap
src/phpbrowscap/Browscap.php
Browscap._array2string
protected function _array2string($array) { $strings = array(); foreach ($array as $key => $value) { if (is_int($key)) { $key = ''; } elseif (ctype_digit((string) $key) || '.0' === substr($key, -2)) { $key = intval($key) . '=>' ; } ...
php
protected function _array2string($array) { $strings = array(); foreach ($array as $key => $value) { if (is_int($key)) { $key = ''; } elseif (ctype_digit((string) $key) || '.0' === substr($key, -2)) { $key = intval($key) . '=>' ; } ...
[ "protected", "function", "_array2string", "(", "$", "array", ")", "{", "$", "strings", "=", "array", "(", ")", ";", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_int", "(", "$", "key", ")", ")", "{",...
Converts the given array to the PHP string which represent it. This method optimizes the PHP code and the output differs form the var_export one as the internal PHP function does not strip whitespace or convert strings to numbers. @param array $array the array to parse and convert @return string the array parsed into ...
[ "Converts", "the", "given", "array", "to", "the", "PHP", "string", "which", "represent", "it", ".", "This", "method", "optimizes", "the", "PHP", "code", "and", "the", "output", "differs", "form", "the", "var_export", "one", "as", "the", "internal", "PHP", ...
train
https://github.com/GaretJax/phpbrowscap/blob/ed661716d0d9158bac6ab3b074b18b70f8d18bef/src/phpbrowscap/Browscap.php#L885-L910
GaretJax/phpbrowscap
src/phpbrowscap/Browscap.php
Browscap._getUpdateMethod
protected function _getUpdateMethod() { // Caches the result if ($this->updateMethod === null) { if ($this->localFile !== null) { $this->updateMethod = self::UPDATE_LOCAL; } elseif (ini_get('allow_url_fopen') && function_exists('file_get_contents')) { ...
php
protected function _getUpdateMethod() { // Caches the result if ($this->updateMethod === null) { if ($this->localFile !== null) { $this->updateMethod = self::UPDATE_LOCAL; } elseif (ini_get('allow_url_fopen') && function_exists('file_get_contents')) { ...
[ "protected", "function", "_getUpdateMethod", "(", ")", "{", "// Caches the result", "if", "(", "$", "this", "->", "updateMethod", "===", "null", ")", "{", "if", "(", "$", "this", "->", "localFile", "!==", "null", ")", "{", "$", "this", "->", "updateMethod"...
Checks for the various possibilities offered by the current configuration of PHP to retrieve external HTTP data @return string the name of function to use to retrieve the file
[ "Checks", "for", "the", "various", "possibilities", "offered", "by", "the", "current", "configuration", "of", "PHP", "to", "retrieve", "external", "HTTP", "data" ]
train
https://github.com/GaretJax/phpbrowscap/blob/ed661716d0d9158bac6ab3b074b18b70f8d18bef/src/phpbrowscap/Browscap.php#L918-L936
GaretJax/phpbrowscap
src/phpbrowscap/Browscap.php
Browscap._getRemoteData
protected function _getRemoteData($url) { ini_set('user_agent', $this->_getUserAgent()); switch ($this->_getUpdateMethod()) { case self::UPDATE_LOCAL: $file = file_get_contents($url); if ($file !== false) { return $file; ...
php
protected function _getRemoteData($url) { ini_set('user_agent', $this->_getUserAgent()); switch ($this->_getUpdateMethod()) { case self::UPDATE_LOCAL: $file = file_get_contents($url); if ($file !== false) { return $file; ...
[ "protected", "function", "_getRemoteData", "(", "$", "url", ")", "{", "ini_set", "(", "'user_agent'", ",", "$", "this", "->", "_getUserAgent", "(", ")", ")", ";", "switch", "(", "$", "this", "->", "_getUpdateMethod", "(", ")", ")", "{", "case", "self", ...
Retrieve the data identified by the URL @param string $url the url of the data @throws Exception @return string the retrieved data
[ "Retrieve", "the", "data", "identified", "by", "the", "URL" ]
train
https://github.com/GaretJax/phpbrowscap/blob/ed661716d0d9158bac6ab3b074b18b70f8d18bef/src/phpbrowscap/Browscap.php#L945-L1023
GaretJax/phpbrowscap
src/phpbrowscap/Browscap.php
Browscap._getUserAgent
protected function _getUserAgent() { $ua = str_replace('%v', self::VERSION, $this->userAgent); $ua = str_replace('%m', $this->_getUpdateMethod(), $ua); return $ua; }
php
protected function _getUserAgent() { $ua = str_replace('%v', self::VERSION, $this->userAgent); $ua = str_replace('%m', $this->_getUpdateMethod(), $ua); return $ua; }
[ "protected", "function", "_getUserAgent", "(", ")", "{", "$", "ua", "=", "str_replace", "(", "'%v'", ",", "self", "::", "VERSION", ",", "$", "this", "->", "userAgent", ")", ";", "$", "ua", "=", "str_replace", "(", "'%m'", ",", "$", "this", "->", "_ge...
Format the useragent string to be used in the remote requests made by the class during the update process. @return string the formatted user agent
[ "Format", "the", "useragent", "string", "to", "be", "used", "in", "the", "remote", "requests", "made", "by", "the", "class", "during", "the", "update", "process", "." ]
train
https://github.com/GaretJax/phpbrowscap/blob/ed661716d0d9158bac6ab3b074b18b70f8d18bef/src/phpbrowscap/Browscap.php#L1031-L1037
varspool/Wrench
lib/Socket/UriSocket.php
UriSocket.getStreamContext
protected function getStreamContext($listen = false) { $options = []; if ($this->scheme == Protocol::SCHEME_UNDERLYING_SECURE || $this->scheme == Protocol::SCHEME_UNDERLYING ) { $options['socket'] = $this->getSocketStreamContextOptions(); } if ($this...
php
protected function getStreamContext($listen = false) { $options = []; if ($this->scheme == Protocol::SCHEME_UNDERLYING_SECURE || $this->scheme == Protocol::SCHEME_UNDERLYING ) { $options['socket'] = $this->getSocketStreamContextOptions(); } if ($this...
[ "protected", "function", "getStreamContext", "(", "$", "listen", "=", "false", ")", "{", "$", "options", "=", "[", "]", ";", "if", "(", "$", "this", "->", "scheme", "==", "Protocol", "::", "SCHEME_UNDERLYING_SECURE", "||", "$", "this", "->", "scheme", "=...
Gets a stream context @return resource
[ "Gets", "a", "stream", "context" ]
train
https://github.com/varspool/Wrench/blob/2c297b5d655efaed22acbd0486d219f11b698b3c/lib/Socket/UriSocket.php#L79-L97
varspool/Wrench
lib/Connection.php
Connection.handlePayload
public function handlePayload(Payload $payload): void { $app = $this->getClientApplication(); $this->logger->debug('Handling payload: ' . $payload->getPayload()); switch ($type = $payload->getType()) { case Protocol::TYPE_TEXT: if (method_exists($app, 'onData'))...
php
public function handlePayload(Payload $payload): void { $app = $this->getClientApplication(); $this->logger->debug('Handling payload: ' . $payload->getPayload()); switch ($type = $payload->getType()) { case Protocol::TYPE_TEXT: if (method_exists($app, 'onData'))...
[ "public", "function", "handlePayload", "(", "Payload", "$", "payload", ")", ":", "void", "{", "$", "app", "=", "$", "this", "->", "getClientApplication", "(", ")", ";", "$", "this", "->", "logger", "->", "debug", "(", "'Handling payload: '", ".", "$", "p...
Handle a complete payload received from the client Public because called from our PayloadHandler @param Payload $payload @throws ConnectionException
[ "Handle", "a", "complete", "payload", "received", "from", "the", "client" ]
train
https://github.com/varspool/Wrench/blob/2c297b5d655efaed22acbd0486d219f11b698b3c/lib/Connection.php#L177-L222
varspool/Wrench
lib/Connection.php
Connection.close
public function close(int $code = Protocol::CLOSE_NORMAL, string $reason = null): bool { try { if (!$this->handshaked) { $response = $this->protocol->getResponseError($code); $this->socket->send($response); } else { $response = $this->p...
php
public function close(int $code = Protocol::CLOSE_NORMAL, string $reason = null): bool { try { if (!$this->handshaked) { $response = $this->protocol->getResponseError($code); $this->socket->send($response); } else { $response = $this->p...
[ "public", "function", "close", "(", "int", "$", "code", "=", "Protocol", "::", "CLOSE_NORMAL", ",", "string", "$", "reason", "=", "null", ")", ":", "bool", "{", "try", "{", "if", "(", "!", "$", "this", "->", "handshaked", ")", "{", "$", "response", ...
Closes the connection according to the WebSocket protocol If an endpoint receives a Close frame and that endpoint did not previously send a Close frame, the endpoint MUST send a Close frame in response. It SHOULD do so as soon as is practical. An endpoint MAY delay sending a close frame until its current message is ...
[ "Closes", "the", "connection", "according", "to", "the", "WebSocket", "protocol" ]
train
https://github.com/varspool/Wrench/blob/2c297b5d655efaed22acbd0486d219f11b698b3c/lib/Connection.php#L257-L279
varspool/Wrench
lib/Connection.php
Connection.send
public function send(string $data, int $type = Protocol::TYPE_TEXT): bool { if (!$this->handshaked) { throw new HandshakeException('Connection is not handshaked'); } $payload = $this->protocol->getPayload(); if (!is_scalar($data) && !$data instanceof Payload) { ...
php
public function send(string $data, int $type = Protocol::TYPE_TEXT): bool { if (!$this->handshaked) { throw new HandshakeException('Connection is not handshaked'); } $payload = $this->protocol->getPayload(); if (!is_scalar($data) && !$data instanceof Payload) { ...
[ "public", "function", "send", "(", "string", "$", "data", ",", "int", "$", "type", "=", "Protocol", "::", "TYPE_TEXT", ")", ":", "bool", "{", "if", "(", "!", "$", "this", "->", "handshaked", ")", "{", "throw", "new", "HandshakeException", "(", "'Connec...
Sends the payload to the connection @param string|Payload|mixed $data @param int $type @return bool
[ "Sends", "the", "payload", "to", "the", "connection" ]
train
https://github.com/varspool/Wrench/blob/2c297b5d655efaed22acbd0486d219f11b698b3c/lib/Connection.php#L288-L308
varspool/Wrench
lib/Connection.php
Connection.process
public function process() { $data = $this->socket->receive(); $bytes = strlen($data); if ($bytes === 0 || $data === false) { throw new CloseException('Error reading data from socket: ' . $this->socket->getLastError()); } $this->onData($data); }
php
public function process() { $data = $this->socket->receive(); $bytes = strlen($data); if ($bytes === 0 || $data === false) { throw new CloseException('Error reading data from socket: ' . $this->socket->getLastError()); } $this->onData($data); }
[ "public", "function", "process", "(", ")", "{", "$", "data", "=", "$", "this", "->", "socket", "->", "receive", "(", ")", ";", "$", "bytes", "=", "strlen", "(", "$", "data", ")", ";", "if", "(", "$", "bytes", "===", "0", "||", "$", "data", "===...
Processes data on the socket @throws CloseException
[ "Processes", "data", "on", "the", "socket" ]
train
https://github.com/varspool/Wrench/blob/2c297b5d655efaed22acbd0486d219f11b698b3c/lib/Connection.php#L315-L325
varspool/Wrench
lib/Connection.php
Connection.onData
public function onData($data) { if (!$this->handshaked) { return $this->handshake($data); } return $this->handle($data); }
php
public function onData($data) { if (!$this->handshaked) { return $this->handshake($data); } return $this->handle($data); }
[ "public", "function", "onData", "(", "$", "data", ")", "{", "if", "(", "!", "$", "this", "->", "handshaked", ")", "{", "return", "$", "this", "->", "handshake", "(", "$", "data", ")", ";", "}", "return", "$", "this", "->", "handle", "(", "$", "da...
Data receiver Called by the connection manager when the connection has received data @param string $data
[ "Data", "receiver" ]
train
https://github.com/varspool/Wrench/blob/2c297b5d655efaed22acbd0486d219f11b698b3c/lib/Connection.php#L334-L340
varspool/Wrench
lib/Connection.php
Connection.handshake
public function handshake($data) { try { list($path, $origin, $key, $extensions, $protocol, $headers, $params) = $this->protocol->validateRequestHandshake($data); $this->headers = $headers; $this->queryParams = $params; $this->application = $...
php
public function handshake($data) { try { list($path, $origin, $key, $extensions, $protocol, $headers, $params) = $this->protocol->validateRequestHandshake($data); $this->headers = $headers; $this->queryParams = $params; $this->application = $...
[ "public", "function", "handshake", "(", "$", "data", ")", "{", "try", "{", "list", "(", "$", "path", ",", "$", "origin", ",", "$", "key", ",", "$", "extensions", ",", "$", "protocol", ",", "$", "headers", ",", "$", "params", ")", "=", "$", "this"...
Performs a websocket handshake @param string $data @throws BadRequestException @throws HandshakeException @throws WrenchException
[ "Performs", "a", "websocket", "handshake" ]
train
https://github.com/varspool/Wrench/blob/2c297b5d655efaed22acbd0486d219f11b698b3c/lib/Connection.php#L350-L404
varspool/Wrench
lib/Connection.php
Connection.export
protected function export($data): string { $export = ''; foreach (str_split($data) as $chr) { $export .= '\\x' . ord($chr); } }
php
protected function export($data): string { $export = ''; foreach (str_split($data) as $chr) { $export .= '\\x' . ord($chr); } }
[ "protected", "function", "export", "(", "$", "data", ")", ":", "string", "{", "$", "export", "=", "''", ";", "foreach", "(", "str_split", "(", "$", "data", ")", "as", "$", "chr", ")", "{", "$", "export", ".=", "'\\\\x'", ".", "ord", "(", "$", "ch...
Returns a string export of the given binary data @param string $data @return string
[ "Returns", "a", "string", "export", "of", "the", "given", "binary", "data" ]
train
https://github.com/varspool/Wrench/blob/2c297b5d655efaed22acbd0486d219f11b698b3c/lib/Connection.php#L502-L508
varspool/Wrench
lib/Listener/OriginPolicy.php
OriginPolicy.onHandshakeRequest
public function onHandshakeRequest( Connection $connection, string $path, string $origin, string $key, array $extensions ): void { if (!$this->isAllowed($origin)) { $connection->close(Protocol::CLOSE_NORMAL, 'Not allowed origin during handshake request'); ...
php
public function onHandshakeRequest( Connection $connection, string $path, string $origin, string $key, array $extensions ): void { if (!$this->isAllowed($origin)) { $connection->close(Protocol::CLOSE_NORMAL, 'Not allowed origin during handshake request'); ...
[ "public", "function", "onHandshakeRequest", "(", "Connection", "$", "connection", ",", "string", "$", "path", ",", "string", "$", "origin", ",", "string", "$", "key", ",", "array", "$", "extensions", ")", ":", "void", "{", "if", "(", "!", "$", "this", ...
Handshake request listener Closes the connection on handshake from an origin that isn't allowed @param Connection $connection @param string $path @param string $origin @param string $key @param array $extensions
[ "Handshake", "request", "listener", "Closes", "the", "connection", "on", "handshake", "from", "an", "origin", "that", "isn", "t", "allowed" ]
train
https://github.com/varspool/Wrench/blob/2c297b5d655efaed22acbd0486d219f11b698b3c/lib/Listener/OriginPolicy.php#L29-L39
varspool/Wrench
lib/Listener/OriginPolicy.php
OriginPolicy.isAllowed
public function isAllowed(string $origin): bool { $scheme = parse_url($origin, PHP_URL_SCHEME); $host = parse_url($origin, PHP_URL_HOST) ?: $origin; foreach ($this->allowed as $allowed) { $allowed_scheme = parse_url($allowed, PHP_URL_SCHEME); if ($allowed_scheme && ...
php
public function isAllowed(string $origin): bool { $scheme = parse_url($origin, PHP_URL_SCHEME); $host = parse_url($origin, PHP_URL_HOST) ?: $origin; foreach ($this->allowed as $allowed) { $allowed_scheme = parse_url($allowed, PHP_URL_SCHEME); if ($allowed_scheme && ...
[ "public", "function", "isAllowed", "(", "string", "$", "origin", ")", ":", "bool", "{", "$", "scheme", "=", "parse_url", "(", "$", "origin", ",", "PHP_URL_SCHEME", ")", ";", "$", "host", "=", "parse_url", "(", "$", "origin", ",", "PHP_URL_HOST", ")", "...
Whether the specified origin is allowed under this policy @param string $origin @return bool
[ "Whether", "the", "specified", "origin", "is", "allowed", "under", "this", "policy" ]
train
https://github.com/varspool/Wrench/blob/2c297b5d655efaed22acbd0486d219f11b698b3c/lib/Listener/OriginPolicy.php#L47-L69
varspool/Wrench
lib/Payload/Payload.php
Payload.encode
public function encode(string $data, int $type = Protocol::TYPE_TEXT, bool $masked = false) { $this->frames = []; $frame = $this->getFrame(); array_push($this->frames, $frame); $frame->encode($data, $type, $masked); return $this; }
php
public function encode(string $data, int $type = Protocol::TYPE_TEXT, bool $masked = false) { $this->frames = []; $frame = $this->getFrame(); array_push($this->frames, $frame); $frame->encode($data, $type, $masked); return $this; }
[ "public", "function", "encode", "(", "string", "$", "data", ",", "int", "$", "type", "=", "Protocol", "::", "TYPE_TEXT", ",", "bool", "$", "masked", "=", "false", ")", "{", "$", "this", "->", "frames", "=", "[", "]", ";", "$", "frame", "=", "$", ...
Encodes a payload @param string $data @param int $type @param boolean $masked @return Payload @todo No splitting into multiple frames just yet
[ "Encodes", "a", "payload" ]
train
https://github.com/varspool/Wrench/blob/2c297b5d655efaed22acbd0486d219f11b698b3c/lib/Payload/Payload.php#L42-L52
varspool/Wrench
lib/Payload/Payload.php
Payload.getRemainingData
public function getRemainingData(): ?int { if ($this->isComplete()) { return 0; } try { if ($this->getCurrentFrame()->isFinal()) { return $this->getCurrentFrame()->getRemainingData(); } } catch (FrameException $e) { ret...
php
public function getRemainingData(): ?int { if ($this->isComplete()) { return 0; } try { if ($this->getCurrentFrame()->isFinal()) { return $this->getCurrentFrame()->getRemainingData(); } } catch (FrameException $e) { ret...
[ "public", "function", "getRemainingData", "(", ")", ":", "?", "int", "{", "if", "(", "$", "this", "->", "isComplete", "(", ")", ")", "{", "return", "0", ";", "}", "try", "{", "if", "(", "$", "this", "->", "getCurrentFrame", "(", ")", "->", "isFinal...
Gets the number of remaining bytes before this payload will be complete May return 0 (no more bytes required) or null (unknown number of bytes required). @return int|null
[ "Gets", "the", "number", "of", "remaining", "bytes", "before", "this", "payload", "will", "be", "complete", "May", "return", "0", "(", "no", "more", "bytes", "required", ")", "or", "null", "(", "unknown", "number", "of", "bytes", "required", ")", "." ]
train
https://github.com/varspool/Wrench/blob/2c297b5d655efaed22acbd0486d219f11b698b3c/lib/Payload/Payload.php#L79-L94
varspool/Wrench
lib/Payload/Payload.php
Payload.getCurrentFrame
protected function getCurrentFrame() { if (empty($this->frames)) { array_push($this->frames, $this->getFrame()); } return end($this->frames); }
php
protected function getCurrentFrame() { if (empty($this->frames)) { array_push($this->frames, $this->getFrame()); } return end($this->frames); }
[ "protected", "function", "getCurrentFrame", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "frames", ")", ")", "{", "array_push", "(", "$", "this", "->", "frames", ",", "$", "this", "->", "getFrame", "(", ")", ")", ";", "}", "return", "...
Gets the current frame for the payload @return mixed
[ "Gets", "the", "current", "frame", "for", "the", "payload" ]
train
https://github.com/varspool/Wrench/blob/2c297b5d655efaed22acbd0486d219f11b698b3c/lib/Payload/Payload.php#L111-L117
varspool/Wrench
lib/Payload/Payload.php
Payload.receiveData
public function receiveData(string $data): void { $chunkSize = null; while ($data) { $frame = $this->getReceivingFrame(); $remaining = $frame->getRemainingData(); if ($remaining === null) { $chunkSize = 2; } elseif ($remaining > 0) {...
php
public function receiveData(string $data): void { $chunkSize = null; while ($data) { $frame = $this->getReceivingFrame(); $remaining = $frame->getRemainingData(); if ($remaining === null) { $chunkSize = 2; } elseif ($remaining > 0) {...
[ "public", "function", "receiveData", "(", "string", "$", "data", ")", ":", "void", "{", "$", "chunkSize", "=", "null", ";", "while", "(", "$", "data", ")", "{", "$", "frame", "=", "$", "this", "->", "getReceivingFrame", "(", ")", ";", "$", "remaining...
Receive raw data into the payload @param string $data @return void @throws PayloadException
[ "Receive", "raw", "data", "into", "the", "payload" ]
train
https://github.com/varspool/Wrench/blob/2c297b5d655efaed22acbd0486d219f11b698b3c/lib/Payload/Payload.php#L145-L166
varspool/Wrench
lib/Payload/Payload.php
Payload.getReceivingFrame
protected function getReceivingFrame(): Frame { $current = $this->getCurrentFrame(); if ($current->isComplete()) { if ($current->isFinal()) { throw new PayloadException('Payload cannot receive data: it is already complete'); } else { $this->fr...
php
protected function getReceivingFrame(): Frame { $current = $this->getCurrentFrame(); if ($current->isComplete()) { if ($current->isFinal()) { throw new PayloadException('Payload cannot receive data: it is already complete'); } else { $this->fr...
[ "protected", "function", "getReceivingFrame", "(", ")", ":", "Frame", "{", "$", "current", "=", "$", "this", "->", "getCurrentFrame", "(", ")", ";", "if", "(", "$", "current", "->", "isComplete", "(", ")", ")", "{", "if", "(", "$", "current", "->", "...
Gets the frame into which data should be receieved @throws PayloadException @return Frame
[ "Gets", "the", "frame", "into", "which", "data", "should", "be", "receieved" ]
train
https://github.com/varspool/Wrench/blob/2c297b5d655efaed22acbd0486d219f11b698b3c/lib/Payload/Payload.php#L174-L187
varspool/Wrench
lib/Socket/Socket.php
Socket.getIp
public function getIp(): string { $name = $this->getName(); if ($name) { return self::getNamePart($name, self::NAME_PART_IP); } else { throw new SocketException('Cannot get socket IP address'); } }
php
public function getIp(): string { $name = $this->getName(); if ($name) { return self::getNamePart($name, self::NAME_PART_IP); } else { throw new SocketException('Cannot get socket IP address'); } }
[ "public", "function", "getIp", "(", ")", ":", "string", "{", "$", "name", "=", "$", "this", "->", "getName", "(", ")", ";", "if", "(", "$", "name", ")", "{", "return", "self", "::", "getNamePart", "(", "$", "name", ",", "self", "::", "NAME_PART_IP"...
Gets the IP address of the socket @throws \Wrench\Exception\SocketException If the IP address cannot be obtained @return string
[ "Gets", "the", "IP", "address", "of", "the", "socket" ]
train
https://github.com/varspool/Wrench/blob/2c297b5d655efaed22acbd0486d219f11b698b3c/lib/Socket/Socket.php#L74-L83
varspool/Wrench
lib/Socket/Socket.php
Socket.getName
protected function getName(): string { if (!isset($this->name) || !$this->name) { $this->name = @stream_socket_get_name($this->socket, true); } return $this->name; }
php
protected function getName(): string { if (!isset($this->name) || !$this->name) { $this->name = @stream_socket_get_name($this->socket, true); } return $this->name; }
[ "protected", "function", "getName", "(", ")", ":", "string", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "name", ")", "||", "!", "$", "this", "->", "name", ")", "{", "$", "this", "->", "name", "=", "@", "stream_socket_get_name", "(", "$",...
Gets the name of the socket @return string
[ "Gets", "the", "name", "of", "the", "socket" ]
train
https://github.com/varspool/Wrench/blob/2c297b5d655efaed22acbd0486d219f11b698b3c/lib/Socket/Socket.php#L90-L96
varspool/Wrench
lib/Socket/Socket.php
Socket.getNamePart
public static function getNamePart(string $name, int $part): string { if (!$name) { throw new InvalidArgumentException('Invalid name'); } $parts = explode(':', $name); if (count($parts) < 2) { throw new SocketException('Could not parse name parts: ' . $name)...
php
public static function getNamePart(string $name, int $part): string { if (!$name) { throw new InvalidArgumentException('Invalid name'); } $parts = explode(':', $name); if (count($parts) < 2) { throw new SocketException('Could not parse name parts: ' . $name)...
[ "public", "static", "function", "getNamePart", "(", "string", "$", "name", ",", "int", "$", "part", ")", ":", "string", "{", "if", "(", "!", "$", "name", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Invalid name'", ")", ";", "}", "$", "...
Gets part of the name of the socket PHP seems to return IPV6 address/port combos like this: ::1:1234, where ::1 is the address and 1234 the port So, the part number here is either the last : delimited section (the port) or all the other sections (the whole initial part, the address). @param string $name (from $this->g...
[ "Gets", "part", "of", "the", "name", "of", "the", "socket", "PHP", "seems", "to", "return", "IPV6", "address", "/", "port", "combos", "like", "this", ":", "::", "1", ":", "1234", "where", "::", "1", "is", "the", "address", "and", "1234", "the", "port...
train
https://github.com/varspool/Wrench/blob/2c297b5d655efaed22acbd0486d219f11b698b3c/lib/Socket/Socket.php#L110-L129
varspool/Wrench
lib/Socket/Socket.php
Socket.getPort
public function getPort(): int { $name = $this->getName(); if ($name) { return (int)self::getNamePart($name, self::NAME_PART_PORT); } else { throw new SocketException('Cannot get socket IP address'); } }
php
public function getPort(): int { $name = $this->getName(); if ($name) { return (int)self::getNamePart($name, self::NAME_PART_PORT); } else { throw new SocketException('Cannot get socket IP address'); } }
[ "public", "function", "getPort", "(", ")", ":", "int", "{", "$", "name", "=", "$", "this", "->", "getName", "(", ")", ";", "if", "(", "$", "name", ")", "{", "return", "(", "int", ")", "self", "::", "getNamePart", "(", "$", "name", ",", "self", ...
Gets the port of the socket @throws \Wrench\Exception\SocketException If the port cannot be obtained @return int
[ "Gets", "the", "port", "of", "the", "socket" ]
train
https://github.com/varspool/Wrench/blob/2c297b5d655efaed22acbd0486d219f11b698b3c/lib/Socket/Socket.php#L137-L146
varspool/Wrench
lib/Socket/Socket.php
Socket.getLastError
public function getLastError(): string { if ($this->isConnected() && $this->socket) { $err = @socket_last_error($this->socket); if ($err) { $err = socket_strerror($err); } if (!$err) { $err = 'Unknown error'; } ...
php
public function getLastError(): string { if ($this->isConnected() && $this->socket) { $err = @socket_last_error($this->socket); if ($err) { $err = socket_strerror($err); } if (!$err) { $err = 'Unknown error'; } ...
[ "public", "function", "getLastError", "(", ")", ":", "string", "{", "if", "(", "$", "this", "->", "isConnected", "(", ")", "&&", "$", "this", "->", "socket", ")", "{", "$", "err", "=", "@", "socket_last_error", "(", "$", "this", "->", "socket", ")", ...
Get the last error that occurred on the socket @return string
[ "Get", "the", "last", "error", "that", "occurred", "on", "the", "socket" ]
train
https://github.com/varspool/Wrench/blob/2c297b5d655efaed22acbd0486d219f11b698b3c/lib/Socket/Socket.php#L153-L167
varspool/Wrench
lib/Socket/Socket.php
Socket.receive
public function receive(int $length = self::DEFAULT_RECEIVE_LENGTH): string { $buffer = ''; $metadata['unread_bytes'] = 0; $makeBlockingAfterRead = false; try { do { // feof means socket has been closed // also, sometimes in long running p...
php
public function receive(int $length = self::DEFAULT_RECEIVE_LENGTH): string { $buffer = ''; $metadata['unread_bytes'] = 0; $makeBlockingAfterRead = false; try { do { // feof means socket has been closed // also, sometimes in long running p...
[ "public", "function", "receive", "(", "int", "$", "length", "=", "self", "::", "DEFAULT_RECEIVE_LENGTH", ")", ":", "string", "{", "$", "buffer", "=", "''", ";", "$", "metadata", "[", "'unread_bytes'", "]", "=", "0", ";", "$", "makeBlockingAfterRead", "=", ...
Receive data from the socket @param int $length @return string
[ "Receive", "data", "from", "the", "socket" ]
train
https://github.com/varspool/Wrench/blob/2c297b5d655efaed22acbd0486d219f11b698b3c/lib/Socket/Socket.php#L228-L308
varspool/Wrench
lib/Socket/Socket.php
Socket.disconnect
public function disconnect(): void { if ($this->socket) { stream_socket_shutdown($this->socket, STREAM_SHUT_RDWR); } $this->socket = null; $this->connected = false; }
php
public function disconnect(): void { if ($this->socket) { stream_socket_shutdown($this->socket, STREAM_SHUT_RDWR); } $this->socket = null; $this->connected = false; }
[ "public", "function", "disconnect", "(", ")", ":", "void", "{", "if", "(", "$", "this", "->", "socket", ")", "{", "stream_socket_shutdown", "(", "$", "this", "->", "socket", ",", "STREAM_SHUT_RDWR", ")", ";", "}", "$", "this", "->", "socket", "=", "nul...
Disconnect the socket @return void
[ "Disconnect", "the", "socket" ]
train
https://github.com/varspool/Wrench/blob/2c297b5d655efaed22acbd0486d219f11b698b3c/lib/Socket/Socket.php#L315-L322
varspool/Wrench
lib/Socket/Socket.php
Socket.configure
protected function configure(array $options): void { $options = array_merge([ 'timeout_socket' => self::TIMEOUT_SOCKET, ], $options); parent::configure($options); }
php
protected function configure(array $options): void { $options = array_merge([ 'timeout_socket' => self::TIMEOUT_SOCKET, ], $options); parent::configure($options); }
[ "protected", "function", "configure", "(", "array", "$", "options", ")", ":", "void", "{", "$", "options", "=", "array_merge", "(", "[", "'timeout_socket'", "=>", "self", "::", "TIMEOUT_SOCKET", ",", "]", ",", "$", "options", ")", ";", "parent", "::", "c...
Configure options Options include - timeout_socket => int, seconds, default 5 @param array $options @return void
[ "Configure", "options", "Options", "include", "-", "timeout_socket", "=", ">", "int", "seconds", "default", "5" ]
train
https://github.com/varspool/Wrench/blob/2c297b5d655efaed22acbd0486d219f11b698b3c/lib/Socket/Socket.php#L332-L339
varspool/Wrench
lib/Server.php
Server.run
public function run(): void { $this->connectionManager->listen(); while ($this->loop->shouldContinue()) { /* * If there's nothing changed on any of the sockets, the server * will sleep and other processes will have a change to run. Control * this b...
php
public function run(): void { $this->connectionManager->listen(); while ($this->loop->shouldContinue()) { /* * If there's nothing changed on any of the sockets, the server * will sleep and other processes will have a change to run. Control * this b...
[ "public", "function", "run", "(", ")", ":", "void", "{", "$", "this", "->", "connectionManager", "->", "listen", "(", ")", ";", "while", "(", "$", "this", "->", "loop", "->", "shouldContinue", "(", ")", ")", "{", "/*\n * If there's nothing change...
Main server loop @return void This method does not return!
[ "Main", "server", "loop" ]
train
https://github.com/varspool/Wrench/blob/2c297b5d655efaed22acbd0486d219f11b698b3c/lib/Server.php#L126-L149
varspool/Wrench
lib/Server.php
Server.notify
public function notify($event, array $arguments = []): void { if (!isset($this->listeners[$event])) { return; } foreach ($this->listeners[$event] as $listener) { call_user_func_array($listener, $arguments); } }
php
public function notify($event, array $arguments = []): void { if (!isset($this->listeners[$event])) { return; } foreach ($this->listeners[$event] as $listener) { call_user_func_array($listener, $arguments); } }
[ "public", "function", "notify", "(", "$", "event", ",", "array", "$", "arguments", "=", "[", "]", ")", ":", "void", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "listeners", "[", "$", "event", "]", ")", ")", "{", "return", ";", "}", "f...
Notifies listeners of an event @param string $event @param array $arguments Event arguments @return void
[ "Notifies", "listeners", "of", "an", "event" ]
train
https://github.com/varspool/Wrench/blob/2c297b5d655efaed22acbd0486d219f11b698b3c/lib/Server.php#L158-L167
varspool/Wrench
lib/Server.php
Server.addListener
public function addListener($event, callable $callback): void { if (!isset($this->listeners[$event])) { $this->listeners[$event] = []; } if (!is_callable($callback)) { throw new InvalidArgumentException('Invalid listener'); } $this->listeners[$event]...
php
public function addListener($event, callable $callback): void { if (!isset($this->listeners[$event])) { $this->listeners[$event] = []; } if (!is_callable($callback)) { throw new InvalidArgumentException('Invalid listener'); } $this->listeners[$event]...
[ "public", "function", "addListener", "(", "$", "event", ",", "callable", "$", "callback", ")", ":", "void", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "listeners", "[", "$", "event", "]", ")", ")", "{", "$", "this", "->", "listeners", "[...
Adds a listener Provide an event (see the Server::EVENT_* constants) and a callback closure. Some arguments may be provided to your callback, such as the connection the caused the event. @param string $event @param callable $callback @return void @throws InvalidArgumentException
[ "Adds", "a", "listener", "Provide", "an", "event", "(", "see", "the", "Server", "::", "EVENT_", "*", "constants", ")", "and", "a", "callback", "closure", ".", "Some", "arguments", "may", "be", "provided", "to", "your", "callback", "such", "as", "the", "c...
train
https://github.com/varspool/Wrench/blob/2c297b5d655efaed22acbd0486d219f11b698b3c/lib/Server.php#L180-L191
varspool/Wrench
lib/Server.php
Server.getApplication
public function getApplication($key) { if (empty($key)) { return null; } if (array_key_exists($key, $this->applications)) { return $this->applications[$key]; } return null; }
php
public function getApplication($key) { if (empty($key)) { return null; } if (array_key_exists($key, $this->applications)) { return $this->applications[$key]; } return null; }
[ "public", "function", "getApplication", "(", "$", "key", ")", "{", "if", "(", "empty", "(", "$", "key", ")", ")", "{", "return", "null", ";", "}", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "applications", ")", ")", "{"...
Returns a server application. @param string $key Name of application. @return null|DataHandlerInterface|ConnectionHandlerInterface|UpdateHandlerInterface The application object
[ "Returns", "a", "server", "application", "." ]
train
https://github.com/varspool/Wrench/blob/2c297b5d655efaed22acbd0486d219f11b698b3c/lib/Server.php#L199-L210
varspool/Wrench
lib/Server.php
Server.configure
protected function configure(array $options): void { $options = array_merge([ 'connection_manager' => null, 'connection_manager_class' => ConnectionManager::class, 'connection_manager_options' => [], ], $options); parent::configure($options); $th...
php
protected function configure(array $options): void { $options = array_merge([ 'connection_manager' => null, 'connection_manager_class' => ConnectionManager::class, 'connection_manager_options' => [], ], $options); parent::configure($options); $th...
[ "protected", "function", "configure", "(", "array", "$", "options", ")", ":", "void", "{", "$", "options", "=", "array_merge", "(", "[", "'connection_manager'", "=>", "null", ",", "'connection_manager_class'", "=>", "ConnectionManager", "::", "class", ",", "'con...
Configure options Options include - socket_class => The socket class to use, defaults to ServerSocket - socket_options => An array of socket options - logger => Closure($message, $priority = 'info'), used for logging @param array $options @return void
[ "Configure", "options" ]
train
https://github.com/varspool/Wrench/blob/2c297b5d655efaed22acbd0486d219f11b698b3c/lib/Server.php#L236-L247
varspool/Wrench
lib/Server.php
Server.configureConnectionManager
protected function configureConnectionManager(): void { if ($this->options['connection_manager']) { $this->connectionManager = $this->options['connection_manager']; } else { $class = $this->options['connection_manager_class']; $options = $this->options['connection...
php
protected function configureConnectionManager(): void { if ($this->options['connection_manager']) { $this->connectionManager = $this->options['connection_manager']; } else { $class = $this->options['connection_manager_class']; $options = $this->options['connection...
[ "protected", "function", "configureConnectionManager", "(", ")", ":", "void", "{", "if", "(", "$", "this", "->", "options", "[", "'connection_manager'", "]", ")", "{", "$", "this", "->", "connectionManager", "=", "$", "this", "->", "options", "[", "'connecti...
Configures the connection manager @return void
[ "Configures", "the", "connection", "manager" ]
train
https://github.com/varspool/Wrench/blob/2c297b5d655efaed22acbd0486d219f11b698b3c/lib/Server.php#L254-L266
varspool/Wrench
lib/Protocol/Protocol.php
Protocol.generateKey
public function generateKey() { if (extension_loaded('openssl')) { $key = openssl_random_pseudo_bytes(16); } else { // SHA1 is 128 bit (= 16 bytes) $key = sha1(spl_object_hash($this) . mt_rand(0, PHP_INT_MAX) . uniqid('', true), true); } return ba...
php
public function generateKey() { if (extension_loaded('openssl')) { $key = openssl_random_pseudo_bytes(16); } else { // SHA1 is 128 bit (= 16 bytes) $key = sha1(spl_object_hash($this) . mt_rand(0, PHP_INT_MAX) . uniqid('', true), true); } return ba...
[ "public", "function", "generateKey", "(", ")", "{", "if", "(", "extension_loaded", "(", "'openssl'", ")", ")", "{", "$", "key", "=", "openssl_random_pseudo_bytes", "(", "16", ")", ";", "}", "else", "{", "// SHA1 is 128 bit (= 16 bytes)", "$", "key", "=", "sh...
Generates a key suitable for use in the protocol This base implementation returns a 16-byte (128 bit) random key as a binary string. @return string
[ "Generates", "a", "key", "suitable", "for", "use", "in", "the", "protocol", "This", "base", "implementation", "returns", "a", "16", "-", "byte", "(", "128", "bit", ")", "random", "key", "as", "a", "binary", "string", "." ]
train
https://github.com/varspool/Wrench/blob/2c297b5d655efaed22acbd0486d219f11b698b3c/lib/Protocol/Protocol.php#L226-L236
varspool/Wrench
lib/Protocol/Protocol.php
Protocol.getRequestHandshake
public function getRequestHandshake( $uri, $key, $origin, array $headers = [] ) { if (!$uri || !$key || !$origin) { throw new InvalidArgumentException('You must supply a URI, key and origin'); } list($scheme, $host, $port, $path, $query) = self::v...
php
public function getRequestHandshake( $uri, $key, $origin, array $headers = [] ) { if (!$uri || !$key || !$origin) { throw new InvalidArgumentException('You must supply a URI, key and origin'); } list($scheme, $host, $port, $path, $query) = self::v...
[ "public", "function", "getRequestHandshake", "(", "$", "uri", ",", "$", "key", ",", "$", "origin", ",", "array", "$", "headers", "=", "[", "]", ")", "{", "if", "(", "!", "$", "uri", "||", "!", "$", "key", "||", "!", "$", "origin", ")", "{", "th...
Gets request handshake string The leading line from the client follows the Request-Line format. The leading line from the server follows the Status-Line format. The Request-Line and Status-Line productions are defined in [RFC2616]. An unordered set of header fields comes after the leading line in both cases. The mean...
[ "Gets", "request", "handshake", "string", "The", "leading", "line", "from", "the", "client", "follows", "the", "Request", "-", "Line", "format", ".", "The", "leading", "line", "from", "the", "server", "follows", "the", "Status", "-", "Line", "format", ".", ...
train
https://github.com/varspool/Wrench/blob/2c297b5d655efaed22acbd0486d219f11b698b3c/lib/Protocol/Protocol.php#L254-L295
varspool/Wrench
lib/Protocol/Protocol.php
Protocol.validateUri
public function validateUri($uri) { $uri = (string)$uri; if (!$uri) { throw new InvalidArgumentException('Invalid URI'); } $scheme = parse_url($uri, PHP_URL_SCHEME); $this->validateScheme($scheme); $host = parse_url($uri, PHP_URL_HOST); if (!$hos...
php
public function validateUri($uri) { $uri = (string)$uri; if (!$uri) { throw new InvalidArgumentException('Invalid URI'); } $scheme = parse_url($uri, PHP_URL_SCHEME); $this->validateScheme($scheme); $host = parse_url($uri, PHP_URL_HOST); if (!$hos...
[ "public", "function", "validateUri", "(", "$", "uri", ")", "{", "$", "uri", "=", "(", "string", ")", "$", "uri", ";", "if", "(", "!", "$", "uri", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Invalid URI'", ")", ";", "}", "$", "scheme"...
Validates a WebSocket URI @param string $uri @return array(string $scheme, string $host, int $port, string $path)
[ "Validates", "a", "WebSocket", "URI" ]
train
https://github.com/varspool/Wrench/blob/2c297b5d655efaed22acbd0486d219f11b698b3c/lib/Protocol/Protocol.php#L303-L331
varspool/Wrench
lib/Protocol/Protocol.php
Protocol.validateScheme
protected function validateScheme($scheme) { if (!$scheme) { throw new InvalidArgumentException('No scheme specified'); } if (!in_array($scheme, self::$schemes)) { throw new InvalidArgumentException( 'Unknown socket scheme: ' . $scheme ); ...
php
protected function validateScheme($scheme) { if (!$scheme) { throw new InvalidArgumentException('No scheme specified'); } if (!in_array($scheme, self::$schemes)) { throw new InvalidArgumentException( 'Unknown socket scheme: ' . $scheme ); ...
[ "protected", "function", "validateScheme", "(", "$", "scheme", ")", "{", "if", "(", "!", "$", "scheme", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'No scheme specified'", ")", ";", "}", "if", "(", "!", "in_array", "(", "$", "scheme", ",", ...
Validates a scheme @param string $scheme @return string Underlying scheme @throws InvalidArgumentException
[ "Validates", "a", "scheme" ]
train
https://github.com/varspool/Wrench/blob/2c297b5d655efaed22acbd0486d219f11b698b3c/lib/Protocol/Protocol.php#L340-L355
varspool/Wrench
lib/Protocol/Protocol.php
Protocol.getPort
protected function getPort($scheme) { if ($scheme == self::SCHEME_WEBSOCKET) { return 80; } elseif ($scheme == self::SCHEME_WEBSOCKET_SECURE) { return 443; } elseif ($scheme == self::SCHEME_UNDERLYING) { return 80; } elseif ($scheme == self::SCHEME...
php
protected function getPort($scheme) { if ($scheme == self::SCHEME_WEBSOCKET) { return 80; } elseif ($scheme == self::SCHEME_WEBSOCKET_SECURE) { return 443; } elseif ($scheme == self::SCHEME_UNDERLYING) { return 80; } elseif ($scheme == self::SCHEME...
[ "protected", "function", "getPort", "(", "$", "scheme", ")", "{", "if", "(", "$", "scheme", "==", "self", "::", "SCHEME_WEBSOCKET", ")", "{", "return", "80", ";", "}", "elseif", "(", "$", "scheme", "==", "self", "::", "SCHEME_WEBSOCKET_SECURE", ")", "{",...
Gets the default port for a scheme By default, the WebSocket Protocol uses port 80 for regular WebSocket connections and port 443 for WebSocket connections tunneled over Transport Layer Security @param string|false $scheme @return int
[ "Gets", "the", "default", "port", "for", "a", "scheme", "By", "default", "the", "WebSocket", "Protocol", "uses", "port", "80", "for", "regular", "WebSocket", "connections", "and", "port", "443", "for", "WebSocket", "connections", "tunneled", "over", "Transport",...
train
https://github.com/varspool/Wrench/blob/2c297b5d655efaed22acbd0486d219f11b698b3c/lib/Protocol/Protocol.php#L366-L379
varspool/Wrench
lib/Protocol/Protocol.php
Protocol.getDefaultRequestHeaders
protected function getDefaultRequestHeaders($host, $key, $origin) { return [ self::HEADER_HOST => $host, self::HEADER_UPGRADE => self::UPGRADE_VALUE, self::HEADER_CONNECTION => self::CONNECTION_VALUE, self::HEADER_KEY => $key, self::HEADER_ORIGIN =...
php
protected function getDefaultRequestHeaders($host, $key, $origin) { return [ self::HEADER_HOST => $host, self::HEADER_UPGRADE => self::UPGRADE_VALUE, self::HEADER_CONNECTION => self::CONNECTION_VALUE, self::HEADER_KEY => $key, self::HEADER_ORIGIN =...
[ "protected", "function", "getDefaultRequestHeaders", "(", "$", "host", ",", "$", "key", ",", "$", "origin", ")", "{", "return", "[", "self", "::", "HEADER_HOST", "=>", "$", "host", ",", "self", "::", "HEADER_UPGRADE", "=>", "self", "::", "UPGRADE_VALUE", "...
Gets the default request headers @param string $host @param string $key @param string $origin @return string[]
[ "Gets", "the", "default", "request", "headers" ]
train
https://github.com/varspool/Wrench/blob/2c297b5d655efaed22acbd0486d219f11b698b3c/lib/Protocol/Protocol.php#L389-L399
varspool/Wrench
lib/Protocol/Protocol.php
Protocol.getResponseHandshake
public function getResponseHandshake($key, array $headers = []) { $headers = array_merge( $this->getSuccessResponseHeaders( $key ), $headers ); return $this->getHttpResponse(self::HTTP_SWITCHING_PROTOCOLS, $headers); }
php
public function getResponseHandshake($key, array $headers = []) { $headers = array_merge( $this->getSuccessResponseHeaders( $key ), $headers ); return $this->getHttpResponse(self::HTTP_SWITCHING_PROTOCOLS, $headers); }
[ "public", "function", "getResponseHandshake", "(", "$", "key", ",", "array", "$", "headers", "=", "[", "]", ")", "{", "$", "headers", "=", "array_merge", "(", "$", "this", "->", "getSuccessResponseHeaders", "(", "$", "key", ")", ",", "$", "headers", ")",...
Gets a handshake response body @param string $key @param array $headers
[ "Gets", "a", "handshake", "response", "body" ]
train
https://github.com/varspool/Wrench/blob/2c297b5d655efaed22acbd0486d219f11b698b3c/lib/Protocol/Protocol.php#L414-L424
varspool/Wrench
lib/Protocol/Protocol.php
Protocol.getSuccessResponseHeaders
protected function getSuccessResponseHeaders($key) { return [ self::HEADER_UPGRADE => self::UPGRADE_VALUE, self::HEADER_CONNECTION => self::CONNECTION_VALUE, self::HEADER_ACCEPT => $this->getAcceptValue($key), ]; }
php
protected function getSuccessResponseHeaders($key) { return [ self::HEADER_UPGRADE => self::UPGRADE_VALUE, self::HEADER_CONNECTION => self::CONNECTION_VALUE, self::HEADER_ACCEPT => $this->getAcceptValue($key), ]; }
[ "protected", "function", "getSuccessResponseHeaders", "(", "$", "key", ")", "{", "return", "[", "self", "::", "HEADER_UPGRADE", "=>", "self", "::", "UPGRADE_VALUE", ",", "self", "::", "HEADER_CONNECTION", "=>", "self", "::", "CONNECTION_VALUE", ",", "self", "::"...
Gets the default response headers @param string $key @return string[]
[ "Gets", "the", "default", "response", "headers" ]
train
https://github.com/varspool/Wrench/blob/2c297b5d655efaed22acbd0486d219f11b698b3c/lib/Protocol/Protocol.php#L432-L439
varspool/Wrench
lib/Protocol/Protocol.php
Protocol.getHttpResponse
protected function getHttpResponse($status, array $headers = []) { if (array_key_exists($status, self::HTTP_RESPONSES)) { $response = self::HTTP_RESPONSES[$status]; } else { $response = self::HTTP_RESPONSES[self::HTTP_NOT_IMPLEMENTED]; } $handshake = [ ...
php
protected function getHttpResponse($status, array $headers = []) { if (array_key_exists($status, self::HTTP_RESPONSES)) { $response = self::HTTP_RESPONSES[$status]; } else { $response = self::HTTP_RESPONSES[self::HTTP_NOT_IMPLEMENTED]; } $handshake = [ ...
[ "protected", "function", "getHttpResponse", "(", "$", "status", ",", "array", "$", "headers", "=", "[", "]", ")", "{", "if", "(", "array_key_exists", "(", "$", "status", ",", "self", "::", "HTTP_RESPONSES", ")", ")", "{", "$", "response", "=", "self", ...
Gets an HTTP response @param int $status @param array $headers @return string
[ "Gets", "an", "HTTP", "response" ]
train
https://github.com/varspool/Wrench/blob/2c297b5d655efaed22acbd0486d219f11b698b3c/lib/Protocol/Protocol.php#L462-L479
varspool/Wrench
lib/Protocol/Protocol.php
Protocol.getResponseError
public function getResponseError($e, array $headers = []) { $code = false; if ($e instanceof Exception) { $code = $e->getCode(); } elseif (is_numeric($e)) { $code = (int)$e; } if (!$code || $code < 400 || $code > 599) { $code = self::HTTP...
php
public function getResponseError($e, array $headers = []) { $code = false; if ($e instanceof Exception) { $code = $e->getCode(); } elseif (is_numeric($e)) { $code = (int)$e; } if (!$code || $code < 400 || $code > 599) { $code = self::HTTP...
[ "public", "function", "getResponseError", "(", "$", "e", ",", "array", "$", "headers", "=", "[", "]", ")", "{", "$", "code", "=", "false", ";", "if", "(", "$", "e", "instanceof", "Exception", ")", "{", "$", "code", "=", "$", "e", "->", "getCode", ...
Gets a response to an error in the handshake @param int|Exception $e Exception or HTTP error @param array $headers @return string
[ "Gets", "a", "response", "to", "an", "error", "in", "the", "handshake" ]
train
https://github.com/varspool/Wrench/blob/2c297b5d655efaed22acbd0486d219f11b698b3c/lib/Protocol/Protocol.php#L488-L503
varspool/Wrench
lib/Protocol/Protocol.php
Protocol.getHeaders
protected function getHeaders($response, &$request_line = null) { $parts = explode("\r\n\r\n", $response, 2); if (count($parts) < 2) { $parts[] = ''; } list($headers, $body) = $parts; $return = []; foreach (explode("\r\n", $headers) as $header) { ...
php
protected function getHeaders($response, &$request_line = null) { $parts = explode("\r\n\r\n", $response, 2); if (count($parts) < 2) { $parts[] = ''; } list($headers, $body) = $parts; $return = []; foreach (explode("\r\n", $headers) as $header) { ...
[ "protected", "function", "getHeaders", "(", "$", "response", ",", "&", "$", "request_line", "=", "null", ")", "{", "$", "parts", "=", "explode", "(", "\"\\r\\n\\r\\n\"", ",", "$", "response", ",", "2", ")", ";", "if", "(", "count", "(", "$", "parts", ...
Gets the headers from a full response @param string $response @return array() @throws InvalidArgumentException
[ "Gets", "the", "headers", "from", "a", "full", "response" ]
train
https://github.com/varspool/Wrench/blob/2c297b5d655efaed22acbd0486d219f11b698b3c/lib/Protocol/Protocol.php#L545-L573
varspool/Wrench
lib/Protocol/Protocol.php
Protocol.validateRequestHandshake
public function validateRequestHandshake( $request ) { if (!$request) { return false; } list($request, $headers) = $this->getRequestHeaders($request); // make a copy of the headers array to store all extra headers $extraHeaders = $headers; // par...
php
public function validateRequestHandshake( $request ) { if (!$request) { return false; } list($request, $headers) = $this->getRequestHeaders($request); // make a copy of the headers array to store all extra headers $extraHeaders = $headers; // par...
[ "public", "function", "validateRequestHandshake", "(", "$", "request", ")", "{", "if", "(", "!", "$", "request", ")", "{", "return", "false", ";", "}", "list", "(", "$", "request", ",", "$", "headers", ")", "=", "$", "this", "->", "getRequestHeaders", ...
Validates a request handshake @param string $request @throws BadRequestException
[ "Validates", "a", "request", "handshake" ]
train
https://github.com/varspool/Wrench/blob/2c297b5d655efaed22acbd0486d219f11b698b3c/lib/Protocol/Protocol.php#L592-L682
varspool/Wrench
lib/Protocol/Protocol.php
Protocol.getRequestHeaders
protected function getRequestHeaders($response) { $eol = stripos($response, "\r\n"); if ($eol === false) { throw new InvalidArgumentException('Invalid request line'); } $request = substr($response, 0, $eol); $headers = $this->getHeaders(substr($response, $eol + ...
php
protected function getRequestHeaders($response) { $eol = stripos($response, "\r\n"); if ($eol === false) { throw new InvalidArgumentException('Invalid request line'); } $request = substr($response, 0, $eol); $headers = $this->getHeaders(substr($response, $eol + ...
[ "protected", "function", "getRequestHeaders", "(", "$", "response", ")", "{", "$", "eol", "=", "stripos", "(", "$", "response", ",", "\"\\r\\n\"", ")", ";", "if", "(", "$", "eol", "===", "false", ")", "{", "throw", "new", "InvalidArgumentException", "(", ...
Gets request headers @param string $response @return array<string, array<string>> The request line, and an array of headers @throws InvalidArgumentException
[ "Gets", "request", "headers" ]
train
https://github.com/varspool/Wrench/blob/2c297b5d655efaed22acbd0486d219f11b698b3c/lib/Protocol/Protocol.php#L692-L704
varspool/Wrench
lib/Protocol/Protocol.php
Protocol.validateRequestLine
protected function validateRequestLine($line) { $matches = [0 => null, 1 => null]; if (!preg_match(self::REQUEST_LINE_REGEX, $line, $matches) || !$matches[1]) { throw new BadRequestException('Invalid request line', 400); } return $matches[1]; }
php
protected function validateRequestLine($line) { $matches = [0 => null, 1 => null]; if (!preg_match(self::REQUEST_LINE_REGEX, $line, $matches) || !$matches[1]) { throw new BadRequestException('Invalid request line', 400); } return $matches[1]; }
[ "protected", "function", "validateRequestLine", "(", "$", "line", ")", "{", "$", "matches", "=", "[", "0", "=>", "null", ",", "1", "=>", "null", "]", ";", "if", "(", "!", "preg_match", "(", "self", "::", "REQUEST_LINE_REGEX", ",", "$", "line", ",", "...
Validates a request line @param string $line @throws BadRequestException
[ "Validates", "a", "request", "line" ]
train
https://github.com/varspool/Wrench/blob/2c297b5d655efaed22acbd0486d219f11b698b3c/lib/Protocol/Protocol.php#L712-L721
varspool/Wrench
lib/Protocol/Protocol.php
Protocol.getClosePayload
public function getClosePayload($e, $masked = true) { $code = false; if ($e instanceof Exception) { $code = $e->getCode(); } elseif (is_numeric($e)) { $code = (int)$e; } if (!$code || !key_exists($code, self::CLOSE_REASONS)) { $code = sel...
php
public function getClosePayload($e, $masked = true) { $code = false; if ($e instanceof Exception) { $code = $e->getCode(); } elseif (is_numeric($e)) { $code = (int)$e; } if (!$code || !key_exists($code, self::CLOSE_REASONS)) { $code = sel...
[ "public", "function", "getClosePayload", "(", "$", "e", ",", "$", "masked", "=", "true", ")", "{", "$", "code", "=", "false", ";", "if", "(", "$", "e", "instanceof", "Exception", ")", "{", "$", "code", "=", "$", "e", "->", "getCode", "(", ")", ";...
Gets a suitable WebSocket close frame. Please set `masked` to false if you send a close frame from server side. @param Exception|int $e @param boolean $masked @return Payload
[ "Gets", "a", "suitable", "WebSocket", "close", "frame", ".", "Please", "set", "masked", "to", "false", "if", "you", "send", "a", "close", "frame", "from", "server", "side", "." ]
train
https://github.com/varspool/Wrench/blob/2c297b5d655efaed22acbd0486d219f11b698b3c/lib/Protocol/Protocol.php#L740-L758
varspool/Wrench
lib/Protocol/Protocol.php
Protocol.validateSocketUri
public function validateSocketUri($uri) { $uri = (string)$uri; if (!$uri) { throw new InvalidArgumentException('Invalid URI'); } $scheme = parse_url($uri, PHP_URL_SCHEME); $scheme = $this->validateScheme($scheme); $host = parse_url($uri, PHP_URL_HOST); ...
php
public function validateSocketUri($uri) { $uri = (string)$uri; if (!$uri) { throw new InvalidArgumentException('Invalid URI'); } $scheme = parse_url($uri, PHP_URL_SCHEME); $scheme = $this->validateScheme($scheme); $host = parse_url($uri, PHP_URL_HOST); ...
[ "public", "function", "validateSocketUri", "(", "$", "uri", ")", "{", "$", "uri", "=", "(", "string", ")", "$", "uri", ";", "if", "(", "!", "$", "uri", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Invalid URI'", ")", ";", "}", "$", "s...
Validates a socket URI @param string $uri @throws InvalidArgumentException @return array(string $scheme, string $host, string $port)
[ "Validates", "a", "socket", "URI" ]
train
https://github.com/varspool/Wrench/blob/2c297b5d655efaed22acbd0486d219f11b698b3c/lib/Protocol/Protocol.php#L775-L796