idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
300
public static function forMethod ( string $ class , string $ method , array $ classParameters = [ ] , array $ methodParameters = [ ] ) : RouteMatch { try { $ controller = new \ ReflectionMethod ( $ class , $ method ) ; } catch ( \ ReflectionException $ e ) { throw RoutingException :: invalidControllerClassMethod ( $ e ...
Returns a RouteMatch for the given class and method .
301
public static function forFunction ( $ function , array $ functionParameters = [ ] ) : RouteMatch { try { $ controller = new \ ReflectionFunction ( $ function ) ; } catch ( \ ReflectionException $ e ) { throw RoutingException :: invalidControllerFunction ( $ e , $ function ) ; } return new self ( $ controller , [ ] , $...
Returns a RouteMatch for the given function or closure .
302
public function withClassParameters ( array $ parameters ) : RouteMatch { $ routeMatch = clone $ this ; $ routeMatch -> classParameters = $ parameters + $ this -> classParameters ; return $ routeMatch ; }
Returns a copy of this RouteMatch with additional class parameters .
303
public function withFunctionParameters ( array $ parameters ) : RouteMatch { $ routeMatch = clone $ this ; $ routeMatch -> functionParameters = $ parameters + $ this -> functionParameters ; return $ routeMatch ; }
Returns a copy of this RouteMatch with additional function parameters .
304
protected function getConfigFromInput ( ) { $ config_file_parse [ 'separator' ] = $ this -> form_input [ 'separator' ] ; $ config_file_parse [ 'file_path' ] = $ this -> form_input [ 'file_csv' ] -> getRealPath ( ) ; $ config [ "file_parse" ] = $ config_file_parse ; $ config_builder [ 'first_line_headers' ] = ( $ this -...
get the config from form input
305
private function assertValidClientID ( $ value , $ fromPacket ) { if ( strlen ( $ value ) > 23 ) { $ this -> throwException ( sprintf ( 'Expected client id shorter than 24 bytes but got "%s".' , $ value ) , $ fromPacket ) ; } if ( $ value !== '' && ! ctype_alnum ( $ value ) ) { $ this -> throwException ( sprintf ( 'Exp...
Asserts that a client id is shorter than 24 bytes and only contains characters 0 - 9 a - z or A - Z .
306
public function fill ( array $ input , bool $ force = false ) { foreach ( $ input as $ key => $ value ) { if ( $ force ) { $ this -> setAttribute ( $ key , $ value ) ; continue ; } if ( ( empty ( $ this -> fillable ) || in_array ( $ key , $ this -> fillable ) ) && ! in_array ( $ key , $ this -> guarded ) ) { $ this -> ...
Set the model attributes using an array .
307
protected function hasMutatorMethod ( $ key , $ prefix ) { $ method = $ this -> buildMutatorMethod ( $ key , $ prefix ) ; return method_exists ( $ this , $ method ) ; }
Verify if model has a mutator method defined .
308
private function handleHttpException ( HttpException $ exception , Request $ request ) : Response { $ response = new Response ( ) ; $ response -> setContent ( $ exception ) ; $ response -> setStatusCode ( $ exception -> getStatusCode ( ) ) ; $ response -> setHeaders ( $ exception -> getHeaders ( ) ) ; $ response -> set...
Converts an HttpException to a Response .
309
private function handleUncaughtException ( \ Throwable $ exception , Request $ request ) : Response { $ httpException = new HttpInternalServerErrorException ( 'Uncaught exception' , $ exception ) ; return $ this -> handleHttpException ( $ httpException , $ request ) ; }
Wraps an uncaught exception in an HttpInternalServerErrorException and converts it to a Response .
310
private function route ( Request $ request ) : RouteMatch { foreach ( $ this -> routes as $ route ) { try { $ match = $ route -> match ( $ request ) ; } catch ( RoutingException $ e ) { throw new HttpNotFoundException ( $ e -> getMessage ( ) , $ e ) ; } if ( $ match !== null ) { if ( $ match instanceof RouteMatch ) { r...
Routes the given Request .
311
public static function nameCase ( $ string = '' , array $ options = [ ] ) { if ( $ string == '' ) return $ string ; self :: $ options = array_merge ( self :: $ options , $ options ) ; if ( self :: $ options [ 'lazy' ] && self :: skipMixed ( $ string ) ) return $ string ; $ string = self :: capitalize ( $ string ) ; $ s...
Main function for NameCase .
312
private static function capitalize ( $ string ) { $ string = mb_strtolower ( $ string ) ; $ string = mb_ereg_replace_callback ( '\b\w' , function ( $ matches ) { return mb_strtoupper ( $ matches [ 0 ] ) ; } , $ string ) ; $ string = mb_ereg_replace_callback ( '\'\w\b' , function ( $ matches ) { return mb_strtolower ( $...
Capitalize first letters .
313
private static function skipMixed ( $ string ) { $ firstLetterLower = $ string [ 0 ] == mb_strtolower ( $ string [ 0 ] ) ; $ allLowerOrUpper = ( mb_strtolower ( $ string ) == $ string || mb_strtoupper ( $ string ) == $ string ) ; return ! ( $ firstLetterLower || $ allLowerOrUpper ) ; }
Skip if string is mixed case .
314
private static function updateIrish ( $ string ) { if ( ! self :: $ options [ 'irish' ] ) return $ string ; if ( mb_ereg_match ( '.*?\bMac[A-Za-z]{2,}[^aciozj]\b' , $ string ) || mb_ereg_match ( '.*?\bMc' , $ string ) ) { $ string = self :: updateMac ( $ string ) ; } return mb_ereg_replace ( 'Macmurdo' , 'MacMurdo' , $...
Update for Irish names .
315
private static function fixConjunction ( $ string ) { if ( ! self :: $ options [ 'spanish' ] ) return $ string ; foreach ( self :: $ conjunctions as $ conjunction ) { $ string = mb_ereg_replace ( '\b' . $ conjunction . '\b' , mb_strtolower ( $ conjunction ) , $ string ) ; } return $ string ; }
Fix Spanish conjunctions .
316
private static function updateMac ( $ string ) { $ string = mb_ereg_replace_callback ( '\b(Ma?c)([A-Za-z]+)' , function ( $ matches ) { return $ matches [ 1 ] . mb_strtoupper ( mb_substr ( $ matches [ 2 ] , 0 , 1 ) ) . mb_substr ( $ matches [ 2 ] , 1 ) ; } , $ string ) ; foreach ( self :: $ exceptions as $ pattern => $...
Updates irish Mac & Mc .
317
public function reduce ( $ tolerance ) { $ this -> points = $ this -> _reduce ( $ this -> points , ( double ) $ tolerance ) ; return $ this -> points ; }
Public visible method to reduce points .
318
private function _reduce ( $ points , $ tolerance ) { $ distanceMax = $ index = 0 ; $ pointsEnd = key ( array_slice ( $ points , - 1 , 1 , true ) ) ; for ( $ i = 1 ; $ i < $ pointsEnd ; $ i ++ ) { $ distance = $ this -> shortestDistanceToSegment ( $ points [ $ i ] , $ points [ 0 ] , $ points [ $ pointsEnd ] ) ; if ( $ ...
Reduce points with Ramer - Douglas - Peucker algorithm .
319
public function reduce ( $ tolerance , $ lookAhead = null ) { if ( $ lookAhead ) { $ this -> lookAhead = ( int ) $ lookAhead ; } $ key = 0 ; $ endPoint = min ( $ this -> lookAhead , $ this -> lastKey ( ) ) ; do { if ( $ key + 1 == $ endPoint ) { if ( $ endPoint != $ this -> lastKey ( ) ) { $ key = $ endPoint ; $ endPoi...
Reduce points with Lang algorithm .
320
public function initializeState ( ) { if ( Session :: has ( $ this -> session_key ) ) { $ this -> setStateArray ( Session :: get ( $ this -> session_key ) ) ; } else { $ this -> resetState ( ) ; } return $ this -> getStateArray ( ) ; }
Initialize starting import state from session
321
public function setContent ( $ layout ) { $ content = '' ; $ state_array = $ this -> getStateArray ( ) ; foreach ( $ state_array as $ state_key => $ state ) { $ content .= $ state -> getForm ( ) ; } $ layout -> content = $ content ; }
Fill layout content with forms
322
public function processForm ( ) { $ current_state = $ this -> getCurrent ( ) ; $ executed_process = $ current_state -> processForm ( ) ; $ executed_next_state = $ this -> setNextState ( $ current_state , $ executed_process ) ; return ( $ executed_process && $ executed_next_state ) ; }
Process the current form
323
protected function setNextState ( $ current_state , $ executed ) { try { $ next_state = $ current_state -> getNextState ( ) ; } catch ( ClassNotFoundException $ e ) { Session :: put ( 'Errors' , new MessageBag ( array ( "Class" => "Class not found" ) ) ) ; return false ; } if ( $ executed ) { $ this -> append ( $ next_...
Set the next state
324
public function replaceCurrent ( $ value ) { $ key = $ this -> getLastKey ( ) ; if ( $ key >= 0 ) { $ this -> getStateArray ( ) -> offsetSet ( $ key , $ value ) ; } else { throw new NoDataException ; } }
Replace the current state
325
protected function & getAttributeValue ( string $ key ) { if ( isset ( $ this -> attributes [ $ key ] ) ) { return $ this -> attributes [ $ key ] ; } $ null = null ; return $ null ; }
Get a plain attribute
326
public function setAttributes ( array $ attributes ) : void { $ this -> checkAttributeAssignable ( array_keys ( $ attributes ) ) ; $ this -> setRawAttributes ( $ attributes ) ; }
Mass assignment of attributes
327
protected function recursiveToArray ( $ item ) { if ( is_array ( $ item ) ) { foreach ( $ item as & $ subitem ) { $ subitem = $ this -> recursiveToArray ( $ subitem ) ; } unset ( $ subitem ) ; return $ item ; } if ( $ item instanceof Arrayable ) { return $ item -> toArray ( ) ; } return $ item ; }
Recursively converts parameter to array
328
public function offsetSet ( $ offset , $ value ) { if ( ! $ this -> magicAssignment ) { throw new UnassignableAttributeException ( "Not allowed to assign value by magic with array access" ) ; } $ this -> checkAttributeAssignable ( $ offset ) ; $ this -> attributes [ $ offset ] = $ value ; }
Set the value for a given offset .
329
public function reduce ( $ tolerance ) { $ this -> _tolerance = $ tolerance ; $ sentinelKey = 0 ; while ( $ sentinelKey < $ this -> count ( ) - 1 ) { $ testKey = $ sentinelKey + 1 ; while ( $ sentinelKey < $ this -> count ( ) - 1 && $ this -> _isInTolerance ( $ sentinelKey , $ testKey ) ) { unset ( $ this -> points [ $...
Remove points with a distance under a given tolerance .
330
private function _isInTolerance ( $ basePointIndex , $ subjectPointIndex ) { $ radius = $ this -> distanceBetweenPoints ( $ this -> points [ $ basePointIndex ] , $ this -> points [ $ subjectPointIndex ] ) ; return $ radius < $ this -> _tolerance ; }
Helper method to ensure clean code .
331
public function createVote ( RatingInterface $ rating , UserInterface $ voter ) { $ class = $ this -> getClass ( ) ; $ vote = new $ class ; $ vote -> setRating ( $ rating ) ; $ vote -> setVoter ( $ voter ) ; $ this -> dispatcher -> dispatch ( DCSRatingEvents :: VOTE_CREATE , new Event \ VoteEvent ( $ vote ) ) ; return ...
Creates an empty vote instance
332
public function onDispatcherReady ( ) { if ( $ this -> dispatcher && $ this -> dispatcher -> isReady ( ) ) { $ context = $ this -> currentContext ; $ event = $ this -> currentEvent ; $ this -> dispatcher = null ; $ this -> currentContext = null ; $ this -> currentEvent = null ; $ this -> doCheckTransitions ( $ context ...
is called after dispatcher was executed .
333
public function setPathFilter ( $ path_filter ) { if ( empty ( $ path_filter ) ) { $ this -> clearPathFilter ( ) ; } else { $ this -> path_filter = $ path_filter . '/' ; } return $ this ; }
Set Path Filter
334
public function getIframeURL ( ) { $ info = $ this -> parseLink ( ) ; if ( ! $ info ) { return false ; } $ params = $ this -> Config ( ) -> get ( 'service' ) ; if ( $ this -> Service == 'Vimeo' ) { $ url = 'https://player.vimeo.com/video/' . $ this -> VideoID ; if ( $ params && ! empty ( $ params [ strtolower ( $ this ...
Return the iframe URL
335
public function iFrame ( $ maxwidth = '100%' , $ height = '56%' ) { $ url = $ this -> getIFrameURL ( ) ; if ( ! $ url ) { return false ; } if ( is_numeric ( $ maxwidth ) ) { $ maxwidth .= 'px' ; } if ( is_numeric ( $ height ) ) { $ height .= 'px' ; } return $ this -> customise ( [ 'URL' => $ url , 'MaxWidth' => $ maxwi...
Return populated iframe template
336
public function getTitle ( ) { if ( $ this -> getService ( ) == 'YouTube' ) { $ data = $ this -> getCachedJsonResponse ( 'https://www.youtube.com/oembed?url=http://www.youtube.com/watch?v=' . $ this -> VideoID . '&format=json' ) ; if ( $ data && ! empty ( $ data [ 'title' ] ) ) { return $ data [ 'title' ] ; } } if ( $ ...
Scrape Video information from hosting sites
337
public function thumbnailURL ( $ size = 'large' ) { if ( ! in_array ( $ size , [ 'large' , 'medium' , 'small' ] ) ) { return false ; } $ info = $ this -> parseLink ( ) ; $ service = $ this -> getService ( ) ; if ( ! $ info || ! $ service ) { return false ; } if ( $ service == 'YouTube' ) { if ( $ size == 'large' ) { $ ...
Return thumbnail URL
338
private function getCachedJsonResponse ( $ url ) { if ( ! class_exists ( 'GuzzleHttp\Client' ) ) { return false ; } $ cache_seconds = $ this -> config ( ) -> get ( 'cache_seconds' ) ; if ( ! is_numeric ( $ cache_seconds ) ) { $ cache_seconds = 604800 ; } $ cache = Injector :: inst ( ) -> get ( CacheInterface :: class ....
Return cached json response
339
private function parseLink ( ) { $ value = $ this -> RAW ( ) ; if ( ! $ value ) { return false ; } $ output = false ; if ( preg_match ( '/(https?:\/\/)?(www\.)?(player\.)?vimeo\.com\/([a-z]*\/)*([0-9]{6,11})[?]?.*/i' , $ value , $ matches ) ) { foreach ( $ matches as $ match ) { if ( preg_match ( '/^[0-9]{6,12}$/' , $ ...
Parse video link
340
public function buildUrl ( string $ url , array $ parameters = [ ] ) : string { if ( $ parameters ) { foreach ( $ parameters as $ key => $ value ) { if ( $ value === null ) { unset ( $ parameters [ $ key ] ) ; } if ( is_object ( $ value ) ) { $ packedObject = $ this -> objectPacker -> pack ( $ value ) ; if ( $ packedOb...
Builds a URL with the given parameters .
341
public function has ( string $ key ) : bool { if ( array_key_exists ( $ key , $ this -> ttl ) && $ this -> time ( ) - $ this -> ttl [ $ key ] > 0 ) { unset ( $ this -> ttl [ $ key ] ) ; unset ( $ this -> storage [ $ key ] ) ; return false ; } return array_key_exists ( $ key , $ this -> storage ) ; }
Determine if an item exists in the cache . This method will also check if the ttl of the given cache key has been expired and will free the memory if so .
342
public function getKey ( $ key ) { $ out = NULL ; if ( $ this -> hasKey ( $ key ) ) { $ out = $ this -> key [ $ key ] ; unset ( $ this -> key [ $ key ] ) ; } return $ out ; }
get and clear a flash key if it s existing
343
protected function findDefaultDatabase ( string $ connectionString ) { preg_match ( '/\S+\/(\w*)/' , $ connectionString , $ matches ) ; if ( $ matches [ 1 ] ?? null ) { $ this -> defaultDatabase = $ matches [ 1 ] ; } }
Find and stores the default database in the connection string .
344
protected function contains ( $ token ) { return stripos ( $ this -> whois , sprintf ( $ token , $ this -> domain ) ) !== false ; }
Checks if whois contains given token .
345
public function getErrorName ( ) { if ( isset ( self :: $ returnCodes [ $ this -> returnCode ] ) ) { return self :: $ returnCodes [ $ this -> returnCode ] [ 0 ] ; } return 'Error ' . $ this -> returnCode ; }
Returns a string representation of the returned error code .
346
public function save ( $ entity , array $ options = [ ] ) { if ( false === $ this -> fireEvent ( 'saving' , $ entity , true ) ) { return false ; } $ data = $ this -> parseToDocument ( $ entity ) ; $ queryResult = $ this -> getCollection ( ) -> replaceOne ( [ '_id' => $ data [ '_id' ] ] , $ data , $ this -> mergeOptions...
Upserts the given object into database . Returns success if write concern is acknowledged .
347
public function insert ( $ entity , array $ options = [ ] , bool $ fireEvents = true ) : bool { if ( $ fireEvents && false === $ this -> fireEvent ( 'inserting' , $ entity , true ) ) { return false ; } $ data = $ this -> parseToDocument ( $ entity ) ; $ queryResult = $ this -> getCollection ( ) -> insertOne ( $ data , ...
Inserts the given object into database . Returns success if write concern is acknowledged . Since it s an insert it will fail if the _id already exists .
348
public function update ( $ entity , array $ options = [ ] ) : bool { if ( false === $ this -> fireEvent ( 'updating' , $ entity , true ) ) { return false ; } if ( ! $ entity -> _id ) { if ( $ result = $ this -> insert ( $ entity , $ options , false ) ) { $ this -> afterSuccess ( $ entity ) ; $ this -> fireEvent ( 'upda...
Updates the given object into database . Returns success if write concern is acknowledged . Since it s an update it will fail if the document with the given _id did not exists .
349
public function delete ( $ entity , array $ options = [ ] ) : bool { if ( false === $ this -> fireEvent ( 'deleting' , $ entity , true ) ) { return false ; } $ data = $ this -> parseToDocument ( $ entity ) ; $ queryResult = $ this -> getCollection ( ) -> deleteOne ( [ '_id' => $ data [ '_id' ] ] , $ this -> mergeOption...
Removes the given document from the collection .
350
protected function parseToDocument ( $ entity ) { $ schemaMapper = $ this -> getSchemaMapper ( ) ; $ parsedDocument = $ schemaMapper -> map ( $ entity ) ; if ( is_object ( $ entity ) ) { foreach ( $ parsedDocument as $ field => $ value ) { $ entity -> $ field = $ value ; } } return $ parsedDocument ; }
Parses an object with SchemaMapper and the given Schema .
351
protected function getCollection ( ) : Collection { $ conn = $ this -> connPool -> getConnection ( ) ; $ database = $ conn -> defaultDatabase ; $ collection = $ this -> schema -> collection ; return $ conn -> getRawConnection ( ) -> $ database -> $ collection ; }
Retrieves the Collection object .
352
protected function prepareArrayFieldOfQuery ( array $ value ) : array { foreach ( [ '$in' , '$nin' ] as $ operator ) { if ( isset ( $ value [ $ operator ] ) && is_array ( $ value [ $ operator ] ) ) { foreach ( $ value [ $ operator ] as $ index => $ id ) { if ( ObjectIdUtils :: isObjectId ( $ id ) ) { $ value [ $ operat...
Prepares an embedded array of an query . It will convert string ObjectIds in operators into actual objects .
353
protected function getAssembler ( ) { if ( ! $ this -> assembler ) { $ this -> assembler = Ioc :: make ( EntityAssembler :: class ) ; } return $ this -> assembler ; }
Retrieves an EntityAssembler instance .
354
protected function fireEvent ( string $ event , $ entity , bool $ halt = false ) { $ event = "mongolid.{$event}: " . get_class ( $ entity ) ; $ this -> eventService ? $ this -> eventService : $ this -> eventService = Ioc :: make ( EventTriggerService :: class ) ; return $ this -> eventService -> fire ( $ event , $ enti...
Triggers an event . May return if that event had success .
355
protected function prepareProjection ( array $ fields ) { $ projection = [ ] ; foreach ( $ fields as $ key => $ value ) { if ( is_string ( $ key ) ) { if ( is_bool ( $ value ) ) { $ projection [ $ key ] = $ value ; continue ; } if ( is_int ( $ value ) ) { $ projection [ $ key ] = ( $ value >= 1 ) ; continue ; } } if ( ...
Converts the given projection fields to Mongo driver format .
356
public function check ( $ domain ) { return $ this -> client -> query ( $ domain ) -> then ( function ( $ result ) use ( $ domain ) { return Factory :: create ( $ domain , $ result ) -> isAvailable ( ) ; } ) ; }
Checks domain availability .
357
public function checkAll ( array $ domains ) { return When :: map ( $ domains , array ( $ this , 'check' ) ) -> then ( function ( $ statuses ) use ( $ domains ) { ksort ( $ statuses ) ; return array_combine ( $ domains , $ statuses ) ; } ) ; }
Checks domain availability of multiple domains .
358
public function end ( ) { if ( $ this -> buffering === false ) { throw new ParserBufferingException ( 'Markdown buffering have not been started.' ) ; } $ markdown = ob_get_clean ( ) ; $ this -> buffering = false ; return $ this -> parse ( $ markdown ) ; }
Stop buffering output & return the parsed markdown string .
359
protected function referencesOne ( string $ entity , string $ field , bool $ cacheable = true ) { $ referenced_id = $ this -> $ field ; if ( is_array ( $ referenced_id ) && isset ( $ referenced_id [ 0 ] ) ) { $ referenced_id = $ referenced_id [ 0 ] ; } $ entityInstance = Ioc :: make ( $ entity ) ; if ( $ entityInstance...
Returns the referenced documents as objects .
360
protected function referencesMany ( string $ entity , string $ field , bool $ cacheable = true ) { $ referencedIds = ( array ) $ this -> $ field ; if ( ObjectIdUtils :: isObjectId ( $ referencedIds [ 0 ] ?? '' ) ) { foreach ( $ referencedIds as $ key => $ value ) { $ referencedIds [ $ key ] = new ObjectId ( $ value ) ;...
Returns the cursor for the referenced documents as objects .
361
protected function embedsOne ( string $ entity , string $ field ) { if ( is_subclass_of ( $ entity , Schema :: class ) ) { $ entity = ( new $ entity ( ) ) -> entityClass ; } $ items = ( array ) $ this -> $ field ; if ( false === empty ( $ items ) && false === array_key_exists ( 0 , $ items ) ) { $ items = [ $ items ] ;...
Return a embedded documents as object .
362
private function renderErrors ( Base $ base ) : string { if ( ! $ base -> hasErrors ( ) ) { return '' ; } $ html = '' ; foreach ( $ base -> getErrors ( ) as $ error ) { $ li = new Tag ( 'li' ) ; $ li -> setTextContent ( $ error ) ; $ html .= $ li -> render ( ) ; } $ ul = new Tag ( 'ul' ) ; $ ul -> setHtmlContent ( $ ht...
Renders the errors of a Form or an Element as an unordered list .
363
private function _distance ( $ out , $ key ) { return $ this -> distanceBetweenPoints ( $ this -> points [ $ out ] , $ this -> points [ $ key ] ) ; }
Short - cut function for distanceBetweenPoints method
364
public function execute ( $ writeConcern = 1 ) { $ connection = Ioc :: make ( Pool :: class ) -> getConnection ( ) ; $ manager = $ connection -> getRawManager ( ) ; $ namespace = $ connection -> defaultDatabase . '.' . $ this -> schema -> collection ; return $ manager -> executeBulkWrite ( $ namespace , $ this -> getBu...
Execute the BulkWrite using a connection from the Pool . The collection is inferred from entity s collection name .
365
public function push ( $ data ) { $ this -> buffer -> write ( $ data ) ; $ result = [ ] ; while ( $ this -> buffer -> getRemainingBytes ( ) > 0 ) { $ type = $ this -> buffer -> readByte ( ) >> 4 ; try { $ packet = $ this -> factory -> build ( $ type ) ; } catch ( UnknownPacketTypeException $ e ) { $ this -> handleError...
Appends the given data to the internal buffer and parses it .
366
private function handleError ( $ exception ) { if ( $ this -> errorCallback !== null ) { $ callback = $ this -> errorCallback ; $ callback ( $ exception ) ; } }
Executes the registered error callback .
367
final public function partial ( View $ view ) : string { if ( $ this -> injector ) { $ this -> injector -> inject ( $ view ) ; } return $ view -> render ( ) ; }
Renders a partial View .
368
public static function deleteAllButLive ( ) { $ query = new SQLSelect ( ) ; $ query -> setFrom ( 'SiteTree_Versions' ) ; $ versionsToDelete = [ ] ; $ results = $ query -> execute ( ) ; foreach ( $ results as $ row ) { $ ID = $ row [ 'ID' ] ; $ RecordID = $ row [ 'RecordID' ] ; $ Version = $ row [ 'Version' ] ; $ ClassN...
Remove ALL previous versions of a SiteTree record
369
function get ( $ countryCode = false , $ separator = '' ) { if ( $ countryCode == false ) { $ formattedNumber = '0' . $ this -> msisdn ; if ( ! empty ( $ separator ) ) { $ formattedNumber = substr_replace ( $ formattedNumber , $ separator , 4 , 0 ) ; $ formattedNumber = substr_replace ( $ formattedNumber , $ separator ...
Returns a formatted mobile number
370
public function getPrefix ( ) { if ( $ this -> prefix == null ) { $ this -> prefix = substr ( $ this -> msisdn , 0 , 3 ) ; } return $ this -> prefix ; }
Returns the prefix of the MSISDN number .
371
public function getOperator ( ) { $ this -> setPrefixes ( ) ; if ( ! empty ( $ this -> operator ) ) { return $ this -> operator ; } if ( in_array ( $ this -> getPrefix ( ) , $ this -> smartPrefixes ) ) { $ this -> operator = 'SMART' ; } else if ( in_array ( $ this -> getPrefix ( ) , $ this -> globePrefixes ) ) { $ this...
Determines the operator of this number
372
public static function validate ( $ mobileNumber ) { $ mobileNumber = Msisdn :: clean ( $ mobileNumber ) ; return ! empty ( $ mobileNumber ) && strlen ( $ mobileNumber ) === 10 && is_numeric ( $ mobileNumber ) ; }
Validate a given mobile number
373
private static function clean ( $ msisdn ) { $ msisdn = preg_replace ( "/[^0-9]/" , "" , $ msisdn ) ; if ( substr ( $ msisdn , 0 , 1 ) == '0' ) { $ msisdn = substr ( $ msisdn , 1 , strlen ( $ msisdn ) ) ; } else if ( substr ( $ msisdn , 0 , 2 ) == '63' ) { $ msisdn = substr ( $ msisdn , 2 , strlen ( $ msisdn ) ) ; } re...
Cleans the string
374
public function exec ( $ command ) { if ( ! $ this -> connected ) { throw new NotAuthenticatedException ( 'Client has not connected to the Rcon server.' ) ; } $ this -> write ( self :: SERVERDATA_EXECCOMMAND , $ command ) ; return $ this -> read ( ) [ 0 ] [ 'S1' ] ; }
Executes a command on the server .
375
public function read ( ) { $ rarray = [ ] ; $ count = 0 ; while ( $ data = fread ( $ this -> socket , 4 ) ) { $ data = unpack ( 'V1Size' , $ data ) ; if ( $ data [ 'Size' ] > 4096 ) { $ packet = '' ; for ( $ i = 0 ; $ i < 8 ; $ i ++ ) { $ packet .= "\x00" ; } $ packet .= fread ( $ this -> socket , 4096 ) ; } else { $ p...
Reads from the socket .
376
public function close ( ) { if ( ! $ this -> connected ) { return false ; } $ this -> connected = false ; fclose ( $ this -> socket ) ; return true ; }
Closes the socket .
377
public function createTable ( $ name , Array $ columns , $ safe_create = false ) { if ( ( ! $ safe_create ) || ( $ safe_create && ! Schema :: connection ( $ this -> connection ) -> hasTable ( 'users' ) ) ) { if ( Schema :: connection ( $ this -> connection ) -> hasTable ( $ name ) ) { Schema :: connection ( $ this -> c...
Create a table schme with the given columns
378
public function getReturnCodeName ( $ returnCode ) { if ( isset ( self :: $ qosLevels [ $ returnCode ] ) ) { return self :: $ qosLevels [ $ returnCode ] [ 0 ] ; } return 'Unknown ' . $ returnCode ; }
Indicates if the given return code is an error .
379
public function setReturnCodes ( array $ value ) { foreach ( $ value as $ returnCode ) { $ this -> assertValidReturnCode ( $ returnCode , false ) ; } $ this -> returnCodes = $ value ; }
Sets the return codes .
380
private function assertValidReturnCode ( $ returnCode , $ fromPacket = true ) { if ( ! in_array ( $ returnCode , [ 0 , 1 , 2 , 128 ] ) ) { $ this -> throwException ( sprintf ( 'Malformed return code %02x.' , $ returnCode ) , $ fromPacket ) ; } }
Asserts that a return code is valid .
381
public function setConfig ( array $ configs ) { foreach ( $ configs as $ config_key => $ config_value ) { if ( property_exists ( get_class ( $ this ) , $ config_key ) ) { $ this -> $ config_key = $ config_value ; } else { throw new \ InvalidArgumentException ; } } }
set parameters of the object
382
protected function createDataObjectFrom ( $ value , $ className ) { if ( $ value instanceof $ className ) { return $ value ; } if ( $ value instanceof Arrayable ) { $ value = $ value -> toArray ( ) ; } elseif ( is_object ( $ value ) ) { $ value = json_decode ( json_encode ( $ value ) , true ) ; } if ( ! is_array ( $ va...
Creates a DataObject with the given class name
383
public function assemble ( $ document , Schema $ schema ) { $ entityClass = $ schema -> entityClass ; $ model = Ioc :: make ( $ entityClass ) ; foreach ( $ document as $ field => $ value ) { $ fieldType = $ schema -> fields [ $ field ] ?? null ; if ( $ fieldType && 'schema.' == substr ( $ fieldType , 0 , 7 ) ) { $ valu...
Builds an object from the provided data .
384
private function destructEventEmitterTrait ( ) { $ this -> emitterBlocked = EventEmitter :: EVENTS_FORWARD ; $ this -> eventPointers = [ ] ; $ this -> eventListeners = [ ] ; $ this -> forwardListeners = [ ] ; }
Destruct method .
385
private function getTransactionalAnnotation ( RouteMatch $ routeMatch ) : ? Transactional { $ method = $ routeMatch -> getControllerReflection ( ) ; if ( $ method instanceof \ ReflectionMethod ) { $ annotations = $ this -> annotationReader -> getMethodAnnotations ( $ method ) ; foreach ( $ annotations as $ annotation )...
Returns the Transactional annotation for the controller .
386
public function build ( $ type ) { if ( ! isset ( self :: $ mapping [ $ type ] ) ) { throw new UnknownPacketTypeException ( sprintf ( 'Unknown packet type %d.' , $ type ) ) ; } $ class = self :: $ mapping [ $ type ] ; return new $ class ( ) ; }
Builds a packet object for the given type .
387
public function getNextState ( ) { if ( $ this -> getIsExecuted ( ) ) { if ( class_exists ( $ next = $ this -> getNextStateClass ( ) ) ) { return ( new $ next ) ; } else { throw new ClassNotFoundException ; } } else { return $ this ; } }
Return the next state
388
public function getErrorHeader ( ) { $ err_str = '' ; $ error_class = $ this -> getErrors ( ) ; $ error_session = Session :: get ( $ this -> errors_key ) ; if ( $ error_class ) { foreach ( $ error_class -> all ( ) as $ error_key => $ error ) { $ err_str .= "<div class=\"alert alert-danger\">{$error}</div>" ; } } if ( $...
Print the form errors if exists
389
public function appendError ( $ error_key , $ error_string ) { if ( $ this -> getErrors ( ) ) { $ this -> errors -> add ( $ error_key , $ error_string ) ; } else { $ this -> errors = new MessageBag ( array ( $ error_key => $ error_string ) ) ; } }
Append error to the MessageBag
390
public function setProtocolLevel ( $ value ) { if ( $ value < 3 || $ value > 4 ) { throw new \ InvalidArgumentException ( sprintf ( 'Unknown protocol level %d.' , $ value ) ) ; } $ this -> protocolLevel = $ value ; if ( $ this -> protocolLevel === 3 ) { $ this -> protocolName = 'MQIsdp' ; } elseif ( $ this -> protocolL...
Sets the protocol level .
391
public function setWill ( $ topic , $ message , $ qosLevel = 0 , $ isRetained = false ) { $ this -> assertValidString ( $ topic , false ) ; if ( $ topic === '' ) { throw new \ InvalidArgumentException ( 'The topic must not be empty.' ) ; } $ this -> assertValidStringLength ( $ message , false ) ; if ( $ message === '' ...
Sets the will .
392
public function setUsername ( $ value ) { $ this -> assertValidString ( $ value , false ) ; $ this -> username = $ value ; if ( $ this -> username !== '' ) { $ this -> flags |= 64 ; } else { $ this -> flags &= ~ 64 ; } }
Sets the username .
393
private function assertValidWill ( ) { if ( $ this -> hasWill ( ) ) { $ this -> assertValidQosLevel ( $ this -> getWillQosLevel ( ) , true ) ; } else { if ( $ this -> getWillQosLevel ( ) > 0 ) { $ this -> throwException ( sprintf ( 'Expected a will quality of service level of zero but got %d.' , $ this -> getWillQosLev...
Asserts that all will flags and quality of service are correct .
394
public function display ( ) : void { $ templateParameters = [ ] ; foreach ( $ this -> params as $ param ) { if ( $ param instanceof PostParameter ) { $ templateParameters [ $ param -> getName ( ) ] = $ param ; } else { if ( $ param instanceof GenericParameter ) { $ templateParameters [ $ param -> getName ( ) ] = $ para...
Displays the current view . Iterates over all the parameters and stores them in a temporary associative array . Twig then displays the main template using the array with the parameters . Exceptions generated by Twig are shown as errors and logged accordingly for simplification .
395
public function call ( $ call , $ format = null , $ timeout = 6000 , $ pagination = true ) { $ service = $ this -> getService ( ) ; $ service -> setLogger ( $ this -> getLogger ( ) ) ; return $ service -> process ( $ call , $ format , $ timeout , $ pagination ) ; }
Facade d appel Navitia
396
public function setConfiguration ( $ config ) { $ this -> config = $ config ; $ service = $ this -> getService ( ) ; return $ service -> processConfiguration ( $ this -> config ) ; }
Facade de setter de la configuration
397
public function beforeModeration ( ) : bool { if ( method_exists ( $ this -> owner , 'beforeModeration' ) ) { if ( ! $ this -> owner -> beforeModeration ( ) ) { return false ; } } $ event = new ModelEvent ( ) ; $ this -> owner -> trigger ( self :: EVENT_BEFORE_MODERATION , $ event ) ; return $ event -> isValid ; }
This method is invoked before moderating a record .
398
public function markApproved ( ) : bool { $ this -> owner -> { $ this -> statusAttribute } = Status :: APPROVED ; if ( $ this -> beforeModeration ( ) ) { return $ this -> owner -> save ( ) ; } return false ; }
Change model status to Approved
399
public function markRejected ( ) : bool { $ this -> owner -> { $ this -> statusAttribute } = Status :: REJECTED ; if ( $ this -> beforeModeration ( ) ) { return $ this -> owner -> save ( ) ; } return false ; }
Change model status to Rejected