idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
46,900
protected function getQueryFilter ( $ params ) { if ( empty ( $ params [ 'FilterClass' ] ) ) { return null ; } $ filterClass = $ params [ 'FilterClass' ] ; if ( ! is_subclass_of ( $ filterClass , CMSSiteTreeFilter :: class ) ) { throw new InvalidArgumentException ( "Invalid filter class passed: {$filterClass}" ) ; } re...
Safely reconstruct a selected filter from a given set of query parameters
46,901
public function save ( $ data , $ form ) { $ className = $ this -> config ( ) -> get ( 'tree_class' ) ; $ id = $ data [ 'ID' ] ; if ( substr ( $ id , 0 , 3 ) != 'new' ) { $ record = DataObject :: get_by_id ( $ className , $ id ) ; if ( $ record && ! $ record -> canEdit ( ) ) { return Security :: permissionFailure ( $ t...
Save and Publish page handler
46,902
public function performPublish ( $ record ) { if ( $ record && ! $ record -> canPublish ( ) ) { return Security :: permissionFailure ( $ this ) ; } $ record -> publishRecursive ( ) ; }
Actually perform the publication step
46,903
public function delete ( $ data , $ form ) { $ id = $ data [ 'ID' ] ; $ record = SiteTree :: get ( ) -> byID ( $ id ) ; if ( $ record && ! $ record -> canDelete ( ) ) { return Security :: permissionFailure ( ) ; } if ( ! $ record || ! $ record -> ID ) { throw new HTTPResponse_Exception ( "Bad record ID #$id" , 404 ) ; ...
Delete the current page from draft stage .
46,904
public function archive ( $ data , $ form ) { $ id = $ data [ 'ID' ] ; $ record = SiteTree :: get ( ) -> byID ( $ id ) ; if ( ! $ record || ! $ record -> exists ( ) ) { throw new HTTPResponse_Exception ( "Bad record ID #$id" , 404 ) ; } if ( ! $ record -> canArchive ( ) ) { return Security :: permissionFailure ( ) ; } ...
Delete this page from both live and stage
46,905
public function doRollback ( $ data , $ form ) { $ this -> extend ( 'onBeforeRollback' , $ data [ 'ID' ] , $ data [ 'Version' ] ) ; $ id = ( isset ( $ data [ 'ID' ] ) ) ? ( int ) $ data [ 'ID' ] : null ; $ version = ( isset ( $ data [ 'Version' ] ) ) ? ( int ) $ data [ 'Version' ] : null ; $ record = Versioned :: get_l...
Rolls a site back to a given version ID
46,906
public function restore ( $ data , $ form ) { if ( ! isset ( $ data [ 'ID' ] ) || ! is_numeric ( $ data [ 'ID' ] ) ) { return new HTTPResponse ( "Please pass an ID in the form content" , 400 ) ; } $ id = ( int ) $ data [ 'ID' ] ; $ restoredPage = Versioned :: get_latest_version ( SiteTree :: class , $ id ) ; if ( ! $ r...
Restore a completely deleted page from the SiteTree_versions table .
46,907
public function flushMemberCache ( $ memberIDs = null ) { $ cache = $ this -> getHintsCache ( ) ; if ( ! $ memberIDs ) { $ cache -> clear ( ) ; return ; } foreach ( $ memberIDs as $ memberID ) { $ key = $ this -> generateHintsCacheKey ( $ memberID ) ; $ cache -> delete ( $ key ) ; } }
Flush the hints cache for a specific member
46,908
public function classesToSearch ( $ classes ) { $ supportedClasses = array ( SiteTree :: class , File :: class ) ; $ illegalClasses = array_diff ( $ classes , $ supportedClasses ) ; if ( $ illegalClasses ) { throw new BadMethodCallException ( "SearchForm::classesToSearch() passed illegal classes '" . implode ( "', '" ,...
Set the classes to search . Currently you can only choose from SiteTree and File but a future version might improve this .
46,909
public function ChildrenOf ( $ parentRef ) { $ parent = SiteTree :: get_by_link ( $ parentRef ) ; if ( ! $ parent && is_numeric ( $ parentRef ) ) { $ parent = DataObject :: get_by_id ( SiteTree :: class , $ parentRef ) ; } if ( $ parent ) { return $ parent -> Children ( ) ; } return null ; }
Return the children of a given page . The parent reference can either be a page link or an ID .
46,910
public function getViewer ( $ action ) { if ( ! empty ( $ this -> templates [ $ action ] ) || ! empty ( $ this -> templates [ 'index' ] ) || $ this -> template ) { return parent :: getViewer ( $ action ) ; } $ action = $ action === 'index' ? '' : '_' . $ action ; $ templatesFound = [ ] ; if ( $ this -> dataRecord insta...
Return an SSViewer object to render the template for the current page .
46,911
public function successfullyinstalled ( ) { if ( ! file_exists ( PUBLIC_PATH . '/install.php' ) ) { $ this -> httpError ( 410 ) ; } if ( isset ( $ _SESSION [ 'StatsID' ] ) && $ _SESSION [ 'StatsID' ] ) { $ url = 'http://ss2stat.silverstripe.com/Installation/installed?ID=' . $ _SESSION [ 'StatsID' ] ; @ file_get_content...
This action is called by the installation system
46,912
protected function toggleElementClass ( DOMElement $ domReference , $ class , $ toggle ) { $ classes = array_filter ( explode ( ' ' , trim ( $ domReference -> getAttribute ( 'class' ) ) ) ) ; if ( $ toggle ) { $ classes = array_unique ( array_merge ( $ classes , [ $ class ] ) ) ; } else { $ classes = array_diff ( $ cla...
Add the given css class to the DOM element .
46,913
public function getFilteredPages ( ) { $ pages = Versioned :: get_by_stage ( SiteTree :: class , Versioned :: DRAFT ) ; $ pages = $ this -> applyDefaultFilters ( $ pages ) ; return $ pages ; }
Retun an array of maps containing the keys ID and ParentID for each page to be displayed in the search .
46,914
public function getUnusedFilesListFilter ( ) { Deprecation :: notice ( '5.0' , 'Will be removed in 5.0' ) ; $ usedFiles = FileLink :: get ( ) -> column ( 'LinkedID' ) ; $ fileClasses = array_diff_key ( ClassInfo :: subclassesFor ( File :: class ) , ClassInfo :: subclassesFor ( Folder :: class ) ) ; $ classes = ClassInf...
Looks for files used in system and create where clause which contains all ID s of files .
46,915
public function onBeforeHTTPError404 ( $ request ) { $ params = preg_split ( '|/+|' , $ request -> getURL ( ) ) ; $ cleanURL = trim ( Director :: makeRelative ( $ request -> getURL ( false ) ) , '/' ) ; $ getvars = $ request -> getVars ( ) ; unset ( $ getvars [ 'url' ] ) ; $ page = self :: find_old_page ( $ params ) ; ...
On every URL that generates a 404 we ll capture it here and see if we can find an old URL that it should be redirecting to .
46,916
public function editorInternalLink ( ) { $ showLinkText = $ this -> getOwner ( ) -> getRequest ( ) -> getVar ( 'requireLinkText' ) ; $ factory = InternalLinkFormFactory :: singleton ( ) ; return $ factory -> getForm ( $ this -> getOwner ( ) , "editorInternalLink" , [ 'RequireLinkText' => isset ( $ showLinkText ) ] ) ; ...
Form for inserting internal link pages
46,917
public function index ( HTTPRequest $ request ) { $ page = $ this -> data ( ) ; if ( ! $ this -> getResponse ( ) -> isFinished ( ) && $ link = $ page -> redirectionLink ( ) ) { $ this -> redirect ( $ link , 301 ) ; } return parent :: handleAction ( $ request , 'handleIndex' ) ; }
Check we don t already have a redirect code set
46,918
public function VersionsForm ( ) { $ id = $ this -> currentPageID ( ) ; $ page = $ this -> getRecord ( $ id ) ; $ versionsHtml = '' ; $ action = $ this -> getRequest ( ) -> param ( 'Action' ) ; $ versionID = $ this -> getRequest ( ) -> param ( 'VersionID' ) ; $ otherVersionID = $ this -> getRequest ( ) -> param ( 'Othe...
Version select form . Main interface between selecting versions to view and comparing multiple versions .
46,919
public function transformReadonly ( FieldList $ fields ) { foreach ( $ fields -> dataFields ( ) as $ field ) { if ( $ field instanceof HiddenField ) { continue ; } $ newField = $ field -> castedCopy ( HTMLReadonlyField :: class ) ; $ fields -> replaceField ( $ field -> getName ( ) , $ newField ) ; } return $ fields ; }
Replace all data fields with HTML readonly fields to display diff
46,920
public function Link ( $ action = null ) { $ link = $ this -> redirectionLink ( ) ; if ( $ link ) { return $ link ; } else { return $ this -> regularLink ( $ action ) ; } }
Return the the link that should be used for this redirector page in navigation etc . If the redirectorpage has been appropriately configured then it will return the redirection destination to prevent unnecessary 30x redirections . However if it s misconfigured then it will return a link to itself which will then displa...
46,921
public function redirectionLink ( ) { if ( $ this -> RedirectionType == 'External' ) { return $ this -> ExternalURL ? : null ; } $ linkTo = $ this -> LinkToID ? SiteTree :: get ( ) -> byID ( $ this -> LinkToID ) : null ; if ( empty ( $ linkTo ) ) { return null ; } if ( $ this -> ID == $ linkTo -> ID ) { return null ; }...
Return the link that we should redirect to . Only return a value if there is a legal redirection destination .
46,922
public function isArchived ( ) { $ record = $ this -> record ; if ( ! $ record -> hasExtension ( Versioned :: class ) || ! $ record -> hasStages ( ) ) { return false ; } if ( ! isset ( $ record -> _cached_isArchived ) ) { $ baseClass = $ record -> baseClass ( ) ; $ currentDraft = Versioned :: get_by_stage ( $ baseClass...
Counts as archived if the current record is a different version from both live and draft .
46,923
public function sourceRecords ( $ params = null ) { return SiteTree :: get ( ) -> exclude ( 'ClassName' , RedirectorPage :: class ) -> filter ( 'Content' , [ null , '' , '<p></p>' , '<p>&nbsp;</p>' ] ) -> sort ( 'Title' ) ; }
Gets the source records
46,924
public static function get_all_filters ( ) { $ filters = ClassInfo :: subclassesFor ( CMSSiteTreeFilter :: class ) ; array_shift ( $ filters ) ; $ filterMap = array ( ) ; foreach ( $ filters as $ filter ) { $ filterMap [ $ filter ] = $ filter :: title ( ) ; } uasort ( $ filterMap , function ( $ a , $ b ) { return ( $ a...
Returns a sorted array of all implementators of CMSSiteTreeFilter suitable for use in a dropdown .
46,925
protected function applyDefaultFilters ( $ query ) { $ sng = SiteTree :: singleton ( ) ; foreach ( $ this -> params as $ name => $ val ) { if ( empty ( $ val ) ) { continue ; } switch ( $ name ) { case 'Term' : $ query = $ query -> filterAny ( array ( 'URLSegment:PartialMatch' => $ val , 'Title:PartialMatch' => $ val ,...
Applies the default filters to a specified DataList of pages
46,926
protected function mapIDs ( $ pages ) { $ ids = array ( ) ; if ( $ pages ) { foreach ( $ pages as $ page ) { $ ids [ ] = array ( 'ID' => $ page -> ID , 'ParentID' => $ page -> ParentID ) ; } } return $ ids ; }
Maps a list of pages to an array of associative arrays with ID and ParentID keys
46,927
public function createDataCollection ( string $ resourceFolder ) : DataCollection { $ this -> logger -> debug ( 'add platform file' ) ; $ this -> addPlatformsFile ( $ resourceFolder . '/platforms.json' ) ; $ this -> logger -> debug ( 'add engine file' ) ; $ this -> addEnginesFile ( $ resourceFolder . '/engines.json' ) ...
Create and populate a data collection object from a resource folder
46,928
public function addPlatformsFile ( string $ filename ) : void { $ decodedFileContent = $ this -> loadFile ( $ filename ) ; $ platformFactory = new PlatformFactory ( ) ; foreach ( array_keys ( $ decodedFileContent ) as $ platformName ) { $ platformName = ( string ) $ platformName ; $ platformData = $ decodedFileContent ...
Load a platforms . json file and parse it into the platforms data array validates these data and creates a collection of Platform objects
46,929
public function addEnginesFile ( string $ filename ) : void { $ decodedFileContent = $ this -> loadFile ( $ filename ) ; $ engineFactory = new EngineFactory ( ) ; foreach ( array_keys ( $ decodedFileContent ) as $ engineName ) { $ engineName = ( string ) $ engineName ; $ engineData = $ decodedFileContent [ $ engineName...
Load a engines . json file and parse it into the platforms data array validates these data and creates a collection of Engine objects
46,930
public function addBrowserFile ( string $ filename ) : void { $ decodedFileContent = $ this -> loadFile ( $ filename ) ; Assertion :: isArray ( $ decodedFileContent , 'required "browsers" structure has to be an array' ) ; $ browserFactory = new BrowserFactory ( ) ; foreach ( array_keys ( $ decodedFileContent ) as $ bro...
Load a browsers . json file and parse it into the browsers data array validates these data and creates a collection of Browser objects
46,931
public function addDevicesFile ( string $ filename ) : void { $ decodedFileContent = $ this -> loadFile ( $ filename ) ; foreach ( $ decodedFileContent as $ deviceName => $ deviceData ) { $ this -> collection -> addDevice ( $ deviceName , $ this -> deviceFactory -> build ( $ deviceData , $ deviceName ) ) ; } }
Load a devices . json file and parse it into the platforms data array validates these data and creates a collection of Device objects
46,932
public function addSourceFile ( string $ filename ) : void { $ divisionData = $ this -> loadFile ( $ filename ) ; $ this -> divisionDataValidator -> validate ( $ divisionData , $ filename , $ this -> allDivisions , false ) ; $ this -> collection -> addDivision ( $ this -> divisionFactory -> build ( $ divisionData , $ f...
Load a JSON file parse it s JSON to arrays validates these data and creates a collection of Division objects
46,933
private function parseDivision ( Division $ division , string $ divisionName ) : \ Generator { $ i = 0 ; foreach ( $ division -> getUserAgents ( ) as $ uaData ) { $ this -> resetPatternId ( ) ; $ this -> patternId [ 'division' ] = $ division -> getFileName ( ) ; $ this -> patternId [ 'useragent' ] = $ i ; foreach ( $ t...
parses and expands a single division
46,934
private function getPatternId ( ) : string { return sprintf ( '%s::u%d::c%d::d%s::p%s' , $ this -> patternId [ 'division' ] , $ this -> patternId [ 'useragent' ] , $ this -> patternId [ 'child' ] , $ this -> patternId [ 'device' ] , $ this -> patternId [ 'platform' ] ) ; }
Builds and returns the string pattern id from the array components
46,935
public function trimProperty ( string $ propertyValue ) { switch ( $ propertyValue ) { case 'true' : $ propertyValue = true ; break ; case 'false' : $ propertyValue = false ; break ; default : $ propertyValue = trim ( $ propertyValue ) ; break ; } return $ propertyValue ; }
trims the value of a property and converts the string values true and false to boolean
46,936
public function run ( string $ buildVersion , bool $ createZipFile = true ) : void { $ this -> logger -> info ( 'Resource folder: ' . $ this -> resourceFolder . '' ) ; $ this -> logger -> info ( 'Build folder: ' . $ this -> buildFolder . '' ) ; Helper \ BuildHelper :: run ( $ buildVersion , $ this -> resourceFolder , $...
Entry point for generating builds for a specified version
46,937
public function create ( OutputInterface $ output ) : LoggerInterface { $ logger = new Logger ( 'browscap' ) ; $ consoleLogger = new ConsoleLogger ( $ output ) ; $ psrHandler = new PsrHandler ( $ consoleLogger ) ; $ logger -> pushHandler ( $ psrHandler ) ; $ logger -> pushHandler ( new ErrorLogHandler ( ErrorLogHandler...
creates an instance of a PSR - 3 Logger
46,938
public function validate ( array $ divisionData , string $ filename , array & $ allDivisions = [ ] , bool $ isCore = false ) : void { Assertion :: keyExists ( $ divisionData , 'division' , 'required attibute "division" is missing in File ' . $ filename ) ; Assertion :: string ( $ divisionData [ 'division' ] , 'required...
valdates the structure of a division
46,939
public function checkDeviceProperties ( array $ properties , string $ message ) : void { if ( array_key_exists ( 'Device_Name' , $ properties ) || array_key_exists ( 'Device_Maker' , $ properties ) || array_key_exists ( 'Device_Type' , $ properties ) || array_key_exists ( 'Device_Pointing_Method' , $ properties ) || ar...
checks if device properties are set inside a properties array
46,940
public function checkBrowserProperties ( array $ properties , string $ message ) : void { if ( array_key_exists ( 'Browser' , $ properties ) || array_key_exists ( 'Browser_Type' , $ properties ) || array_key_exists ( 'Browser_Maker' , $ properties ) || array_key_exists ( 'isSyndicationReader' , $ properties ) || array_...
checks if browser properties are set inside a properties array
46,941
public function checkDeprecatedProperties ( array $ properties , string $ message ) : void { if ( array_key_exists ( 'AolVersion' , $ properties ) || array_key_exists ( 'MinorVer' , $ properties ) || array_key_exists ( 'MajorVer' , $ properties ) ) { throw new \ LogicException ( $ message ) ; } }
checks if deprecated properties are set inside a properties array
46,942
public function getPropertyType ( string $ propertyName ) : string { $ stringProperties = [ 'Comment' => 1 , 'Browser' => 1 , 'Browser_Maker' => 1 , 'Browser_Modus' => 1 , 'Browser_Type' => 1 , 'Platform' => 1 , 'Platform_Name' => 1 , 'Platform_Description' => 1 , 'Device_Name' => 1 , 'Platform_Maker' => 1 , 'Device_Co...
Get the type of a property
46,943
public function isLiteModeProperty ( string $ propertyName , WriterInterface $ writer ) : bool { $ outputProperties = [ 'Parent' => 1 , 'Comment' => 1 , 'Browser' => 1 , 'Platform' => 1 , 'Version' => 1 , 'isMobileDevice' => 1 , 'isTablet' => 1 , 'Device_Type' => 1 , ] ; if ( isset ( $ outputProperties [ $ propertyName...
Determine if the specified property is an property that should be included in the all versions of the files
46,944
public function isStandardModeProperty ( string $ propertyName , WriterInterface $ writer ) : bool { $ outputProperties = [ 'MajorVer' => 1 , 'MinorVer' => 1 , 'Crawler' => 1 , 'Browser_Maker' => 1 , 'Device_Pointing_Method' => 1 , ] ; if ( isset ( $ outputProperties [ $ propertyName ] ) ) { return true ; } if ( in_arr...
Determine if the specified property is an property that should be included in the standard or full versions of the files only
46,945
public function isDeprecatedProperty ( string $ propertyName ) : bool { $ deprecatedProperties = [ 'Win16' => 1 , 'Win32' => 1 , 'Win64' => 1 , 'isMobileDevice' => 1 , 'isTablet' => 1 , 'Crawler' => 1 , 'AolVersion' => 1 , 'MajorVer' => 1 , 'MinorVer' => 1 , ] ; if ( isset ( $ deprecatedProperties [ $ propertyName ] ) ...
Determine if the specified property is marked as deprecated
46,946
public function renderSectionFooter ( string $ sectionName = '' ) : void { foreach ( $ this -> writers as $ writer ) { $ writer -> renderSectionFooter ( $ sectionName ) ; } }
renders the footer for a section
46,947
public function setDefaultBrowser ( Division $ division ) : void { $ this -> defaultBrowser = $ division ; $ this -> divisionsHaveBeenSorted = false ; }
Load the file for the default browser
46,948
public function getPlatform ( string $ platform ) : Platform { if ( ! array_key_exists ( $ platform , $ this -> platforms ) ) { throw new \ OutOfBoundsException ( 'Platform "' . $ platform . '" does not exist in data' ) ; } return $ this -> platforms [ $ platform ] ; }
Get a single platform data array
46,949
public function getBrowser ( string $ browser ) : Browser { if ( ! array_key_exists ( $ browser , $ this -> browsers ) ) { throw new \ OutOfBoundsException ( 'Browser "' . $ browser . '" does not exist in data' ) ; } return $ this -> browsers [ $ browser ] ; }
Get a single browser data array
46,950
public function getVersionParts ( string $ version ) : array { $ dots = explode ( '.' , $ version , 2 ) ; $ majorVer = $ dots [ 0 ] ; $ minorVer = ( isset ( $ dots [ 1 ] ) ? $ dots [ 1 ] : '0' ) ; return [ $ majorVer , $ minorVer ] ; }
splits a version into the major and the minor version
46,951
public function replace ( string $ value , string $ majorVer , string $ minorVer ) : string { return str_replace ( [ '#MAJORVER#' , '#MINORVER#' ] , [ $ majorVer , $ minorVer ] , $ value ) ; }
Render the property of a single User Agent and replaces version placeholders
46,952
public function process ( array $ coveredIds ) : void { $ this -> setCoveredPatternIds ( $ coveredIds ) ; $ finder = new Finder ( ) ; $ finder -> files ( ) ; $ finder -> name ( '*.json' ) ; $ finder -> ignoreDotFiles ( true ) ; $ finder -> ignoreVCS ( true ) ; $ finder -> sortByName ( ) ; $ finder -> ignoreUnreadableDi...
Process the directory of JSON files using the collected pattern ids
46,953
public function write ( string $ fileName ) : void { file_put_contents ( $ fileName , str_replace ( '[]' , '{}' , ( string ) json_encode ( $ this -> coverage , JSON_UNESCAPED_SLASHES ) ) ) ; }
Write the coverage data in JSON format to specified filename
46,954
public function processFile ( string $ file , string $ contents , array $ coveredIds ) : array { $ this -> fileCoverage = [ 'path' => $ file , 'statementMap' => [ ] , 'fnMap' => [ ] , 'branchMap' => [ ] , 's' => [ ] , 'b' => [ ] , 'f' => [ ] , ] ; $ this -> fileLines = explode ( "\n" , $ contents ) ; $ this -> fileCove...
Process an individual file for coverage data using covered ids
46,955
private function getLocationCoordinates ( Lexer $ lexer , bool $ end = false , string $ content = '' ) : array { $ lineNumber = $ lexer -> yylineno ; $ lineContent = $ this -> fileLines [ $ lineNumber ] ; if ( '' === $ content ) { $ content = $ lexer -> yytext ; } $ position = mb_strpos ( $ lineContent , $ content ) ; ...
Builds the location object for the current position in the JSON file
46,956
private function handleJsonRoot ( Lexer $ lexer ) : void { do { $ code = $ lexer -> lex ( ) ; if ( self :: JSON_OBJECT_START === $ code ) { $ code = $ this -> handleJsonDivision ( $ lexer ) ; } } while ( self :: JSON_EOF !== $ code ) ; }
JSON file processing entry point
46,957
private function handleUseragentGroup ( Lexer $ lexer ) : int { $ useragentPosition = 0 ; do { $ code = $ lexer -> lex ( ) ; if ( self :: JSON_OBJECT_START === $ code ) { $ code = $ this -> handleUseragentBlock ( $ lexer , $ useragentPosition ) ; ++ $ useragentPosition ; } } while ( self :: JSON_ARRAY_END !== $ code ) ...
Processes the userAgents array
46,958
private function handleUseragentBlock ( Lexer $ lexer , int $ useragentPosition ) : int { $ enterChildGroup = false ; do { $ code = $ lexer -> lex ( ) ; if ( self :: JSON_STRING === $ code && 'children' === $ lexer -> yytext ) { $ enterChildGroup = true ; } elseif ( self :: JSON_ARRAY_START === $ code && true === $ ent...
Processes each userAgent object in the userAgents array
46,959
private function handleChildrenGroup ( Lexer $ lexer , int $ useragentPosition ) : int { $ childPosition = 0 ; do { $ code = $ lexer -> lex ( ) ; if ( self :: JSON_OBJECT_START === $ code ) { $ code = $ this -> handleChildBlock ( $ lexer , $ useragentPosition , $ childPosition ) ; ++ $ childPosition ; } } while ( self ...
Processes the children array of a userAgent object
46,960
private function handleChildBlock ( Lexer $ lexer , int $ useragentPosition , int $ childPosition ) : int { $ enterPlatforms = false ; $ enterDevices = false ; $ collectMatch = false ; $ functionStart = $ this -> getLocationCoordinates ( $ lexer ) ; $ functionDeclaration = [ ] ; do { $ code = $ lexer -> lex ( ) ; switc...
Processes each child object in the children array
46,961
private function handleDeviceBlock ( Lexer $ lexer , int $ useragentPosition , int $ childPosition ) : int { $ capturedKey = false ; $ sawColon = false ; $ branchStart = $ this -> getLocationCoordinates ( $ lexer ) ; $ branchLocations = [ ] ; $ branchCoverage = [ ] ; do { $ code = $ lexer -> lex ( ) ; if ( self :: JSON...
Process the devices has in the child object
46,962
private function handlePlatformBlock ( Lexer $ lexer , int $ useragentPosition , int $ childPosition ) : int { $ branchStart = $ this -> getLocationCoordinates ( $ lexer ) ; $ branchLocations = [ ] ; $ branchCoverage = [ ] ; do { $ code = $ lexer -> lex ( ) ; if ( self :: JSON_STRING === $ code ) { $ branchLocations [ ...
Processes the platforms hash in the child object
46,963
private function ignoreObjectBlock ( Lexer $ lexer ) : int { do { $ code = $ lexer -> lex ( ) ; if ( self :: JSON_OBJECT_START === $ code ) { $ this -> ignoreObjectBlock ( $ lexer ) ; } } while ( self :: JSON_OBJECT_END !== $ code ) ; return $ lexer -> lex ( ) ; }
Processes JSON object block that isn t needed for coverage data
46,964
private function collectFunction ( array $ start , array $ end , array $ declaration , int $ coverage = 0 ) : void { $ this -> fileCoverage [ 'fnMap' ] [ ] = [ 'name' => '(anonymous_' . $ this -> funcCount . ')' , 'decl' => $ declaration , 'loc' => [ 'start' => $ start , 'end' => $ end ] , ] ; $ this -> fileCoverage [ ...
Collects and stores a function s location information as well as any passed in coverage counts
46,965
private function collectBranch ( array $ start , array $ end , array $ locations , array $ coverage = [ ] ) : void { $ this -> fileCoverage [ 'branchMap' ] [ ] = [ 'type' => 'switch' , 'locations' => $ locations , 'loc' => [ 'start' => $ start , 'end' => $ end ] , ] ; $ this -> fileCoverage [ 'b' ] [ ] = $ coverage ; $...
Collects and stores a branch s location information as well as any coverage counts
46,966
private function collectStatement ( array $ start , array $ end , int $ coverage = 0 ) : void { $ this -> fileCoverage [ 'statementMap' ] [ ] = [ 'start' => $ start , 'end' => $ end , ] ; $ this -> fileCoverage [ 's' ] [ ] = $ coverage ; }
Collects and stores a statement s location information as well as any coverage counts
46,967
private function groupIdsByFile ( array $ ids ) : array { $ covered = [ ] ; foreach ( $ ids as $ id ) { $ file = mb_substr ( $ id , 0 , ( int ) mb_strpos ( $ id , '::' ) ) ; if ( ! isset ( $ covered [ $ file ] ) ) { $ covered [ $ file ] = [ ] ; } $ covered [ $ file ] [ ] = mb_substr ( $ id , mb_strpos ( $ id , '::' ) +...
Groups pattern ids by their filename prefix
46,968
private function getCoverageCount ( string $ id , array $ covered ) : int { $ id = str_replace ( '\/' , '/' , $ id ) ; [ $ u , $ c , $ d , $ p ] = explode ( '::' , $ id ) ; $ u = preg_quote ( mb_substr ( $ u , 1 ) , '/' ) ; $ c = preg_quote ( mb_substr ( $ c , 1 ) , '/' ) ; $ p = preg_quote ( mb_substr ( $ p , 1 ) , '/...
Counts number of times given generated pattern id is covered by patterns ids collected during tests
46,969
public function fileStart ( ) : void { if ( $ this -> isSilent ( ) ) { return ; } fwrite ( $ this -> file , '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL ) ; fwrite ( $ this -> file , '<browsercaps>' . PHP_EOL ) ; }
Generates a start sequence for the output file
46,970
public function acknowledge ( AMQPMessage $ message ) { $ message -> delivery_info [ 'channel' ] -> basic_ack ( $ message -> delivery_info [ 'delivery_tag' ] ) ; if ( $ message -> body === 'quit' ) { $ message -> delivery_info [ 'channel' ] -> basic_cancel ( $ message -> delivery_info [ 'consumer_tag' ] ) ; } }
Acknowledges a message
46,971
public function applyCode ( $ code , $ callback = null ) { try { if ( $ promocode = Promocodes :: check ( $ code ) ) { if ( $ promocode -> users ( ) -> wherePivot ( config ( 'promocodes.related_pivot_key' ) , $ this -> id ) -> exists ( ) ) { throw new AlreadyUsedException ; } $ promocode -> users ( ) -> attach ( $ this...
Apply promocode to user and get callback .
46,972
public function output ( $ amount = 1 ) { $ collection = [ ] ; for ( $ i = 1 ; $ i <= $ amount ; $ i ++ ) { $ random = $ this -> generate ( ) ; while ( ! $ this -> validate ( $ collection , $ random ) ) { $ random = $ this -> generate ( ) ; } array_push ( $ collection , $ random ) ; } return $ collection ; }
Generates promocodes as many as you wish .
46,973
public function create ( $ amount = 1 , $ reward = null , array $ data = [ ] , $ expires_in = null , $ is_disposable = false ) { $ records = [ ] ; foreach ( $ this -> output ( $ amount ) as $ code ) { $ records [ ] = [ 'code' => $ code , 'reward' => $ reward , 'data' => json_encode ( $ data ) , 'expires_at' => $ expire...
Save promocodes into database Successful insert returns generated promocodes Fail will return empty collection .
46,974
public function createDisposable ( $ amount = 1 , $ reward = null , array $ data = [ ] , $ expires_in = null ) { return $ this -> create ( $ amount , $ reward , $ data , $ expires_in , true ) ; }
Save one - time use promocodes into database Successful insert returns generated promocodes Fail will return empty collection .
46,975
public function check ( $ code ) { $ promocode = Promocode :: byCode ( $ code ) -> first ( ) ; if ( $ promocode === null ) { throw new InvalidPromocodeException ; } if ( $ promocode -> isExpired ( ) || ( $ promocode -> isDisposable ( ) && $ promocode -> users ( ) -> exists ( ) ) ) { return false ; } return $ promocode ...
Check promocode in database if it is valid .
46,976
public function apply ( $ code ) { if ( ! auth ( ) -> check ( ) ) { throw new UnauthenticatedException ; } try { if ( $ promocode = $ this -> check ( $ code ) ) { if ( $ this -> isSecondUsageAttempt ( $ promocode ) ) { throw new AlreadyUsedException ; } $ promocode -> users ( ) -> attach ( auth ( ) -> id ( ) , [ 'promo...
Apply promocode to user that it s used from now .
46,977
public function disable ( $ code ) { $ promocode = Promocode :: byCode ( $ code ) -> first ( ) ; if ( $ promocode === null ) { throw new InvalidPromocodeException ; } $ promocode -> expires_at = Carbon :: now ( ) ; return $ promocode -> save ( ) ; }
Expire code as it won t usable anymore .
46,978
public function clearRedundant ( ) { Promocode :: all ( ) -> each ( function ( Promocode $ promocode ) { if ( $ promocode -> isExpired ( ) || ( $ promocode -> isDisposable ( ) && $ promocode -> users ( ) -> exists ( ) ) ) { $ promocode -> users ( ) -> detach ( ) ; $ promocode -> delete ( ) ; } } ) ; }
Clear all expired and used promotion codes that can not be used anymore .
46,979
private function generate ( ) { $ characters = config ( 'promocodes.characters' ) ; $ mask = config ( 'promocodes.mask' ) ; $ promocode = '' ; $ random = [ ] ; for ( $ i = 1 ; $ i <= $ this -> length ; $ i ++ ) { $ character = $ characters [ rand ( 0 , strlen ( $ characters ) - 1 ) ] ; $ random [ ] = $ character ; } sh...
Here will be generated single code using your parameters from config .
46,980
public function isSecondUsageAttempt ( Promocode $ promocode ) { return $ promocode -> users ( ) -> wherePivot ( config ( 'promocodes.related_pivot_key' , 'user_id' ) , auth ( ) -> id ( ) ) -> exists ( ) ; }
Check if user is trying to apply code again .
46,981
public function apply ( object $ object , ReflectionProperty $ reflectionProperty , callable $ objectCopier ) : void { $ reflectionProperty -> setAccessible ( true ) ; $ oldCollection = $ reflectionProperty -> getValue ( $ object ) ; $ newCollection = $ oldCollection -> map ( function ( $ item ) use ( $ objectCopier ) ...
Copies the object property doctrine collection .
46,982
public function apply ( object $ object , ReflectionProperty $ reflectionProperty , callable $ objectCopier ) : void { $ reflectionProperty -> setAccessible ( true ) ; $ reflectionProperty -> setValue ( $ object , null ) ; }
Sets the object property to null .
46,983
public function matches ( object $ object , ReflectionProperty $ reflectionProperty ) : bool { return $ reflectionProperty -> getName ( ) === $ this -> property ; }
Matches a property by its name .
46,984
public function apply ( object $ object , ReflectionProperty $ reflectionProperty , callable $ objectCopier ) : void { $ reflectionProperty -> setAccessible ( true ) ; $ value = ( $ this -> callback ) ( $ reflectionProperty -> getValue ( $ object ) ) ; $ reflectionProperty -> setValue ( $ object , $ value ) ; }
Replaces the object property by the result of the callback called with the object property .
46,985
protected function readBytes ( $ bytes ) { $ data = '' ; $ chunk = null ; while ( $ bytes > 0 && false !== ( $ chunk = \ fread ( $ this -> stream , $ bytes ) ) ) { $ bytes -= \ strlen ( $ chunk ) ; $ data .= $ chunk ; } if ( false === $ chunk ) { throw new RuntimeException ( 'Could not read from stream' ) ; } return $ ...
Network safe \ fread wrapper
46,986
protected function parseUrl ( $ url ) { $ parsed = \ parse_url ( $ url ) ; if ( false === $ parsed ) { throw new MalformedUrlException ( $ url ) ; } $ server = \ array_replace ( [ 'scheme' => 'http' , 'host' => 'localhost' , 'query' => [ ] ] , $ parsed ) ; if ( ! isset ( $ server [ 'port' ] ) ) { $ server [ 'port' ] = ...
Parse an url into parts we may expect
46,987
protected function maskData ( $ data ) { $ masked = '' ; $ data = \ str_split ( $ data ) ; $ key = \ str_split ( $ this -> maskKey ) ; foreach ( $ data as $ i => $ letter ) { $ masked .= $ letter ^ $ key [ $ i % 4 ] ; } return $ masked ; }
Mask a data according to the current mask key
46,988
public function initialize ( ) { try { $ this -> logger -> debug ( 'Connecting to the websocket' ) ; $ this -> engine -> connect ( ) ; $ this -> logger -> debug ( 'Connected to the server' ) ; $ this -> isConnected = true ; } catch ( SocketException $ e ) { $ this -> logger -> error ( 'Could not connect to the server' ...
Connects to the websocket
46,989
public function emit ( $ event , array $ args ) { $ this -> logger -> debug ( 'Sending a new message' , [ 'event' => $ event , 'args' => $ args ] ) ; $ this -> engine -> emit ( $ event , $ args ) ; return $ this ; }
Emits a message through the engine
46,990
public function needsHeartbeat ( ) { if ( 0 < $ this -> timeouts [ 'interval' ] && \ microtime ( true ) > ( $ this -> timeouts [ 'interval' ] + $ this -> heartbeat - 5 ) ) { $ this -> heartbeat = \ microtime ( true ) ; return true ; } return false ; }
Checks whether a new heartbeat is necessary and does a new heartbeat if it is the case
46,991
public function tableize ( string $ word ) : string { $ tableized = preg_replace ( '~(?<=\\w)([A-Z])~u' , '_$1' , $ word ) ; if ( $ tableized === null ) { throw new RuntimeException ( sprintf ( 'preg_replace returned null for value "%s"' , $ word ) ) ; } return mb_strtolower ( $ tableized ) ; }
Converts a word into the format for a Doctrine table name . Converts ModelName to model_name .
46,992
public function urlize ( string $ string ) : string { $ unaccented = $ this -> unaccent ( $ string ) ; if ( function_exists ( 'mb_strtolower' ) ) { $ lowered = mb_strtolower ( $ unaccented ) ; } else { $ lowered = strtolower ( $ unaccented ) ; } $ replacements = [ '/\W/' => ' ' , '/([A-Z]+)([A-Z][a-z])/' => '\1_\2' , '...
Convert any passed string to a url friendly string . Converts My first blog post to my - first - blog - post
46,993
public static function semanticalErrorConstants ( $ identifier , $ context = null ) { return self :: semanticalError ( sprintf ( "Couldn't find constant %s%s." , $ identifier , $ context ? ', ' . $ context : '' ) ) ; }
Creates a new AnnotationException describing a constant semantical error .
46,994
public static function attributeTypeError ( $ attributeName , $ annotationName , $ context , $ expected , $ actual ) { return self :: typeError ( sprintf ( 'Attribute "%s" of @%s declared on %s expects %s, but got %s.' , $ attributeName , $ annotationName , $ context , $ expected , is_object ( $ actual ) ? 'an instance...
Creates a new AnnotationException describing an type error of an attribute .
46,995
public static function requiredError ( $ attributeName , $ annotationName , $ context , $ expected ) { return self :: typeError ( sprintf ( 'Attribute "%s" of @%s declared on %s expects %s. This value should not be null.' , $ attributeName , $ annotationName , $ context , $ expected ) ) ; }
Creates a new AnnotationException describing an required error of an attribute .
46,996
public function next ( $ docCommentIsComment = TRUE ) { for ( $ i = $ this -> pointer ; $ i < $ this -> numTokens ; $ i ++ ) { $ this -> pointer ++ ; if ( $ this -> tokens [ $ i ] [ 0 ] === T_WHITESPACE || $ this -> tokens [ $ i ] [ 0 ] === T_COMMENT || ( $ docCommentIsComment && $ this -> tokens [ $ i ] [ 0 ] === T_DO...
Gets the next non whitespace and non comment token .
46,997
public function parseUseStatements ( $ namespaceName ) { $ statements = [ ] ; while ( ( $ token = $ this -> next ( ) ) ) { if ( $ token [ 0 ] === T_USE ) { $ statements = array_merge ( $ statements , $ this -> parseUseStatement ( ) ) ; continue ; } if ( $ token [ 0 ] !== T_NAMESPACE || $ this -> parseNamespace ( ) != $...
Gets all use statements .
46,998
public function parseNamespace ( ) { $ name = '' ; while ( ( $ token = $ this -> next ( ) ) && ( $ token [ 0 ] === T_STRING || $ token [ 0 ] === T_NS_SEPARATOR ) ) { $ name .= $ token [ 1 ] ; } return $ name ; }
Gets the namespace .
46,999
public function parse ( $ input , $ context = '' ) { $ pos = $ this -> findInitialTokenPosition ( $ input ) ; if ( $ pos === null ) { return [ ] ; } $ this -> context = $ context ; $ this -> lexer -> setInput ( trim ( substr ( $ input , $ pos ) , '* /' ) ) ; $ this -> lexer -> moveNext ( ) ; return $ this -> Annotation...
Parses the given docblock string for annotations .