idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
5,500
public function zipLeft ( $ other ) { if ( count ( $ other ) !== count ( $ this ) ) { throw new \ InvalidArgumentException ( 'Both left and right must have same size.' ) ; } if ( is_array ( $ other ) ) { $ aKeys = array_keys ( $ this -> data ) ; $ other = new Dict ( $ other ) ; return new Dict ( array_map ( function ( ...
Zip with another Dict values on the left
5,501
private function fromStdObject ( \ stdClass $ data , $ class ) { $ reflection = $ this -> getReflection ( $ class ) ; $ object = $ this -> getClassInstance ( $ data , $ reflection ) ; $ map = $ this -> getPropertyMap ( $ class ) ; $ this -> handleAssociations ( $ data , $ object , $ reflection , $ map [ 'associations' ...
Converts a stdClass representation of data into a class
5,502
private function getPropertyMap ( $ class ) { $ output [ 'meta' ] = $ meta = $ this -> em -> getClassMetadata ( $ class ) ; $ output [ 'fields' ] = $ meta -> getFieldNames ( ) ; $ output [ 'associations' ] = $ meta -> getAssociationNames ( ) ; $ output [ 'fields' ] = array_filter ( $ output [ 'fields' ] , function ( $ ...
builds a property map for doctrine entities
5,503
public function reset ( ) { $ ex = func_get_args ( ) ; foreach ( $ _SESSION as $ n => $ s ) { if ( ! in_array ( $ n , $ ex ) ) unset ( $ _SESSION [ $ n ] ) ; } if ( empty ( $ ex ) ) session_destroy ( ) ; }
foo will still return true whilst bar will return false
5,504
public function timerUp ( ) { if ( ! self :: get ( 'timer' ) || ! self :: get ( 'timeout' ) ) return false ; return ( time ( ) - self :: get ( 'timeout' ) >= self :: get ( 'timer' ) ) ? true : false ; }
To be used in conjunction with the above function for checking if the timer has run out .
5,505
public function setDefer ( $ defer = false ) { $ this -> defer = is_bool ( $ defer ) ? $ defer : false ; return $ this ; }
Sets the objects defer state .
5,506
public function & addGroup ( $ unshift = false ) { $ group = $ this -> factory -> create ( 'FormDesigner\FormGroup' ) ; if ( $ unshift == true ) { array_unshift ( $ this -> groups , $ group ) ; } else { $ this -> groups [ ] = $ group ; } $ group -> injectFormDesigner ( $ this ) ; return $ group ; }
Creates a FormGroup
5,507
public function isHorizontal ( $ grid_size = 'sm' , $ label_with = '3' ) { $ this -> display_mode = 'h' ; $ this -> setGridSize ( $ grid_size ) ; $ this -> setLabelWidth ( $ label_with ) ; return $ this ; }
Sets the forms display mode to horizontal
5,508
private function handleGlobalContainerErrors ( ) { if ( empty ( $ this -> errors [ '@' ] ) ) { return ; } $ group = $ this -> addGroup ( true ) ; $ div = $ group -> addElement ( 'Elements\Div' ) ; $ div -> addCss ( 'alert alert-danger alert-dismissable' ) ; if ( $ this -> fadeout ) { $ div -> addCss ( 'fadeout' ) ; } $...
Checks a possible used Container object for global errors
5,509
public static function generateSalt ( $ chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' , $ saltLength = 30 ) { return substr ( str_shuffle ( str_repeat ( ( string ) $ chars , 10 ) ) , 0 , ( int ) $ saltLength ) ; }
Generates a random string
5,510
public static function concat ( $ glue ) { $ ret = "" ; $ args = array ( ) ; $ len = func_num_args ( ) ; for ( $ i = 1 ; $ i < $ len ; $ i ++ ) { $ value = func_get_arg ( $ i ) ; $ values = is_array ( $ value ) ? array_values ( $ value ) : array ( $ value ) ; $ args = array_merge ( $ args , $ values ) ; } foreach ( $ a...
Concatenates strings .
5,511
public static function replaceArgs ( $ str , $ args , $ escapeFunc = null ) { if ( $ escapeFunc === null ) { $ escapeFunc = function ( $ x ) { return $ x ; } ; } if ( ! is_callable ( $ escapeFunc ) ) { throw new TextException ( "Escape function is not callable" ) ; } return preg_replace_callback ( '/(^|[^\\\]){\w+}/' ,...
Replaces arguments in a string .
5,512
public static function trimText ( $ str ) { $ ret = "" ; $ str = preg_replace ( "/\t/" , " " , $ str ) ; $ lines = explode ( "\n" , $ str ) ; $ len = count ( $ lines ) ; $ i0 = 0 ; for ( $ i = 0 ; $ i < $ len ; $ i ++ ) { $ line = $ lines [ $ i ] ; $ trimLine = trim ( $ line ) ; if ( strlen ( $ trimLine ) > 0 ) { $ ...
Removes left spaces from a multiline string .
5,513
public static function read ( string $ fileName = '' , bool $ returnArray = false ) { $ pathInfo = \ pathinfo ( static :: normalizePath ( $ fileName ) ) ; if ( ! isset ( $ pathInfo [ 'extension' ] ) ) { $ exMsg = \ sprintf ( 'Config file name "%s" is missing an extension and cannot be auto-detected' , $ pathInfo [ 'fil...
Reads configuration from file
5,514
public static function write ( string $ fileName = '' , $ config = null ) : bool { $ pathInfo = \ pathinfo ( static :: normalizePath ( $ fileName ) ) ; if ( ! isset ( $ pathInfo [ 'extension' ] ) ) { $ message = \ sprintf ( 'Config file name "%s" is missing an extension and cannot be auto-detected' , $ pathInfo [ 'file...
Writes configuration to file
5,515
public function getAchievementByName ( $ achievementName ) { foreach ( $ this -> getAchievements ( ) as $ achievement ) { if ( $ achievement -> getName ( ) == $ achievementName ) { return $ achievement ; } } return null ; }
Retrieve an achievement by using its name
5,516
public function getAchievementsByCategory ( Category $ category ) { $ achievements = array ( ) ; foreach ( $ this -> getAchievements ( ) as $ achievement ) { if ( $ achievement -> getCategory ( ) == $ category ) { $ achievements [ ] = $ achievement ; } } return $ achievements ; }
Gets all achievements for a category
5,517
public function getProviders ( ) { $ providers = array ( ) ; foreach ( $ this -> getPluginManager ( ) -> getCanonicalNames ( ) as $ providerAlias ) { $ providers [ ] = $ this -> getPluginManager ( ) -> get ( $ providerAlias ) ; } return $ providers ; }
Get all possible achievement providers
5,518
public function render ( $ actionName , array $ attributes = array ( ) , array $ options = array ( ) ) { $ controller = 'PablodipModuleBundle:Module:execute' ; $ attributes [ '_module.module' ] = get_class ( $ this -> module ) ; $ attributes [ '_module.action' ] = $ actionName ; $ options [ 'attributes' ] = $ attribute...
Renders an action .
5,519
private function set ( $ key , $ secs = null ) { $ item = $ this -> adapter -> getItem ( $ key ) ; if ( ! is_null ( $ secs ) ) { if ( $ secs > 0 ) { $ item -> expiresAfter ( $ secs ) ; } } return $ item ; }
Set the cache item .
5,520
public function put ( $ key , $ value , $ secs = 0 ) { $ item = $ this -> set ( $ key , $ secs ) ; $ item -> set ( $ value ) ; $ this -> adapter -> save ( $ item ) ; }
Set new cache item .
5,521
public function pull ( $ key ) { $ item = $ this -> get ( $ key ) ; $ this -> remove ( $ key ) ; return $ item ; }
Get an item cache and remove it .
5,522
public function prolong ( $ key , $ secs ) { $ item = $ this -> set ( $ key ) ; $ expiration = $ item -> getExpiration ( ) -> getTimestamp ( ) ; $ now = time ( ) ; if ( $ expiration > $ now ) { $ interval = ( $ expiration - $ now ) + $ secs ; } else { $ interval = $ secs ; } $ item -> expiresAfter ( $ interval ) ; $ th...
prolong a lifetime of cache item .
5,523
public function create ( ) { if ( ! isset ( $ this -> wurflManager ) ) { $ this -> init ( ) ; } if ( $ this -> hasToBeReloaded ( ) ) { $ this -> reload ( ) ; } return $ this -> wurflManager ; }
Creates a new WURFLManager Object
5,524
public function getClientWithCOID ( IRI $ apiCoid ) { $ apiCoidString = ( string ) $ apiCoid ; if ( ! isset ( $ this -> apiClients [ $ apiCoidString ] ) ) { $ this -> apiClients [ $ apiCoidString ] = self :: createClient ( $ this -> objectRetriever -> getObject ( $ apiCoid ) , $ this -> namespace ) ; } return $ this ->...
Get an API client for the WebAPI with the specified COID .
5,525
public static function explodeArrayOnKeys ( $ array , $ explodeOn , $ limit = null ) { $ result = [ ] ; foreach ( $ array as $ path => $ value ) { $ temp = & $ result ; $ tempArray = ( $ limit === null ) ? explode ( $ explodeOn , $ path ) : explode ( $ explodeOn , $ path , $ limit ) ; foreach ( $ tempArray as $ key ) {...
Explode an array on string .
5,526
public static function calculateArrayDepth ( array $ array , $ deReference = false ) { if ( $ deReference === true ) { $ array = unserialize ( serialize ( $ array ) ) ; } $ maxDepth = 1 ; foreach ( $ array as $ value ) { if ( is_array ( $ value ) ) { $ depth = static :: calculateArrayDepth ( $ value ) + 1 ; if ( $ dept...
Calculate the depth of an array . Be aware of array with references to other places in the same array . This can cause memory exhaustion .
5,527
public static function toUnderscore ( array $ array = [ ] ) { $ output = [ ] ; foreach ( $ array as $ key => $ value ) { $ key = StringUtils :: toUnderscore ( $ key ) ; if ( is_array ( $ value ) ) { $ value = static :: toUnderscore ( $ value ) ; } $ output [ $ key ] = $ value ; } return $ output ; }
Convert an array to camelcased key version
5,528
public function use ( Identity $ identity , MapInterface $ source ) : self { if ( ( string ) $ source -> keyType ( ) !== 'string' || ( string ) $ source -> valueType ( ) !== 'mixed' ) { throw new \ TypeError ( 'Argument 2 must be of type MapInterface<string, mixed>' ) ; } $ this -> sources = $ this -> sources -> put ( ...
Use the given collection as the original data for the given entity
5,529
public function compute ( Identity $ identity , MapInterface $ target ) : MapInterface { if ( ( string ) $ target -> keyType ( ) !== 'string' || ( string ) $ target -> valueType ( ) !== 'mixed' ) { throw new \ TypeError ( 'Argument 2 must be of type MapInterface<string, mixed>' ) ; } if ( ! $ this -> sources -> contain...
Return the collection of data that has changed for the given identity
5,530
public function parse ( ) { $ this -> rules = [ ] ; $ parts = explode ( '|' , $ this -> command ) ; foreach ( $ parts as $ part ) { $ segments = explode ( ':' , $ part ) ; $ this -> rules [ ] = array ( 'name' => $ segments [ 0 ] , 'args' => isset ( $ segments [ 1 ] ) ? explode ( ',' , $ segments [ 1 ] ) : array ( ) ) ;...
Parse the rule and find sub - rules in it .
5,531
public function getFieldDatabaseNameArray ( ) { $ fields = [ ] ; foreach ( $ this -> fields as $ field ) { $ fields [ ] = $ field -> toSelectString ( ) ; } return $ fields ; }
Gets a array with the database name for all the fields of the entity for the repository .
5,532
private function getUserGroup ( ) { if ( null !== $ token = $ this -> tokenStorage -> getToken ( ) ) { if ( null !== $ user = $ token -> getUser ( ) ) { return $ user -> getGroup ( ) ; } } return null ; }
Returns the current user s group .
5,533
protected function defineForm ( FormObjectDefinition $ form ) { $ form -> section ( 'Account Details' , [ $ form -> bind ( $ this -> serviceAccountEmail ) -> to ( Field :: create ( 'service_account_email' , 'Service Account Email' ) -> string ( ) -> email ( ) -> required ( ) ) , $ form -> bind ( $ this -> privateKeyDat...
Defines the structure of the form object .
5,534
public function createProcess ( ProcessFactoryInterface $ processFactory ) : Process { return $ processFactory -> createProcess ( $ this -> name , $ this -> arguments ) ; }
Returns the Symfony process generated using factory .
5,535
public function retry ( RetrySchedulerInterface $ retryScheduler ) : array { if ( ! $ this -> isRetryable ( ) ) { throw new class ( 'This job cannot be retried anymore.' ) extends \ BadMethodCallException implements ExceptionInterface { } ; } $ cloned = clone $ this ; $ cloned -> retries ++ ; return [ $ cloned , $ retr...
Returns the new created job to retry and the datetime when it s executed at .
5,536
public function respondWith ( $ var ) { if ( ! $ this -> respondTo ) { throw new Exception \ RuntimeException ( "In order to use respondWith, first you need to declare the formats your controller responds to in the respondTo property" ) ; } $ format = $ this -> request ( ) -> format ( ) ; if ( in_array ( $ format , $ t...
Basic functionality .
5,537
public function render ( $ options = [ ] ) { if ( $ this -> isPerformed ( ) ) { throw new Exception \ DoubleRenderException ( 'Can only render or redirect once per action' ) ; } list ( $ renderOptions , $ options ) = $ this -> splitOptions ( $ options ) ; $ renderOptions = $ this -> normalizeRender ( $ renderOptions ) ...
Render When rendering action the name of the action could be camelCased or underscored .
5,538
public function getAppControllersMethod ( $ methodName , $ scope = '' ) { $ methods = [ ] ; if ( $ this -> appControllerRefls ) { foreach ( $ this -> appControllerRefls as $ appRefl ) { if ( $ appRefl -> hasMethod ( $ methodName ) ) { $ method = $ appRefl -> getMethod ( $ methodName ) ; if ( $ this -> isApplicationCont...
Searches through all the ApplicationControllers classes for a method and returns them all .
5,539
protected function runInitializers ( ) { $ methodName = 'init' ; if ( $ inits = $ this -> getAppControllersMethod ( $ methodName ) ) { foreach ( $ inits as $ init ) { $ init = $ init -> bindTo ( $ this ) ; $ init ( ) ; } } $ method = $ this -> getReflection ( ) -> getMethod ( $ methodName ) ; if ( $ method -> getDeclar...
Runs initializers from the called class and its ApplicationController parents if any .
5,540
public static function getActiveTheme ( ) { if ( static :: $ _activeTheme === null ) { foreach ( static :: getThemes ( ) as $ index => $ theme ) { if ( $ theme [ 'active' ] ) { return static :: $ _activeTheme = [ $ index => $ theme ] ; } } return false ; } return static :: $ _activeTheme ; }
Gets the active theme .
5,541
public static function setActiveTheme ( $ activeIndex ) { foreach ( $ themes = static :: getThemes ( ) as $ index => $ theme ) { if ( $ activeIndex !== false && $ activeIndex == $ index ) { $ themes [ $ index ] [ 'active' ] = true ; } else { $ themes [ $ index ] [ 'active' ] = false ; } } static :: setThemes ( $ themes...
Sets the active theme .
5,542
protected function processData ( ) { if ( null === $ this -> data ) { if ( null !== $ this -> rawData ) { $ this -> data = $ this -> serializer -> deserialize ( $ this -> rawData , $ this -> serializerParams ) ; } } }
checks if data is already deserialized .
5,543
public function add ( string $ key , $ value ) { if ( $ key === '' || $ key === null ) { throw new ViewException ( 'Empty keys are not allowed!' ) ; } if ( ! isset ( $ this -> engineVarList [ $ key ] ) ) { $ this -> engineVarList [ $ key ] = $ value ; return $ this ; } if ( is_array ( $ this -> engineVarList [ $ key ] ...
!!! important !!!
5,544
public function getConfigVariableList ( array $ param ) { if ( ! $ param || ! is_array ( $ param ) ) { return null ; } $ list = [ ] ; foreach ( $ param as $ key ) { $ list [ $ key ] = $ this -> setting [ $ key ] ; } return $ list ; }
returns you an array of variables
5,545
static function sGetMicrotime ( ) { list ( $ usec , $ sec ) = explode ( " " , microtime ( ) ) ; return ( ( float ) $ usec + ( float ) $ sec ) ; }
Get prased microtime
5,546
static protected function formatErrorText ( $ errno , $ errstr , $ errfile , $ errline ) { $ retVal = '<div><b>' . self :: $ errorType [ $ errno ] . ':</b> ' . $ errstr . '</div>' ; $ retVal .= '<div><b>File:</b> ' . $ errfile . '</div>' ; $ retVal .= '<div><b>Line:</b> ' . $ errline . '</div>' ; return $ retVal ; }
function formats error to readable form
5,547
static public function displayBox ( $ text = '' , $ config = null ) { if ( ! isset ( $ config [ 'attach' ] ) ) { $ config [ 'attach' ] = true ; } if ( $ text == '' ) { $ text = self :: $ standardErrorText ; } $ retVal = '<p style="margin: 0.2em; font-size: 1.5em; color: #000000;">' . $ text . '<p>' ; if ( $ config [ 'a...
Returns nice formatted error message
5,548
static protected function formatExceptionMessage ( \ Exception $ exception ) { $ errorFullText = '<div><b>New ' . get_class ( $ exception ) . '</b></div>' ; $ errorFullText .= '<div><b>File:</b> ' . $ exception -> getFile ( ) . '</div>' ; $ errorFullText .= '<div><b>Line:</b> ' . $ exception -> getLine ( ) . '</div>' ;...
Formats exception messages
5,549
static protected function getArgument ( $ arg ) { switch ( mb_strtolower ( gettype ( $ arg ) ) ) { case 'string' : return ( '"' . str_replace ( array ( "\n" , "\"" ) , array ( '' , '\"' ) , $ arg ) . '"' ) ; case 'boolean' : return ( bool ) $ arg ; case 'object' : return 'object(' . get_class ( $ arg ) . ')' ; case 'ar...
Converts variable into short text
5,550
static public function send ( $ text ) { if ( ! self :: $ sendTrace || empty ( self :: $ senderConfig [ 'url' ] ) || empty ( self :: $ senderConfig [ 'port' ] ) ) { return false ; } $ data [ 'company' ] = self :: $ senderConfig [ 'sender' ] ; $ data [ 'text' ] = urlencode ( $ text ) ; $ data [ 'parameters' ] = serializ...
Error sending function sends messages psHelpdesk
5,551
static public function write ( $ text ) { $ text = str_replace ( '<div>' , '' , $ text ) ; $ text = str_replace ( '</div>' , '; ' , $ text ) ; $ data [ 'text' ] = "\n" . date ( 'Y-m-d H:i' ) . '; ' . $ text ; $ data [ 'parameters' ] = serialize ( $ _REQUEST ) ; $ tFile = fopen ( self :: $ writeFile , 'a' ) ; fputs ( $ ...
Error write function
5,552
static public function cThrow ( $ message = null , \ Exception $ exception = null , $ config = null ) { if ( ! isset ( $ config [ 'display' ] ) ) { $ config [ 'display' ] = self :: $ displayTrace ; } if ( ! isset ( $ config [ 'send' ] ) ) { $ config [ 'send' ] = self :: $ sendTrace ; } if ( ! isset ( $ config [ 'write'...
Controlled throw for catch block
5,553
static public function halt ( $ message = null , \ Exception $ exception = null , $ config = null ) { echo self :: cThrow ( $ message , $ exception , $ config ) ; exit ( 0 ) ; }
Halt program execution
5,554
public function getCodeAttribute ( $ value ) { if ( $ this -> active ) { return $ this -> details ( ) -> active ( ) -> first ( ) -> code ; } return null ; }
Get teacher code .
5,555
public function getDepartmentAttribute ( $ value ) { if ( $ this -> active ) { return Department :: findOrFail ( ( $ this -> details ( ) -> active ( ) -> first ( ) -> department_id ) ) ; } return null ; }
Get teacher department .
5,556
public function unregister ( $ errorHandler = true , $ exceptionHandler = true , $ shutdownHandler = true ) { if ( $ errorHandler ) { $ this -> unregisterErrorHandler ( ) ; } if ( $ exceptionHandler ) { $ this -> unregisterExceptionHandler ( ) ; } if ( $ shutdownHandler ) { $ this -> unregisterShutdownHandler ( ) ; } r...
Unregisters error & exception handler
5,557
public function handleShutdown ( ) { if ( ! $ this -> shutdownHandlerRegistered ) { return ; } $ error = error_get_last ( ) ; if ( $ error && Severity :: fromPhpErrorNo ( $ error [ 'type' ] ) >= $ this -> minSeverityOnShutdown ) { $ this -> handleError ( $ error [ 'type' ] , $ error [ 'message' ] , $ error [ 'file' ] ,...
Handle fatal errors and such
5,558
public static function addSalts ( Event $ event ) { $ composer = $ event -> getComposer ( ) ; $ root = preg_replace ( "/\/vendor/" , '' , $ composer -> getConfig ( ) -> get ( 'vendor-dir' ) ) ; $ io = $ event -> getIO ( ) ; if ( file_exists ( sprintf ( '%s/.env' , $ root ) ) ) { return 1 ; } if ( ! $ io -> isInteractiv...
Adds generedted salts to env file .
5,559
public function generateSalt ( $ length = 64 ) { $ chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' ; $ chars .= '!@#$%^&*()' ; $ chars .= '-_ []{}<>~`+=,.;:/?|' ; $ factory = new Factory ( ) ; $ generator = $ factory -> getGenerator ( new Strength ( Strength :: MEDIUM ) ) ; return $ generator -...
Generates salt .
5,560
protected function writeToFile ( $ file , $ salts , Event $ event ) { try { if ( copy ( sprintf ( '%s.example' , $ file ) , $ file ) ) { file_put_contents ( $ file , implode ( $ salts , "\n" ) , FILE_APPEND | LOCK_EX ) ; return 0 ; } } catch ( \ Exception $ e ) { $ event -> getIO ( ) -> write ( '<error>An error occured...
Write to file .
5,561
public function group ( $ group = null ) { if ( $ group !== null ) { $ this -> _group = $ group ; } return $ this -> _group ; }
Get or set the group of the module .
5,562
public function description ( $ description = null ) { if ( $ description !== null ) { $ this -> _description = $ description ; } return $ this -> _description ; }
Get or set the description of the module .
5,563
public function path ( $ moduleFilePath = null ) { if ( $ moduleFilePath !== null ) { $ this -> _path = dirname ( $ moduleFilePath ) ; } return $ this -> _path ; }
Get or set the path of this module .
5,564
public function getHashLastBuilded ( bool $ buildIfNotFound = false ) : ? string { return $ this -> lastBuildedHash ?? ( $ buildIfNotFound ? $ this -> buildHash ( ) : null ) ; }
Get the last requested hash
5,565
public function loadUserByUsername ( $ username ) { $ user = $ this -> segmentalizer -> loadUserByUsername ( $ username ) ; if ( call_user_func ( $ this -> filter , $ user ) ) { return $ user ; } throw new UsernameNotFoundException ( sprintf ( 'Username "%s" does not exist.' , $ username ) ) ; }
Load user by username from the UserProviderSegmentalizer and apply filter function on the returned User object .
5,566
public function physAddresses ( ) { $ pa = $ this -> getSNMP ( ) -> walk1d ( self :: OID_IF_PHYS_ADDRESS ) ; foreach ( $ pa as $ i => $ a ) { if ( strpos ( $ a , ':' ) == 1 ) { $ pa [ $ i ] = '0' . $ a ; } } return $ pa ; }
Get an array of the interfaces physical addresses
5,567
public function lastChanges ( $ asUnixTimestamp = false ) { $ lc = $ this -> getSNMP ( ) -> walk1d ( self :: OID_IF_LAST_CHANGE ) ; if ( $ asUnixTimestamp ) { $ sysUptime = $ this -> getSNMP ( ) -> useSystem ( ) -> uptime ( ) / 100 ; foreach ( $ lc as $ i => $ t ) { if ( $ t ) { $ lc [ $ i ] = intval ( floor ( time ( )...
Get an array of device interface last change times
5,568
public static function getType ( IRI $ coid ) { if ( $ coid -> getScheme ( ) != 'coid' || $ coid -> getHost ( ) == '' || preg_match ( self :: REGEX_HOSTNAME , $ coid -> getHost ( ) ) != 1 ) return self :: COID_INVALID ; if ( $ coid -> getPath ( ) == '' || $ coid -> getPath ( ) == '/' ) return self :: COID_ROOT ; $ segm...
Get the type of a COID .
5,569
public static function getName ( IRI $ coid ) { if ( self :: getType ( $ coid ) != self :: COID_INVALID && self :: getType ( $ coid ) != self :: COID_ROOT ) { $ segments = explode ( '/' , $ coid -> getPath ( ) ) ; return $ segments [ 1 ] ; } else return null ; }
Get the name segment of a valid COID or null if not available .
5,570
public static function getVersion ( IRI $ coid ) { if ( self :: getType ( $ coid ) == self :: COID_VERSIONED ) { $ segments = explode ( '/' , $ coid -> getPath ( ) ) ; return $ segments [ 2 ] ; } else return null ; }
Get the version segment of a valid versioned COID or null if not available .
5,571
public static function getVersionWildcard ( IRI $ coid ) { if ( self :: getType ( $ coid ) == self :: COID_VERSION_WILDCARD ) { $ segments = explode ( '/' , $ coid -> getPath ( ) ) ; return $ segments [ 2 ] ; } else return null ; }
Get the version segment of a versioned or version wildcard COID or null if not available .
5,572
public static function getNamespaceCOID ( IRI $ coid ) { switch ( self :: getType ( $ coid ) ) { case self :: COID_ROOT : return $ coid ; case self :: COID_UNVERSIONED : case self :: COID_VERSIONED : case self :: COID_VERSION_WILDCARD : return new IRI ( 'coid://' . $ coid -> getHost ( ) ) ; default : return null ; } }
Returns the COID itself if it is a root COID or a new IRI object representing the namespace underlying the given COID .
5,573
public function setPosition ( $ position ) { $ oldPosition = $ this -> owner -> { $ this -> positionAttribute } ; $ transaction = $ this -> owner -> getDb ( ) -> beginTransaction ( ) ; try { $ isUp = ( $ position - $ oldPosition ) > 0 ; $ counters = [ $ this -> positionAttribute => $ isUp ? - 1 : 1 ] ; $ condition = [ ...
Changes position of owner among the entities of the same type .
5,574
private function headersFromFormat ( $ format ) { $ type = gettype ( $ format ) ; if ( $ type === 'array' ) { $ headers = $ format ; } else if ( $ type === 'string' ) { $ headers = array ( ) ; switch ( $ format ) { case 'json' : $ contentType = 'application/json' ; break ; case 'jsonp' : $ contentType = 'application/ja...
Generate headers from format
5,575
private function contentFromData ( $ data , $ format ) { $ type = gettype ( $ data ) ; if ( $ type === 'string' ) { $ content = $ data ; } else if ( $ type === 'array' ) { switch ( $ format ) { case 'json' : case 'jsonp' : $ content = json_encode ( $ data ) ; break ; default : $ content = serialize ( $ data ) ; break ;...
Serialize content from data
5,576
public function nestedAction ( Request $ request , $ content ) { if ( ! $ content instanceof Content ) { $ content = $ this -> get ( 'opifer.content.content_manager' ) -> getRepository ( ) -> findOneById ( $ content ) ; } if ( ! $ content || ! $ content -> getActive ( ) ) { return new Response ( '' ) ; } return $ this ...
View a content item by it s ID
5,577
public function getStableBadge ( Repo $ repo ) { if ( $ repo -> getPackagistSlug ( ) ) { return sprintf ( '<img src="%s" />' , $ this -> helper -> getStableVersionBadgeUrl ( $ repo -> getPackagistSlug ( ) ) ) ; } return '' ; }
Get stable version badge image
5,578
public function getLicenseBadge ( Repo $ repo ) { if ( $ repo -> getPackagistSlug ( ) ) { return sprintf ( '<img src="%s" />' , $ this -> helper -> getLicenseBadgeUrl ( $ repo -> getPackagistSlug ( ) ) ) ; } return '' ; }
Get license badge image
5,579
public function getUnstableBadge ( Repo $ repo ) { if ( $ repo -> getPackagistSlug ( ) ) { return sprintf ( '<img src="%s" />' , $ this -> helper -> getUnstableVersionBadgeUrl ( $ repo -> getPackagistSlug ( ) ) ) ; } return '' ; }
Get unstable version badge image
5,580
public function getDownloadBadge ( Repo $ repo ) { if ( $ repo -> getPackagistSlug ( ) ) { return sprintf ( '<img src="%s" />' , $ this -> helper -> getTotalDownloadBadgeUrl ( $ repo -> getPackagistSlug ( ) ) ) ; } return '' ; }
Get total downloads badge image
5,581
public function getMonthlyDownloadBadge ( Repo $ repo ) { if ( $ repo -> getPackagistSlug ( ) ) { return sprintf ( '<img src="%s" />' , $ this -> helper -> getMonthlyDownloadBadgeUrl ( $ repo -> getPackagistSlug ( ) ) ) ; } return '' ; }
Get monthly downloads badge image
5,582
public function getDailyDownloadBadge ( Repo $ repo ) { if ( $ repo -> getPackagistSlug ( ) ) { return sprintf ( '<img src="%s" />' , $ this -> helper -> getDailyDownloadBadgeUrl ( $ repo -> getPackagistSlug ( ) ) ) ; } return '' ; }
Get daily downloads badge image
5,583
public function bind ( string $ scope , string $ abstract , string $ concrete ) { $ this -> validateScope ( __METHOD__ , $ scope ) ; if ( $ scope === self :: SCOPE_INSTANCE_PER_RESOLVE ) { $ this -> container -> bind ( $ abstract , $ concrete ) ; } else { $ this -> container -> singleton ( $ abstract , $ concrete ) ; }...
Binds the supplied class or interface to the supplied concrete class name .
5,584
public function bindCallback ( string $ scope , string $ abstract , callable $ factory ) { $ this -> validateScope ( __METHOD__ , $ scope ) ; if ( $ scope === self :: SCOPE_INSTANCE_PER_RESOLVE ) { $ this -> container -> bind ( $ abstract , $ factory ) ; } else { $ this -> container -> singleton ( $ abstract , $ factor...
Binds the supplied class or interface to the return value of the supplied callback .
5,585
public function bindForCallback ( string $ abstract , $ concrete , callable $ callback ) { $ hasOriginal = $ this -> container -> bound ( $ abstract ) ; $ originalInstance = false ; if ( $ hasOriginal ) { $ binding = $ this -> container -> getBindings ( ) [ $ abstract ] ?? null ; $ hasInstance = $ binding && $ binding ...
Binds the supplied class or interface to the supplied value for the duration of the supplied callback .
5,586
public static function toInteger ( & $ array , $ default = 0 ) { if ( is_array ( $ array ) ) { foreach ( $ array as $ i => $ v ) { $ array [ $ i ] = ( int ) $ v ; } } else { if ( $ default === null ) { $ array = [ ] ; } elseif ( is_array ( $ default ) ) { self :: toInteger ( $ default , null ) ; $ array = $ default ; }...
Utility function to map an array to a integer value
5,587
public static function toObject ( & $ array , $ class = '\\stdClass' ) { $ obj = null ; if ( is_array ( $ array ) ) { $ obj = new $ class ; foreach ( $ array as $ k => $ v ) { if ( is_array ( $ v ) ) { $ obj -> $ k = self :: toObject ( $ v , '\\stdClass' ) ; } else { $ obj -> $ k = $ v ; } } } return $ obj ; }
Utility function to map an array to a \ stdClass object .
5,588
public static function pivot ( $ source , $ key = null ) { $ result = [ ] ; $ counter = [ ] ; foreach ( $ source as $ index => $ value ) { if ( is_array ( $ value ) ) { if ( ! isset ( $ value [ $ key ] ) ) { continue ; } $ resultKey = $ value [ $ key ] ; $ resultValue = & $ source [ $ index ] ; } elseif ( is_object ( $...
Pivots an array to create a reverse lookup of an array of scalars arrays or objects .
5,589
protected static function _sortObjects ( & $ a , & $ b ) { $ key = self :: $ sortKey ; for ( $ i = 0 , $ count = count ( $ key ) ; $ i < $ count ; $ i ++ ) { if ( isset ( self :: $ sortDirection [ $ i ] ) ) { $ direction = self :: $ sortDirection [ $ i ] ; } if ( isset ( self :: $ sortCase [ $ i ] ) ) { $ caseSensitive...
Callback function for sorting an array of objects on a key
5,590
public function fetchRepository ( Repository $ repository , $ withBuild = true ) { $ response = $ this -> getResponse ( sprintf ( '/repos/%s' , $ repository -> getSlug ( ) ) , array ( ) ) ; $ project = $ this -> hydrate ( $ repository , $ response ) ; if ( ! $ withBuild ) { return $ project ; } return $ this -> fetchBu...
Fetch project into project instance
5,591
public function fetchBuilds ( Repository $ repository ) { $ response = $ this -> getResponse ( sprintf ( '/repos/%s/builds' , $ repository -> getSlug ( ) ) , array ( ) ) ; if ( is_array ( $ response ) ) { foreach ( $ response as $ buildData ) { $ build = new Build ( ) ; $ repository -> addBuild ( $ this -> hydrate ( $ ...
Fetch builds into proejct instance
5,592
protected function slotExtendedAssignMultiple ( array $ variables , $ signalClassName , $ signalName ) { $ variables [ 'settings' ] = $ this -> settings ; $ dispatcher = $ this -> objectManager -> get ( Dispatcher :: class ) ; $ variables = $ dispatcher -> dispatch ( $ signalClassName , $ signalName , $ variables ) ; $...
Extend the view by the slot class and name and assign the variable to the view .
5,593
protected function checkSettings ( ) { if ( empty ( $ this -> settings [ 'additional' ] [ 'detailPid' ] ) ) { $ this -> settings [ 'additional' ] [ 'detailPid' ] = $ GLOBALS [ 'TSFE' ] -> id ; } if ( empty ( $ this -> settings [ 'additional' ] [ 'listPid' ] ) ) { $ this -> settings [ 'additional' ] [ 'listPid' ] = $ GL...
Check if the settings .
5,594
protected function arrayToFiltertext ( array $ filterArray = null ) { $ resultArray = [ ] ; foreach ( $ filterArray as $ key => $ value ) { if ( $ value ) { $ resultArray [ ] = implode ( self :: SEPARATOR_KEY_VALUE , [ $ key , $ value ] ) ; } } return implode ( self :: SEPARATOR_ENTRY , $ resultArray ) ; }
Transfer json to filtertext .
5,595
protected function filtertextToArray ( string $ filter = null ) { $ resultArray = [ ] ; if ( ! empty ( $ filter ) ) { $ filterArray = explode ( self :: SEPARATOR_ENTRY , $ filter ) ; foreach ( $ filterArray as $ key => $ value ) { $ entryArray = explode ( self :: SEPARATOR_KEY_VALUE , $ value ) ; $ resultArray [ $ entr...
Transfer filtertext to json .
5,596
protected function updateMappingConfigurationForAllowedPoperties ( $ mappingConfiguration , $ settings ) { $ mappingConfiguration -> skipUnknownProperties ( ) ; if ( isset ( $ settings ) ) { foreach ( $ settings as $ key => $ value ) { if ( $ value ) { $ mappingConfiguration -> allowProperties ( $ key ) ; } } } }
Get the association
5,597
public function get ( $ parameter ) { $ intermediateConfig = null ; $ path = explode ( '.' , $ parameter ) ; foreach ( $ path as $ section ) { if ( null === $ intermediateConfig ) { $ intermediateConfig = $ this -> config [ $ section ] ; continue ; } $ intermediateConfig = $ intermediateConfig [ $ section ] ; } return ...
Gets the config parameter value based on the path .
5,598
public function getName ( ) { if ( $ this -> _name === null ) { $ name = get_class ( $ this ) ; $ pos = strrpos ( $ name , '\\' ) ; if ( $ pos !== false ) { $ name = substr ( $ name , $ pos + 1 ) ; } if ( preg_match ( '/^Twig([A-Za-z]+)Extension$/' , $ name , $ matches ) ) { $ name = $ matches [ 1 ] ; } $ this -> _name...
Returns the name of the extension .
5,599
protected function generateRequestTarget ( ) { $ endpoint = Client :: API_ENDPOINT ; $ method = WordRequest :: API_METHOD ; $ format = Client :: RESPONSE_FORMAT ; return "{$endpoint}/{$method}.{$format}/{$this->word}" ; }
Generates the request target URL based on the requested word .