idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
233,400
private function getDefinitionDirs ( array $ driverConfig , ContainerBuilder $ container ) { $ modelDir = $ this -> getDefinitionDir ( 'model' , $ driverConfig , $ container ) ; $ mixinDir = $ this -> getDefinitionDir ( 'mixin' , $ driverConfig , $ container ) ; $ embedDir = $ this -> getDefinitionDir ( 'embed' , $ dri...
Gets the definition directories for models and mixins and returns as a tuple .
233,401
public function bodyFormat ( string $ format ) : self { return tap ( $ this , function ( $ request ) use ( $ format ) { $ this -> bodyFormat = $ format ; } ) ; }
Set the request body fomrat .
233,402
public function withBaseUri ( string $ uri ) : self { return tap ( $ this , function ( $ request ) use ( $ uri ) { return $ this -> options = array_merge_recursive ( $ this -> options , [ 'base_uri' => $ uri , ] ) ; } ) ; }
Set the base uri for all requests .
233,403
public function withHeaders ( array $ headers ) : self { return tap ( $ this , function ( $ request ) use ( $ headers ) { return $ this -> options = array_merge_recursive ( $ this -> options , [ 'headers' => $ headers , ] ) ; } ) ; }
Send headers with the request .
233,404
public function withCookies ( ) : self { return tap ( $ this , function ( $ request ) { return $ this -> options = array_merge_recursive ( $ this -> options , [ 'cookies' => static :: getCookieJar ( ) , ] ) ; } ) ; }
Store any cookies in a cookie jar .
233,405
public function withHandler ( $ handler ) : self { return tap ( $ this , function ( $ request ) use ( $ handler ) { return $ this -> handler = $ handler ; } ) ; }
Handle requests with the given class .
233,406
public function timeout ( int $ seconds ) : self { return tap ( $ this , function ( ) use ( $ seconds ) { return $ this -> options = array_merge_recursive ( $ this -> options , [ 'timeout' => $ seconds , ] ) ; } ) ; }
Timeout of the request in seconds .
233,407
public function beforeSending ( Closure $ callback ) : self { return tap ( $ this , function ( ) use ( $ callback ) { $ this -> beforeSendingCallbacks [ ] = $ callback ; } ) ; }
Set the pre - request Callback .
233,408
public function post ( string $ url , $ params = null ) : HttpResponse { return $ this -> send ( 'POST' , $ url , [ $ this -> bodyFormat => $ params , ] ) ; }
Create and send an Http POST request .
233,409
public function delete ( string $ url , array $ params = [ ] ) : HttpResponse { return $ this -> send ( 'DELETE' , $ url , [ $ this -> bodyFormat => $ params , ] ) ; }
Create and send an Http DELETE request .
233,410
public function send ( string $ method , string $ url , array $ options ) : HttpResponse { try { return new HttpResponse ( $ this -> buildClient ( ) -> request ( $ method , $ url , $ this -> mergeOptions ( [ 'query' => $ this -> parseQueryParams ( $ url ) , ] , $ options ) ) ) ; } catch ( \ GuzzleHttp \ Exception \ Con...
Create and send an Http request .
233,411
public function buildHandlerStack ( ) : HandlerStack { static $ handler ; if ( ! $ handler ) { $ handler = $ this -> handler ?? \ GuzzleHttp \ choose_handler ( ) ; } if ( $ handler instanceof HandlerStack ) { $ stack = $ handler ; } return tap ( $ stack ?? HandlerStack :: create ( ) , function ( $ stack ) { $ stack -> ...
Create a new Guzzle HandlerStack instance .
233,412
public function runBeforeSendingCallbacks ( Request $ request ) : Request { return tap ( $ request , function ( $ request ) { $ this -> beforeSendingCallbacks -> each -> __invoke ( new HttpRequest ( $ request ) ) ; } ) ; }
Run the pre - request callback .
233,413
public function parseQueryParams ( string $ url ) : array { return tap ( [ ] , function ( & $ query ) use ( $ url ) { parse_str ( parse_url ( $ url , PHP_URL_QUERY ) ?? '' , $ query ) ; } ) ; }
Parse the given URL and return its query .
233,414
public function createFromComposer ( $ file = 'composer.json' ) { $ composer = $ this -> readComposerDotJson ( $ file ) ; $ this -> setNamespace ( '' ) ; $ this -> setDestinationFolder ( 'generated\\' ) ; if ( isset ( $ composer [ 'extra' ] ) && isset ( $ composer [ 'extra' ] [ 'paris-model-generator' ] ) ) { $ configu...
Set parameters from the given composer . json file path .
233,415
public function cmdUpdateImageStyle ( ) { $ params = $ this -> getParam ( ) ; if ( empty ( $ params [ 0 ] ) || count ( $ params ) < 2 ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid command' ) ) ; } if ( ! is_numeric ( $ params [ 0 ] ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid argument' ) ) ; } $ th...
Callback for imagestyle - update
233,416
public function cmdDeleteImageStyle ( ) { $ id = $ this -> getParam ( 0 ) ; if ( empty ( $ id ) || ! is_numeric ( $ id ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid argument' ) ) ; } if ( ! $ this -> image_style -> delete ( $ id ) ) { $ this -> errorAndExit ( $ this -> text ( 'Unexpected result' ) ) ; } $ th...
Callback for imagestyle - delete command
233,417
public function cmdClearImageStyle ( ) { $ id = $ this -> getParam ( 0 ) ; $ all = $ this -> getParam ( 'all' ) ; if ( ! isset ( $ id ) && empty ( $ all ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid command' ) ) ; } $ result = false ; if ( isset ( $ id ) ) { if ( ! is_numeric ( $ id ) ) { $ this -> errorAndE...
Callback for imagestyle - clear command
233,418
public function cmdGetImageStyle ( ) { $ list = $ this -> getListImageStyle ( ) ; $ this -> outputFormat ( $ list ) ; $ this -> outputFormatTableImageStyle ( $ list ) ; $ this -> output ( ) ; }
Callback for imagestyle - get command
233,419
protected function submitAddImageStyle ( ) { $ this -> setSubmitted ( null , $ this -> getParam ( ) ) ; $ this -> setSubmittedList ( 'actions' ) ; $ this -> validateComponent ( 'image_style' ) ; $ this -> addImageStyle ( ) ; }
Add an image style at once
233,420
protected function wizardAddImageStyle ( ) { $ this -> validatePrompt ( 'name' , $ this -> text ( 'Name' ) , 'image_style' ) ; $ this -> validatePromptList ( 'actions' , $ this -> text ( 'Actions' ) , 'image_style' ) ; $ this -> validatePrompt ( 'status' , $ this -> text ( 'Status' ) , 'image_style' , 0 ) ; $ this -> s...
Adds an image style step - by - step
233,421
public function set ( $ key , $ value ) { $ this -> checkReadOnly ( ) ; self :: setFromKey ( $ this -> data , $ key , $ value , $ this -> separator ) ; }
Set data inside
233,422
private static function recursiveGetFromKey ( $ data , $ key , $ default ) { if ( empty ( $ key ) ) { return $ data ; } else { $ currentKey = array_shift ( $ key ) ; return isset ( $ data [ $ currentKey ] ) ? self :: recursiveGetFromKey ( $ data [ $ currentKey ] , $ key , $ default ) : $ default ; } }
Private unsecured function for getFromKey
233,423
public static function setFromKey ( & $ data , $ key , $ value , $ separator = '/' ) { if ( is_string ( $ key ) ) { $ key = explode ( $ separator , $ key ) ; } $ data = self :: recursiveSetFromKey ( $ data , $ key , $ value ) ; }
Set data inside an array
233,424
private static function recursiveSetFromKey ( $ data , $ key , $ value ) { if ( empty ( $ key ) ) { return $ value ; } else { if ( ! is_array ( $ data ) ) { $ data = [ ] ; } $ currentKey = array_shift ( $ key ) ; if ( ! isset ( $ data [ $ currentKey ] ) ) { $ data [ $ currentKey ] = [ ] ; } $ data [ $ currentKey ] = se...
Private unsecured method to set data in array
233,425
public function id ( ) { if ( $ this -> loggedOut ) return null ; $ id = $ this -> session -> get ( $ this -> getName ( ) ) ; if ( is_null ( $ id ) && $ this -> acct ( ) ) $ id = $ this -> acct ( ) -> getId ( ) ; return $ id ; }
Get the ID for the currently authenticated acct .
233,426
protected function getAcctByRecaller ( $ recaller ) { if ( $ this -> validRecaller ( $ recaller ) && ! $ this -> tokenRetrievalAttempted ) { $ this -> tokenRetrievalAttempted = true ; list ( $ id , $ token ) = explode ( '|' , $ recaller , 2 ) ; $ this -> viaRemember = ! is_null ( $ acct = $ this -> auth -> retrieveByTo...
Pull a acct from the repository by its recaller ID .
233,427
protected function getRecallerId ( ) { if ( $ this -> validRecaller ( $ recaller = $ this -> getRecaller ( ) ) ) return head ( explode ( '|' , $ recaller ) ) ; return null ; }
Get the acct ID from the recaller cookie .
233,428
public function once ( array $ credentials = [ ] ) { if ( $ this -> validate ( $ credentials ) ) { $ this -> setAcct ( $ this -> lastAttempted ) ; return true ; } return false ; }
Log a acct into the application without sessions or cookies .
233,429
protected function hasValidCredentials ( $ acct , $ credentials ) { return ! is_null ( $ acct ) && $ this -> auth -> validateCredentials ( $ acct , $ credentials ) ; }
Determine if the acct matches the credentials .
233,430
public function onceUsingId ( $ id ) { $ acct = $ this -> auth -> retrieveById ( $ id ) ; if ( ! is_null ( $ acct ) ) { $ this -> setAcct ( $ acct ) ; return true ; } return false ; }
Log the given acct ID into the application without sessions or cookies .
233,431
public function logout ( ) { $ acct = $ this -> acct ( ) ; $ this -> clearAcctDataFromStorage ( ) ; if ( ! is_null ( $ this -> acct ) ) $ this -> refreshRememberToken ( $ acct ) ; Hooks :: trigger ( 'acct.logout' , compact ( 'acct' ) ) ; $ this -> acct = null ; $ this -> loggedOut = true ; }
Log the acct out of the application .
233,432
protected function clearAcctDataFromStorage ( ) { $ this -> session -> remove ( $ this -> getName ( ) ) ; if ( ! is_null ( $ this -> getRecaller ( ) ) ) { $ recaller = $ this -> getRecallerName ( ) ; $ this -> getCookieJar ( ) -> queue ( $ this -> getCookieJar ( ) -> forget ( $ recaller ) ) ; } }
Remove the acct data from the session and cookies .
233,433
protected function refreshRememberToken ( Account $ acct ) { $ acct -> setRememberToken ( $ token = Str :: random ( 60 ) ) ; $ this -> auth -> updateRememberToken ( $ acct , $ token ) ; }
Refresh the remember me token for the acct .
233,434
public function setAcct ( Account $ acct ) { $ this -> acct = $ acct ; $ this -> loggedOut = false ; return $ this ; }
Set the current acct .
233,435
protected function transform ( $ middleware ) { if ( is_string ( $ middleware ) ) { return $ this -> container -> get ( $ middleware ) ; } if ( is_callable ( $ middleware ) ) { return new ClosureMiddleware ( $ middleware ) ; } return $ middleware ; }
Transforms the specified input into a middleware .
233,436
protected function resolve ( $ index ) { if ( ! isset ( $ this -> stack [ $ index ] ) ) { return new ErrorHandler ; } $ next = $ this -> resolve ( $ index + 1 ) ; $ item = $ this -> stack [ ( integer ) $ index ] ; return new NextHandler ( $ item , $ next ) ; }
Resolves the whole stack through its index .
233,437
static function reindent ( $ source , $ indent = '' , $ tabs_to_spaces = 4 , $ ignore_zero_indent = true ) { if ( $ tabs_to_spaces !== null ) { $ source = str_replace ( "\t" , str_repeat ( ' ' , $ tabs_to_spaces ) , $ source ) ; } $ lines = explode ( "\n" , $ source ) ; $ min_length = null ; foreach ( $ lines as $ line...
Uniforms indentation . Useful when printing .
233,438
public static function make ( string $ path , int $ ifExists = Directory :: MAKE_DIRECTORY_EXISTS_THROW_EXCEPTION ) : Directory { $ exists = Directory :: exists ( $ path ) ; if ( $ exists ) { if ( $ ifExists === Directory :: MAKE_DIRECTORY_EXISTS_OVERWRITE ) { unlink ( $ path ) ; } else if ( $ ifExists === Directory ::...
Makes a directory .
233,439
public function fileExists ( string $ name ) { if ( ! $ this -> _isLoaded ) { $ this -> load ( ) ; } return in_array ( $ name , $ this -> _files ) ; }
Checks if a file exists in this directory .
233,440
public function getFile ( string $ name , int $ ifNotExists = Directory :: GET_FILE_NOT_EXISTS_THROW_EXCEPTION ) : File { $ path = $ this -> getPath ( ) . DIRECTORY_SEPARATOR . $ name ; if ( $ this -> fileExists ( $ name ) ) { return new File ( $ path ) ; } if ( $ ifNotExists === Directory :: GET_FILE_NOT_EXISTS_CREATE...
Returns a file from the directory .
233,441
public function getFiles ( ) : array { if ( ! $ this -> _isLoaded ) { $ this -> load ( ) ; } return array_map ( function ( $ file ) { return new File ( $ this -> getPath ( ) . DIRECTORY_SEPARATOR . $ file ) ; } , $ this -> _files ) ; }
Returns an array with all files of the directory .
233,442
public function directoryExists ( string $ name ) { if ( ! $ this -> _isLoaded ) { $ this -> load ( ) ; } return in_array ( $ name , $ this -> _directories ) ; }
Checks if a directory exists in this directory .
233,443
public function getDirectory ( string $ name , int $ ifNotExists = Directory :: GET_DIRECTORY_NOT_EXISTS_THROW_EXCEPTION ) : Directory { $ path = $ this -> getPath ( ) . DIRECTORY_SEPARATOR . $ name ; if ( $ this -> directoryExists ( $ name ) ) { return new Directory ( $ path ) ; } if ( $ ifNotExists === Directory :: G...
Returns a directory from the directory .
233,444
public function getDirectories ( ) : array { if ( ! $ this -> _isLoaded ) { $ this -> load ( ) ; } return array_map ( function ( $ directory ) { return new Directory ( $ this -> getPath ( ) . DIRECTORY_SEPARATOR . $ directory ) ; } , $ this -> _directories ) ; }
Returns an array with all directories of the directory .
233,445
public function load ( ) { $ files = scandir ( $ this -> getPath ( ) ) ; foreach ( $ files as $ file ) { if ( $ file === "." || $ file === ".." ) { continue ; } if ( is_file ( $ this -> getPath ( ) . $ file ) ) { $ this -> _files [ $ file ] = $ file ; } else if ( is_dir ( $ this -> getPath ( ) . $ file ) ) { $ this -> ...
Loads directories and files .
233,446
public function setLocation ( string $ location ) { $ dir = Directory :: make ( $ location , Directory :: MAKE_DIRECTORY_EXISTS_OPEN ) ; $ old = $ this -> getPath ( ) ; $ new = $ dir -> getPath ( ) ; if ( rename ( $ old , $ new ) ) { $ this -> _location = $ dir -> getPath ( ) ; } }
Moves the file to the specified location .
233,447
public function setPath ( string $ path ) { $ info = pathinfo ( $ path ) ; $ this -> setLocation ( $ info [ "dirname" ] ?? "" ) ; $ this -> setName ( $ info [ "filename" ] ?? "" ) ; }
Sets new file location name and extension .
233,448
protected function createIPCSegment ( ) { $ this -> fileIPC1 = '/tmp/' . mt_rand ( ) . md5 ( $ this -> getName ( ) ) . '.shm' ; touch ( $ this -> fileIPC1 ) ; $ shm_key = ftok ( $ this -> fileIPC1 , 't' ) ; if ( $ shm_key === - 1 ) { throw new Exception ( 'Fatal exception creating SHM segment (ftok)' ) ; } $ this -> in...
Create IPC segment
233,449
protected function createIPCSemaphore ( ) { $ this -> fileIPC2 = '/tmp/' . mt_rand ( ) . md5 ( $ this -> getName ( ) ) . '.sem' ; touch ( $ this -> fileIPC2 ) ; $ sem_key = ftok ( $ this -> fileIPC2 , 't' ) ; if ( $ sem_key === - 1 ) { throw new Exception ( 'Fatal exception creating semaphore (ftok)' ) ; } $ this -> in...
Create IPC semaphore
233,450
protected function writeToIPCSegment ( ) { if ( shmop_read ( $ this -> internalSemaphoreKey , 1 , 1 ) === 1 ) { return ; } $ serialized_IPC_array = serialize ( $ this -> internalIPCArray ) ; $ shm_bytes_written = shmop_write ( $ this -> internalIPCKey , $ serialized_IPC_array , 0 ) ; if ( $ shm_bytes_written !== strlen...
Write to IPC segment
233,451
protected function readFromIPCSegment ( ) { $ serialized_IPC_array = shmop_read ( $ this -> internalIPCKey , 0 , shmop_size ( $ this -> internalIPCKey ) ) ; if ( ! $ serialized_IPC_array ) { throw new Exception ( 'Fatal exception reading SHM segment (shmop_read)' . "\n" ) ; } unset ( $ this -> internalIPCArray ) ; $ th...
Read from IPC segment
233,452
public function register_callback_func ( $ argList , $ methodName ) { if ( is_array ( $ argList ) && count ( $ argList ) > 1 ) { if ( $ argList [ 1 ] === - 2 ) { $ this -> internalIPCArray [ '_call_type' ] = - 2 ; } else { $ this -> internalIPCArray [ '_call_type' ] = - 1 ; } } else { $ this -> internalIPCArray [ '_cal...
Register callback func into shared memory
233,453
protected function cleanThreadContext ( ) { shmop_delete ( $ this -> internalIPCKey ) ; shmop_delete ( $ this -> internalSemaphoreKey ) ; shmop_close ( $ this -> internalIPCKey ) ; shmop_close ( $ this -> internalSemaphoreKey ) ; unlink ( $ this -> fileIPC1 ) ; unlink ( $ this -> fileIPC2 ) ; $ this -> running = false ...
Clean thread context
233,454
protected static function createContainer ( ) { $ app = JFactory :: getApplication ( ) ; if ( is_null ( $ app -> get ( 'container' , null ) ) ) { $ app -> set ( 'container' , new Container ( ) ) ; } $ container = $ app -> get ( 'container' ) ; if ( ! method_exists ( $ container , 'set' ) ) { $ container = new Container...
Ensure container exists
233,455
protected static function createDatabaseConfiguration ( ) { $ config = new JConfig ( ) ; $ dsn = $ config -> dbtype . '://' . $ config -> user . ':' . $ config -> password . '@' . $ config -> host . '/' . $ config -> db ; $ dataMapperClass = PrefixedDoctrineDataMapper :: class ; $ ini = <<<INIdatabaseUrl="$dsn"definit...
Create DB configuration
233,456
public function getByModelRootId ( $ rootId ) { $ this -> fillScopes ( ) ; if ( ! isset ( $ this -> scopeByModelRootId [ $ rootId ] ) ) { throw new OutOfBoundsException ( "No scope with modelRootId '$rootId' found" ) ; } return $ this -> scopeByModelRootId [ $ rootId ] ; }
Returns the scope by modelRootId
233,457
protected function fillScopes ( ) { if ( $ this -> scopes !== null ) { return ; } $ this -> scopes = [ ] ; foreach ( $ this -> treeModel -> rootNodes ( ) as $ rootNode ) { $ this -> addToScopes ( $ this -> node2Scope ( $ rootNode ) ) ; } foreach ( $ this -> manualScopes as $ scope ) { $ this -> addToScopes ( $ scope ) ...
Fills the scope array for fast lookups
233,458
protected function addToScopes ( TreeScope $ scope ) { $ this -> scopes [ ] = $ scope ; $ this -> scopeByName [ $ scope -> getName ( ) ] = $ scope ; $ this -> scopeByModelRootId [ $ scope -> getModelRootId ( ) ] = $ scope ; $ this -> scopeByPathPrefix [ $ scope -> getPathPrefix ( ) ] = $ scope ; }
Adds the passed scope to the scope array
233,459
public function node2Scope ( SiteTreeNodeInterface $ node ) { $ scope = new TreeScope ( ) ; $ urlSegment = trim ( $ node -> getUrlSegment ( ) , '/' ) ; $ name = $ urlSegment ? $ urlSegment : TreeScope :: DEFAULT_NAME ; $ scope -> setPathPrefix ( $ node -> getUrlSegment ( ) ) ; $ scope -> setName ( $ name ) ; $ scope ->...
Convert a root node to a scope
233,460
public function getPages ( ) { $ pages = array ( ) ; foreach ( $ this -> router -> getRouteCollection ( ) -> all ( ) as $ route ) { if ( $ method = $ this -> getReflectionMethod ( $ route -> getDefault ( '_controller' ) ) ) { if ( $ composerAnnotation = $ this -> reader -> getMethodAnnotation ( $ method , self :: COMPO...
Gets all existing Pages
233,461
private function getReflectionMethod ( $ controller ) { if ( preg_match ( '#(.+)::([\w]+)#' , $ controller , $ matches ) ) { $ class = $ matches [ 1 ] ; $ method = $ matches [ 2 ] ; } elseif ( preg_match ( '#(.+):([\w]+)#' , $ controller , $ matches ) ) { $ controller = $ matches [ 1 ] ; $ method = $ matches [ 2 ] ; if...
Returns the ReflectionMethod for the given controller string
233,462
public function upPagesPosition ( $ parentId , $ position , $ positionLimit = NULL ) { if ( is_null ( $ positionLimit ) ) { $ query = $ this -> getEntityManager ( ) -> createQuery ( 'UPDATE FulgurioLightCMSBundle:Page p SET p.position=p.position-1 WHERE p.position>=:position AND p.parent=:parentId AND p.page_type=:page...
Up pages position
233,463
public function getNextPosition ( $ parentId ) { $ query = $ this -> getEntityManager ( ) -> createQuery ( 'SELECT MAX(p.position) FROM FulgurioLightCMSBundle:Page p WHERE p.parent=:parentId AND p.page_type=:pageType' ) ; $ query -> setParameter ( 'pageType' , 'page' ) ; $ query -> setParameter ( 'parentId' , $ parentI...
Get next position in tree
233,464
public static function validateTags ( array & $ array , $ direction = null ) { foreach ( $ array as $ key => $ tag ) { $ array [ $ key ] = self :: validateTag ( $ tag , $ direction ) ; } return $ array ; }
Validates that the given array contains all valid Tag entries
233,465
public static function matchTags ( array $ tags1 , array $ tags2 ) { if ( count ( self :: diffTags ( $ tags1 , $ tags2 ) ) == 0 && count ( self :: diffTags ( $ tags2 , $ tags1 ) ) == 0 ) return true ; return false ; }
Determines if the tags in both arrays are a match
233,466
public function setValue ( $ value ) { if ( ! $ this -> validate ( $ value ) ) { throw new InvalidClaimException ( 'Invalid value provided for claim "' . $ this -> getName ( ) . '": ' . $ value ) ; } $ this -> value = $ value ; return $ this ; }
Set the claim value and call a validate method if available .
233,467
public function fakeUrl ( $ route , $ params ) { if ( preg_match_all ( '/\[[\s\S]+?]/' , $ route , $ matches , PREG_SET_ORDER ) ) { for ( $ i = 0 ; $ i < count ( $ matches ) ; $ i ++ ) { $ route = preg_replace ( '/\[[\s\S]+?]/' , $ params [ $ i ] , $ route ) ; } } return ( $ route ) ; }
Return the real url genereted from a named route
233,468
public static function fromNative ( ) { $ args = \ func_get_args ( ) ; if ( \ count ( $ args ) != 2 ) { throw new \ BadMethodCallException ( 'You must provide 2 arguments: 1) real part, 2) imaginary part' ) ; } $ real = Real :: fromNative ( $ args [ 0 ] ) ; $ im = Real :: fromNative ( $ args [ 1 ] ) ; $ complex = new s...
Returns a new Complex object from native PHP arguments
233,469
public static function fromPolar ( Real $ modulus , Real $ argument ) { $ realValue = $ modulus -> toNative ( ) * \ cos ( $ argument -> toNative ( ) ) ; $ imValue = $ modulus -> toNative ( ) * \ sin ( $ argument -> toNative ( ) ) ; $ real = new Real ( $ realValue ) ; $ im = new Real ( $ imValue ) ; $ complex = new self...
Returns a Complex given polar coordinates
233,470
public static function parse ( string $ headerValue ) : self { $ self = new self ( ) ; foreach ( explode ( ',' , $ headerValue ) as $ acceptable ) { if ( strstr ( $ acceptable , 'q=' ) !== false ) { list ( $ acceptable , $ priority ) = explode ( 'q=' , trim ( $ acceptable ) ) ; } else { $ priority = 1 ; } settype ( $ p...
method to create an instance from a string header value
233,471
public function addAcceptable ( string $ acceptable , float $ priority = 1.0 ) : self { if ( 0 > $ priority || 1.0 < $ priority ) { throw new \ InvalidArgumentException ( 'Invalid priority, must be between 0 and 1.0' ) ; } $ this -> acceptables [ $ acceptable ] = $ priority ; return $ this ; }
add an acceptable to the list
233,472
public function priorityFor ( string $ mimeType ) : float { if ( ! isset ( $ this -> acceptables [ $ mimeType ] ) ) { if ( $ this -> count ( ) === 0 ) { return 1.0 ; } elseif ( isset ( $ this -> acceptables [ '*/*' ] ) ) { return $ this -> acceptables [ '*/*' ] ; } list ( $ maintype ) = explode ( '/' , $ mimeType ) ; r...
returns priority for given acceptable
233,473
public function asString ( ) : string { $ parts = [ ] ; foreach ( $ this -> acceptables as $ acceptable => $ priority ) { if ( 1.0 === $ priority ) { $ parts [ ] = $ acceptable ; } else { $ parts [ ] = $ acceptable . ';q=' . $ priority ; } } return join ( ',' , $ parts ) ; }
returns current list as string
233,474
protected function castToPhp ( $ value , $ column ) { if ( $ value !== null && $ this -> hasCast ( $ column ) && ! $ this -> isIgnoreCast ( $ value ) ) { $ value = $ this -> toPhpType ( $ value , $ this -> casts [ $ column ] ) ; } return $ value ; }
Cast column value to PHP type
233,475
protected function castToDb ( $ value , $ column ) { if ( $ this -> hasCast ( $ column ) && ! $ this -> isIgnoreCast ( $ value ) ) { $ value = $ this -> toDbType ( $ value , $ this -> casts [ $ column ] ) ; } return $ value ; }
Cast column value for saving to database
233,476
protected function toDbType ( $ value , $ type ) { switch ( $ type ) { case 'int' : return ( int ) $ value ; case 'bool' : return ( bool ) $ value ; case 'string' : case 'datetime' : case 'date' : case 'float' : return ( string ) $ value ; case 'array' : case 'json' : return json_encode ( ( array ) $ value , JSON_UNESC...
Cast value for saving to database
233,477
protected function cacheJsonDecode ( $ value , $ assoc = false ) { if ( ! isset ( static :: $ castCache [ $ value ] [ $ assoc ] ) ) { static :: $ castCache [ $ value ] [ $ assoc ] = json_decode ( $ value , $ assoc ) ; } return static :: $ castCache [ $ value ] [ $ assoc ] ; }
Cache json decode value
233,478
static public function makeApp ( $ envPath = null , array $ config = [ ] , $ kernel = null ) { $ envPath = is_null ( $ envPath ) ? static :: getRuntimePath ( ) : $ envPath ; $ kernel = is_null ( $ kernel ) ? static :: defaultKernel ( ) : $ kernel ; $ config = empty ( $ config ) ? static :: defaultConfig ( ) : $ config ...
Static factor constructor .
233,479
public function config ( ) { if ( $ this -> appConfig ) { return $ this -> appConfig ; } return $ this -> appConfig = $ this -> app -> make ( 'config' ) ; }
Get application config repository ;
233,480
protected function bootComponents ( ) { $ config = $ this -> config ( ) ; foreach ( $ this -> componentInstances as $ instance ) { $ instance -> boot ( $ this -> app , $ config ) ; } }
Boot setup components .
233,481
protected function setupComponents ( ) { $ components = Arr :: get ( $ this -> config , 'components' ) ; foreach ( $ components as $ component ) { $ instance = new $ component ( $ this -> config ) ; $ instance -> setup ( ) ; $ this -> componentInstances [ $ component ] = $ instance ; } }
Build component instances and run setup method .
233,482
protected function buildAppConfig ( $ configPath ) { $ config = require ( $ configPath ) ; $ callback = Arr :: get ( $ this -> config , 'callback.vendor_config' ) ; if ( $ callback instanceof Closure ) { $ config = call_user_func ( $ callback , $ config ) ; } return $ config ; }
Include and add our Service Provider to the App config .
233,483
static public function getRuntimePath ( $ depth = 2 ) { $ stack = debug_backtrace ( ) ; $ frame = $ stack [ count ( $ stack ) - $ depth ] ; return dirname ( $ frame [ 'file' ] ) ; }
Get the file location of the calling file .
233,484
public function addDefaultParam ( $ templateName , $ param , $ value ) { $ isDefaultForAllTemplates = ( $ templateName === self :: TEMPLATE_ALL ) ; if ( $ isDefaultForAllTemplates ) { $ this -> defaultParameters [ $ param ] = $ value ; $ this -> defaultParametersProvided = true ; } else { $ this -> fullQualifiedPathNam...
Add a default parameter to use with a template .
233,485
public static function generateCustom ( $ prefix , $ length = 128 ) { if ( $ length <= ( strlen ( $ prefix ) + 1 ) ) { throw new InvalidArgumentException ( "Uid length cannot be smaller than prefix length +1" ) ; } return "$prefix-" . self :: generate ( $ length - ( strlen ( $ prefix ) + 1 ) ) ; }
Generate a custom uid starting from a prefix
233,486
public static function generate ( $ length = 128 ) { if ( $ length < 32 ) { return substr ( self :: getUid ( ) , 0 , $ length ) ; } else if ( $ length == 32 ) { return self :: getUid ( ) ; } else { $ numString = ( int ) ( $ length / 32 ) + 1 ; $ randNum = "" ; for ( $ i = 0 ; $ i < $ numString ; $ i ++ ) $ randNum .= s...
Generate an uid
233,487
public static function load ( string $ fileName , ImageDriver $ driver = null ) : self { $ self = new self ( $ fileName , $ driver ) ; $ self -> handle = $ self -> driver -> load ( $ fileName ) ; return $ self ; }
loads image from file
233,488
public function store ( string $ fileName ) : self { $ this -> driver -> store ( $ fileName , $ this -> handle ) ; return $ this ; }
stores image under given file name
233,489
static function MemberCheckList ( $ name , Member $ member ) { $ field = new CheckList ( $ name ) ; self :: AddMembergroupOptions ( $ field ) ; $ groupIDs = Membergroup :: GetKeyList ( self :: MemberMembergroups ( $ member ) ) ; $ field -> SetValue ( $ groupIDs ) ; return $ field ; }
Creates a check list field for groups of a member
233,490
static function PageCheckList ( $ name , Page $ page ) { $ field = new CheckList ( $ name ) ; self :: AddMembergroupOptions ( $ field ) ; $ groupIDs = Membergroup :: GetKeyList ( self :: PageMembergroups ( $ page ) ) ; $ field -> SetValue ( $ groupIDs ) ; return $ field ; }
Creates a check list field for groups of a page
233,491
static function ContentCheckList ( $ name , Content $ content ) { $ field = new CheckList ( $ name ) ; self :: AddMembergroupOptions ( $ field ) ; $ groupIDs = Membergroup :: GetKeyList ( self :: ContentMembergroups ( $ content ) ) ; $ field -> SetValue ( $ groupIDs ) ; return $ field ; }
Creates a check list field for groups of a content
233,492
static function MemberMembergroups ( Member $ member ) { if ( ! $ member -> Exists ( ) ) { return array ( ) ; } $ sql = Access :: SqlBuilder ( ) ; $ tblMmg = MemberMembergroup :: Schema ( ) -> Table ( ) ; $ tblMg = Membergroup :: Schema ( ) -> Table ( ) ; $ join = $ sql -> Join ( $ tblMmg ) ; $ joinCondition = $ sql ->...
Gets the member s member groups
233,493
static function PageMembergroups ( Page $ page ) { if ( ! $ page -> Exists ( ) ) { return array ( ) ; } $ sql = Access :: SqlBuilder ( ) ; $ tblPmg = PageMembergroup :: Schema ( ) -> Table ( ) ; $ tblMg = Membergroup :: Schema ( ) -> Table ( ) ; $ join = $ sql -> Join ( $ tblPmg ) ; $ joinCondition = $ sql -> Equals ( ...
Gets the page s member groups
233,494
static function ContentMembergroups ( Content $ content ) { if ( ! $ content -> Exists ( ) ) { return array ( ) ; } $ sql = Access :: SqlBuilder ( ) ; $ tblCmg = ContentMembergroup :: Schema ( ) -> Table ( ) ; $ tblMg = Membergroup :: Schema ( ) -> Table ( ) ; $ join = $ sql -> Join ( $ tblCmg ) ; $ joinCondition = $ s...
Gets the content s member groups
233,495
private static function AddMembergroupOptions ( CheckList $ field ) { $ sql = Access :: SqlBuilder ( ) ; $ tbl = Membergroup :: Schema ( ) -> Table ( ) ; $ orderBy = $ sql -> OrderList ( $ sql -> OrderAsc ( $ tbl -> Field ( 'Name' ) ) ) ; $ groups = Membergroup :: Schema ( ) -> Fetch ( false , null , $ orderBy ) ; fore...
Adds the member group options to the checklist
233,496
public function getRoles ( ) { $ roles = $ this -> roles ; foreach ( $ this -> getGroups ( ) as $ group ) { $ roles = array_merge ( $ roles , $ group -> getRoles ( ) ) ; } $ newRoles = [ ] ; if ( $ this -> getActiveRole ( ) ) { $ newRoles = $ this -> getActiveRole ( ) -> getRoles ( ) ; } $ finalRoles = array_merge ( $ ...
Returns the user roles
233,497
public function build ( ) { $ values = array ( 'access' => false , 'genres' => false , 'publication_date' => false , 'title' => true , 'keywords' => true , 'stock_tickers' => true ) ; foreach ( $ values as $ value => $ isEscaped ) { if ( ! is_null ( $ this -> { $ value } ) ) { $ this -> addChild ( sprintf ( 'news:%s' ,...
Adds all the nodes in our news sitemap with some values being escaped .
233,498
public function setMaxLengths ( $ column1 = null , $ column2 = null , $ _ = null ) { foreach ( func_get_args ( ) as $ index => $ argument ) { $ length = strlen ( ( string ) $ argument ) ; if ( $ this -> columns -> offsetExists ( $ index ) === false || $ this -> columns -> offsetGet ( $ index ) < $ length ) { $ this -> ...
Set the max column lengths for later use
233,499
public function getColumnPaddingLength ( $ columnIndex , $ columnValue ) { if ( $ this -> columns -> offsetExists ( $ columnIndex ) === false ) { return 0 ; } return $ this -> columns -> offsetGet ( $ columnIndex ) - strlen ( $ columnValue ) ; }
Get the padding needed based on the max column length and the column value given