idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
2,800 | private function & convert ( $ nodeName , $ arr = [ ] ) { $ xml = $ this -> xml ; $ node = $ xml -> createElement ( $ nodeName ) ; if ( is_array ( $ arr ) ) { if ( isset ( $ arr [ '@attributes' ] ) ) { $ this -> extractAttributes ( $ node , $ arr , $ nodeName ) ; unset ( $ arr [ '@attributes' ] ) ; } if ( isset ( $ arr... | This method converts an array into XML recursively . |
2,801 | public static function process ( $ ficlist , $ sourcepath , $ distpath , $ preprocvars , $ preprocmanifest = false ) { $ manifest = new Reader ( $ ficlist , $ sourcepath , $ distpath ) ; $ manifest -> setVerbose ( self :: $ verbose ) ; $ manifest -> setStripComment ( self :: $ stripComment ) ; $ manifest -> setTargetCh... | read the given manifest file and copy files . |
2,802 | public static function removeFiles ( $ ficlist , $ distpath ) { $ distdir = Fs \ DirUtils :: normalizeDir ( $ distpath ) ; $ fs = self :: getFileSystem ( $ distdir ) ; $ script = file ( $ ficlist ) ; $ currentdestdir = '' ; foreach ( $ script as $ nbline => $ line ) { ++ $ nbline ; if ( preg_match ( ';^(cd|rmd)?\s+([a-... | delete files indicated in the given manifest file from the indicated target directory . |
2,803 | protected function bootBindings ( ) { $ this -> app [ CommandBus :: class ] = function ( $ app ) { return $ app [ 'tactician.commandbus' ] ; } ; $ this -> app [ CommandHandlerMiddleware :: class ] = function ( $ app ) { return $ app [ 'tactician.handler' ] ; } ; $ this -> app [ CommandNameExtractor :: class ] = functio... | Bind some interfaces and implementations . |
2,804 | protected function registerLocator ( ) { $ this -> app -> singleton ( 'tactician.locator' , function ( $ app ) { $ commandNamespace = $ this -> config ( 'command_namespace' ) ; $ handlerNamespace = $ this -> config ( 'handler_namespace' ) ; $ locator = $ this -> config ( 'locator' ) ; return ( new $ locator ( $ this ->... | Register bindings for the Handler Locator . |
2,805 | protected function registerMiddleware ( ) { $ this -> app -> bind ( 'tactician.middleware' , function ( ) { $ middleware = $ this -> config ( 'middleware' ) ; $ resolved = array_map ( function ( $ name ) { if ( is_string ( $ name ) ) { return $ this -> app -> make ( $ name ) ; } return $ name ; } , $ middleware ) ; $ r... | Register bindings for all the middleware . |
2,806 | public static function checkRequestVars ( ) { if ( version_compare ( PHP_VERSION , '6.0.0' , '<' ) ) { if ( ini_get ( 'register_globals' ) ) { Debug :: _warn ( '<a target="_blank" href="http://www.php.net/manual/en/security.globals.php">register_globals</a> is on, strongly recommended to turn off' ) ; foreach ( array_... | Prep request parameters |
2,807 | public static function checkSettings ( ) { if ( version_compare ( PHP_VERSION , '6.0.0' , '<' ) && ini_get ( 'safe_mode' ) ) { Debug :: _warn ( '<a target="_blank" href="http://www.php.net/manual/en/features.safe-mode.php">safe_mode</a> is on' . ( ini_get ( 'safe_mode_gid' ) ? ' / safe_mode_gid = ' . ini_get ( 'safe_mo... | Check PHP settings |
2,808 | public static function getCallerInfo ( $ retInfo = true , $ offset = 0 ) { $ offset ++ ; $ info = \ bdk \ Debug \ Utilities :: getCallerInfo ( $ offset ) ; if ( $ retInfo ) { return $ info ; } return ( $ info [ 'class' ] ? $ info [ 'class' ] . '::' : '' ) . $ info [ 'function' ] ; } | Returns the calling function |
2,809 | public static function getMemoryLimit ( ) { $ iniVal = ini_get ( 'memory_limit' ) ; $ val = $ iniVal !== '' ? $ iniVal : ( version_compare ( PHP_VERSION , '5.2.0' , '>' ) ? '128M' : ( version_compare ( PHP_VERSION , '5.2.0' , '=' ) ? '16M' : '8M' ) ) ; return $ val ; } | Determine PHP s MemoryLimit |
2,810 | public function process ( ) { if ( $ this -> cache !== null ) { return $ this -> cache ; } else { return ( $ this -> cache = UriTemplate :: expand ( $ this -> template , $ this -> data ) ) ; } } | Processes the template |
2,811 | public static function create_database ( $ database , $ charset = null , $ if_not_exists = true , $ db = null ) { $ sql = 'CREATE DATABASE' ; $ sql .= $ if_not_exists ? ' IF NOT EXISTS ' : ' ' ; $ charset = static :: process_charset ( $ charset , true ) ; return \ DB :: query ( $ sql . \ DB :: quote_identifier ( $ data... | Creates a database . Will throw a Database_Exception if it cannot . |
2,812 | public static function drop_database ( $ database , $ db = null ) { return \ DB :: query ( 'DROP DATABASE ' . \ DB :: quote_identifier ( $ database , $ db ? $ db : static :: $ connection ) , \ DB :: DELETE ) -> execute ( $ db ? $ db : static :: $ connection ) ; } | Drops a database . Will throw a Database_Exception if it cannot . |
2,813 | public static function rename_table ( $ table , $ new_table_name , $ db = null ) { return \ DB :: query ( 'RENAME TABLE ' . \ DB :: quote_identifier ( \ DB :: table_prefix ( $ table , $ db ? $ db : static :: $ connection ) , $ db ? $ db : static :: $ connection ) . ' TO ' . \ DB :: quote_identifier ( \ DB :: table_pref... | Renames a table . Will throw a Database_Exception if it cannot . |
2,814 | public static function drop_index ( $ table , $ index_name , $ db = null ) { if ( strtoupper ( $ index_name ) == 'PRIMARY' ) { $ sql = 'ALTER TABLE ' . \ DB :: quote_identifier ( \ DB :: table_prefix ( $ table , $ db ? $ db : static :: $ connection ) , $ db ? $ db : static :: $ connection ) ; $ sql .= ' DROP PRIMARY KE... | Drop an index from a table . |
2,815 | protected static function process_charset ( $ charset = null , $ is_default = false , $ db = null , $ collation = null ) { $ charset or $ charset = \ Config :: get ( 'db.' . ( $ db ? $ db : \ Config :: get ( 'db.active' ) ) . '.charset' , null ) ; if ( empty ( $ charset ) ) { return '' ; } $ collation or $ collation = ... | Formats the default charset . |
2,816 | public static function add_foreign_key ( $ table , $ foreign_key ) { if ( ! is_array ( $ foreign_key ) ) { throw new InvalidArgumentException ( 'Foreign key for add_foreign_key() must be specified as an array' ) ; } $ sql = 'ALTER TABLE ' ; $ sql .= \ DB :: quote_identifier ( \ DB :: table_prefix ( $ table , static :: ... | Adds a single foreign key to a table |
2,817 | public static function drop_foreign_key ( $ table , $ fk_name ) { $ sql = 'ALTER TABLE ' ; $ sql .= \ DB :: quote_identifier ( \ DB :: table_prefix ( $ table , static :: $ connection ) ) . ' ' ; $ sql .= 'DROP FOREIGN KEY ' . \ DB :: quote_identifier ( $ fk_name ) ; return \ DB :: query ( $ sql , \ DB :: UPDATE ) -> ex... | Drops a foreign key from a table |
2,818 | public static function process_foreign_keys ( $ foreign_keys , $ db = null ) { if ( ! is_array ( $ foreign_keys ) ) { throw new \ Database_Exception ( 'Foreign keys on create_table() must be specified as an array' ) ; } $ fk_list = array ( ) ; foreach ( $ foreign_keys as $ definition ) { if ( empty ( $ definition [ 'ke... | Returns string of foreign keys |
2,819 | public static function truncate_table ( $ table , $ db = null ) { return \ DB :: query ( 'TRUNCATE TABLE ' . \ DB :: quote_identifier ( \ DB :: table_prefix ( $ table , $ db ? $ db : static :: $ connection ) , $ db ? $ db : static :: $ connection ) , \ DB :: DELETE ) -> execute ( $ db ? $ db : static :: $ connection ) ... | Truncates a table . |
2,820 | public static function table_exists ( $ table , $ db = null ) { try { \ DB :: select ( ) -> from ( $ table ) -> limit ( 1 ) -> execute ( $ db ? $ db : static :: $ connection ) ; return true ; } catch ( \ Database_Exception $ e ) { $ connection = \ Database_Connection :: instance ( $ db ? $ db : static :: $ connection )... | Checks if a given table exists . |
2,821 | public function getRequest ( $ master = true ) { if ( ! $ master ) { return ServerRequestFactory :: make ( ) ; } if ( ! $ this -> request ) { $ this -> request = ServerRequestFactory :: make ( ) ; } return $ this -> request ; } | Gets the request . |
2,822 | public function icons ( array $ icons = null ) { foreach ( $ this -> fixIconsArray ( ( $ icons ? : $ this -> icons ) ) as $ icon ) { $ this -> add ( $ icon ) ; } return $ this ; } | add icons based on cofig array |
2,823 | protected function fixIconsArray ( array $ icons ) { $ array = [ ] ; foreach ( $ icons as $ rel => $ data ) { foreach ( ( array ) $ data [ 'sizes' ] as $ size ) { $ array [ ] = array_merge_recursive ( [ 'rel' => $ rel , 'sizes' => "{$size}x{$size}" , 'href' => sprintf ( $ data [ 'pattern' ] , $ size ) , ] , ( isset ( $... | fix icons data into usable array |
2,824 | public function getGroup ( ) { if ( - 1 === $ this -> index || ! $ this -> valid ( ) ) { return null ; } return $ this -> processors [ $ this -> index ] [ 1 ] [ 'group' ] ?? null ; } | Gets the name of a group the iterator points to . |
2,825 | public function getProcessorId ( ) { if ( - 1 === $ this -> index || ! $ this -> valid ( ) ) { return null ; } return $ this -> processors [ $ this -> index ] [ 0 ] ; } | Gets the id of a processor the iterator points to . |
2,826 | public function getProcessorAttributes ( ) { if ( - 1 === $ this -> index || ! $ this -> valid ( ) ) { return null ; } return $ this -> processors [ $ this -> index ] [ 1 ] ; } | Gets all attributes of a processor the iterator points to . |
2,827 | protected function nextApplicable ( ) { $ this -> index ++ ; while ( $ this -> index <= $ this -> maxIndex ) { $ applicable = $ this -> applicableChecker -> isApplicable ( $ this -> context , $ this -> processors [ $ this -> index ] [ 1 ] ) ; if ( ApplicableCheckerInterface :: NOT_APPLICABLE !== $ applicable ) { break ... | Moves forward to next applicable processor |
2,828 | public function match ( string $ word ) { $ this -> processAbbreviations ( ) ; $ word = strtolower ( $ word ) ; if ( $ this -> abbreviations && isset ( $ this -> abbreviations [ $ word ] ) ) { return $ this -> abbreviations [ $ word ] ; } return false ; } | Return a single matching word if it exists . |
2,829 | public function suggest ( string $ word ) { $ this -> processAbbreviations ( ) ; $ word = strtolower ( $ word ) ; $ suggestions = [ ] ; if ( $ this -> abbreviations ) { $ len = mb_strlen ( $ word ) ; foreach ( $ this -> words as $ w ) { if ( substr ( $ w , 0 , $ len ) === $ word ) { $ suggestions [ ] = $ w ; } } } retu... | Obtain a list of possible word matches . |
2,830 | private static function useMcryptBacking ( ) { if ( ! extension_loaded ( self :: BACKING_MCRYPT ) ) { throw new \ RuntimeException ( 'Can not use mcrypt backing, extension mcrypt not available' ) ; } $ engine = mcrypt_module_open ( MCRYPT_DES , '' , 'ecb' , '' ) ; $ engineiv = mcrypt_create_iv ( mcrypt_enc_get_iv_size ... | switches backing to mcrypt |
2,831 | private static function useOpenSslBacking ( ) { if ( ! extension_loaded ( self :: BACKING_OPENSSL ) ) { throw new \ RuntimeException ( 'Can not use openssl backing, extension openssl not available' ) ; } $ key = md5 ( uniqid ( ) ) ; $ iv = substr ( md5 ( uniqid ( ) ) , 0 , openssl_cipher_iv_length ( 'des' ) ) ; self ::... | switches backing to openssl |
2,832 | private static function usePlaintextBacking ( ) { self :: $ encrypt = function ( $ value ) { return base64_encode ( $ value ) ; } ; self :: $ decrypt = function ( $ value ) { return base64_decode ( $ value ) ; } ; } | switches backing to base64 encoding |
2,833 | public static function create ( $ string ) : self { if ( $ string instanceof self ) { return $ string ; } if ( empty ( $ string ) ) { throw new \ InvalidArgumentException ( 'Given string was null or empty, if you explicitly want to' . ' create a Secret with value null use' . ' Secret::forNull()' ) ; } $ self = new stat... | creates an instance for given characters |
2,834 | public function unveil ( ) { if ( ! $ this -> isContained ( ) ) { throw new \ LogicException ( 'An error occurred during string encryption.' ) ; } if ( $ this -> isNull ( ) ) { return null ; } $ decrypt = self :: $ decrypt ; return $ decrypt ( self :: $ store [ $ this -> id ] [ 'payload' ] ) ; } | retrieve secured characters |
2,835 | public function substring ( int $ start , int $ length = null ) : self { if ( $ this -> isNull ( ) ) { return $ this ; } $ substring = null === $ length ? substr ( $ this -> unveil ( ) , $ start ) : substr ( $ this -> unveil ( ) , $ start , $ length ) ; if ( false === $ substring ) { throw new \ InvalidArgumentExceptio... | returns a substring of the secured string as a new Secret instance |
2,836 | public function setThrowable ( \ Throwable $ throwable ) : Event { if ( $ this -> getName ( ) !== definitions \ Events :: DEBUG_THROWABLE_AFTER ) { $ this -> throwable = $ throwable ; } return $ this ; } | Sets the Throwable to be handled . |
2,837 | public static function process ( $ file = NULL ) { $ exists = isset ( self :: $ data [ self :: $ level ] ) ; if ( $ exists ) { $ variables = self :: $ data [ self :: $ level ] ; foreach ( $ variables as $ key => $ value ) { global $ $ key ; $ $ key = $ value ; } } if ( $ file ) { require $ file ; } } | Define global variables from view level data Also require view file if need |
2,838 | protected function replaceDynamicExpression ( $ matches ) { $ program = new DynamicSQLProgram ( $ matches [ 2 ] ) ; $ value = $ program -> executeWith ( $ this -> buildEnvironment ( $ this -> config ) , $ this -> args ) ; if ( ! empty ( $ matches [ 1 ] ) ) return $ this -> castParameter ( $ value , $ matches [ 1 ] ) ; ... | Replaces a dynamic sql expression |
2,839 | public static function getCarrierShortName ( $ className ) { if ( 0 === strpos ( $ className , '\\' ) ) { $ className = substr ( $ className , 1 ) ; } if ( 0 === strpos ( $ className , 'Omniship\\' ) ) { return trim ( str_replace ( '\\' , '_' , substr ( $ className , 8 , - 7 ) ) , '_' ) ; } return '\\' . $ className ; ... | Resolve a carrier class to a short name . |
2,840 | public static function getCarrierClassName ( $ shortName ) { if ( 0 === strpos ( $ shortName , '\\' ) ) { return $ shortName ; } $ shortName = str_replace ( '_' , '\\' , $ shortName ) ; if ( false === strpos ( $ shortName , '\\' ) ) { $ shortName .= '\\' ; } return '\\Omniship\\' . $ shortName . 'Carrier' ; } | Resolve a short carrier name to a full namespaced carrier class . |
2,841 | public function authenticate ( ClientInterface $ client ) { $ account = Account :: find ( ) -> byClient ( $ client ) -> one ( ) ; if ( ! $ this -> module -> enableRegistration && ( $ account === null || $ account -> user === null ) ) { Yii :: $ app -> session -> setFlash ( 'danger' , Yii :: t ( 'users' , 'Registration ... | Tries to authenticate user via social network . If user has already used this network s account he will be logged in . Otherwise it will try to create new user account . |
2,842 | private function build_query ( ) { if ( ! empty ( $ this -> _query ) ) { return $ this -> _query ; } $ query = array ( ) ; foreach ( $ this -> _query_terms as $ k => $ v ) { $ query [ ] = "$k:$v" ; } return implode ( ' AND ' , $ query ) ; } | Builds a SOLR query . |
2,843 | public function get_results ( ) { $ query = $ this -> build_query ( ) ; $ query = $ this -> _solrclient -> createSelect ( $ query ) ; if ( isset ( $ this -> _query_modifiers [ 'limit' ] ) ) { $ query -> setRows ( $ this -> _query_modifiers [ 'limit' ] ) ; } if ( isset ( $ this -> _query_modifiers [ 'offset' ] ) ) { $ q... | Return the results . |
2,844 | private function searchCompletion ( $ partial , $ filter , & $ ofs , & $ matches , & $ numMatches ) { $ ret = $ partial ; $ i = strlen ( $ ret ) ; $ numMatches = 0 ; $ matches = array ( ) ; $ ofs = 0 ; $ autocomplete = $ filter -> getResultFor ( $ ret ) ; foreach ( $ autocomplete as $ value ) { if ( 0 === strpos ( $ va... | Find all valid completion |
2,845 | private function substituteFilter ( $ matches ) { if ( isset ( $ matches [ 1 ] ) && isset ( $ this -> filters [ $ matches [ 1 ] ] ) ) { return $ this -> filters [ $ matches [ 1 ] ] ; } return "([/][\w-\._@%]*)" ; } | Filters for regexp |
2,846 | protected function initializeBundles ( ) { parent :: initializeBundles ( ) ; foreach ( $ this -> registerBundles ( ) as $ bundle ) { if ( \ method_exists ( $ bundle , "extendBundle" ) ) { $ name = $ bundle -> getName ( ) ; $ extenBundle = $ bundle -> extendBundle ( ) ; $ this -> bundleMap [ $ name ] [ ] = $ this -> bun... | Initializes the data structures related to the bundle management . |
2,847 | private function determineUrl ( ) { $ sUrl = '' ; $ sRequestUri = $ this -> _oConfig -> get ( 'request_uri' ) ; $ sUrl = trim ( $ sRequestUri , '/' ) ; $ sUrl = preg_replace ( '/\?.*/' , '' , $ sUrl ) ; $ sUrl = preg_replace ( '#index$#i' , '' , $ sUrl ) ; if ( empty ( $ sUrl ) ) { return 'index' ; } return $ sUrl ; } | Set up routing |
2,848 | public function validate ( $ subject ) : bool { if ( \ is_array ( $ this -> schema [ 'required' ] ) ) { foreach ( $ this -> schema [ 'required' ] as $ propertyName ) { if ( ! \ array_key_exists ( $ propertyName , $ subject ) ) { return false ; } } } return true ; } | Validates subject against required |
2,849 | private function createDeleteForm ( Category $ category ) { return $ this -> createFormBuilder ( ) -> setAction ( $ this -> generateUrl ( 'ecommerce_category_delete' , array ( 'id' => $ category -> getId ( ) ) ) ) -> setMethod ( 'DELETE' ) -> getForm ( ) ; } | Creates a form to delete a Category entity . |
2,850 | private function setLink ( $ type , $ title , $ href ) { $ this -> links [ $ type ] = [ 'rel' => $ type , 'title' => $ title , 'href' => $ href ] ; } | Internal method to add links |
2,851 | public function dispatch ( ServerRequestInterface $ request ) : array { $ uri = $ request -> getUri ( ) -> getPath ( ) ; if ( ! $ uri || $ uri [ 0 ] !== '/' ) { $ uri = '/' . $ uri ; } return $ this -> createDispatcher ( ) -> dispatch ( $ request -> getMethod ( ) , $ uri ) ; } | Dispatch router for HTTP request |
2,852 | public function removeRouteByName ( string $ name ) : bool { if ( $ route = $ this -> getRouteByName ( $ name ) ) { unset ( $ this -> routes [ $ route -> getIdentifier ( ) ] ) ; return true ; } return false ; } | Remove named route |
2,853 | public function getRouteByIdentifier ( int $ identifier ) { return isset ( $ this -> routes [ $ identifier ] ) ? $ this -> routes [ $ identifier ] : null ; } | Get Route By Identifier |
2,854 | public function addSubdirectories ( array $ directories ) { foreach ( $ directories as $ dir ) { $ this -> subdirs [ $ dir ] = $ dir ; } return $ this ; } | Add additional subdirectories within the module directory that should be searched for Module . php |
2,855 | public function setOptions ( $ options ) { if ( ! is_array ( $ options ) && ! ( $ options instanceof \ Traversable ) ) { return $ this ; } foreach ( $ options as $ name => $ option ) { switch ( strtolower ( strtr ( $ name , '-' , '' ) ) ) { case 'pathmanager' : $ this -> setPathManager ( $ option ) ; break ; case 'subd... | Following options are allowed |
2,856 | public static function init ( ) { self :: $ app = Kecik :: getInstance ( ) ; ; self :: $ modelUser = '\\Model\\' . self :: $ app -> config -> get ( 'auth.model' ) ; self :: $ postUsername = self :: $ app -> config -> get ( 'auth.post_username' ) ; self :: $ postPassword = self :: $ app -> config -> get ( 'auth.post_pas... | Initialize for Auth Class |
2,857 | public static function isLogin ( ) { if ( isset ( $ _SESSION [ md5 ( 'login' . self :: $ app -> url -> baseUrl ( ) ) ] ) && base64_decode ( $ _SESSION [ md5 ( 'login' . self :: $ app -> url -> baseUrl ( ) ) ] ) == 'TRUE' ) { return TRUE ; } else { return FALSE ; } } | Check of login status |
2,858 | public static function level ( ) { if ( isset ( $ _SESSION [ md5 ( 'level' . self :: $ app -> url -> baseUrl ( ) ) ] ) ) { return base64_decode ( $ _SESSION [ md5 ( 'level' . self :: $ app -> url -> baseUrl ( ) ) ] ) ; } else { return '' ; } } | Get current level from user logged |
2,859 | public function addTo ( Component $ parent ) { $ parent -> add ( $ this ) ; $ this -> parent = $ parent ; return $ this ; } | Adds component to given parent component |
2,860 | public function getChildren ( $ recursive = true , $ includeInactiveFields = false ) { $ children = array ( ) ; foreach ( $ this -> children as $ component ) if ( $ component -> isActive ( ) || $ includeInactiveFields ) { array_push ( $ children , $ component ) ; if ( $ recursive ) $ children = array_merge ( $ children... | Returns a flat list of the component s enabled children |
2,861 | public function hasChild ( $ child , $ recursive = true ) { foreach ( $ this -> children as $ component ) if ( $ component == $ child || ( $ recursive && $ component -> hasChild ( $ child , true ) ) ) return true ; return false ; } | Check if given component is child |
2,862 | public function getAttributesString ( ) { $ attributePairs = array ( ) ; foreach ( $ this -> getAttributes ( ) as $ attr => $ value ) $ attributePairs [ ] = sprintf ( '%s="%s"' , $ attr , str_replace ( '"' , '"' , $ value ) ) ; return implode ( ' ' , $ attributePairs ) ; } | Gets all HTML attributes |
2,863 | public function getProperty ( PHPStanClassReflection $ reflection , string $ property ) : PHPStanPropertyReflection { $ native = $ reflection -> getNativeReflection ( ) ; if ( $ native -> hasMethod ( "getter_" . $ property ) ) return $ this -> getUnderscoreGetter ( $ reflection , $ property ) ; return null ; } | Retrieve the given property if it does indeed exist |
2,864 | public function returnFullDataIo ( ) { $ aDiskIo = $ this -> getSNMP ( ) -> realWalk1d ( self :: OID_DISK_IO ) ; $ aReturn = Array ( ) ; $ aReturn [ 'index' ] = $ aDiskIo [ self :: OID_DISK_IO_INDEX ] ; $ aReturn [ 'device' ] = $ aDiskIo [ self :: OID_DISK_IO_DEVICE ] ; $ aReturn [ 'disk_io_read' ] = $ aDiskIo [ self :... | Returns Full Data Io |
2,865 | private function freePercentCalculation ( array $ usedPercent = array ( ) ) { $ aReturn = array ( ) ; foreach ( $ usedPercent as $ keyUsedPercent => $ valueUsedPercent ) { $ aReturn [ $ keyUsedPercent ] = ( $ valueUsedPercent > 0 ) ? ( 100 - $ valueUsedPercent ) : 100 ; } return $ aReturn ; } | Calculation Free Percent Disk Path |
2,866 | public function setData ( array $ data ) { foreach ( $ data as $ d ) { if ( ! $ this -> isValid ( $ d ) ) { throw new \ Exception ( 'Data Provided invalid structure.' ) ; } } if ( $ this -> getNoConflictMode ( ) ) { $ scriptItem = array ( 'mode' => 'script' , 'content' => ( $ this -> getNoConflictHandler ( ) ) ? 'var '... | Set data to decorate |
2,867 | public function toString ( ) { $ items = $ this -> data ; $ attachedBaseLib = false ; $ return = array ( 'file' => '' , 'script' => '' ) ; foreach ( $ items as $ item ) { if ( $ item [ 'mode' ] == 'file' && isset ( $ item [ 'attributes' ] [ 'src' ] ) ) { if ( $ item [ 'attributes' ] [ 'src' ] == $ this -> getBaseLibrar... | Render the placeholder as script codes |
2,868 | protected function overrideScript ( $ script ) { $ noConflict = $ this -> getNoConflictMode ( ) ; if ( ! $ noConflict ) { return $ script ; } $ jQ = ( $ this -> getNoConflictHandler ( ) ) ? $ this -> getNoConflictHandler ( ) : 'jQuery' ; preg_match_all ( '/\([\s\n]*function[\s\n]*\([\s\n]*\$[\s\n]*\)[\s\n]*{([\w|\D]*)}... | Correct scripts to noConflict mode |
2,869 | public function isValid ( $ value ) { if ( ! is_array ( $ value ) || ! isset ( $ value [ 'mode' ] ) || ( ! isset ( $ value [ 'content' ] ) && ! isset ( $ value [ 'attributes' ] ) ) ) { return false ; } return true ; } | Is the script provided valid? |
2,870 | public function add ( ResourceSerializerSupportableInterface $ supportable , ResourceSerializerInterface $ serializer ) : void { $ this -> map [ ] = [ $ supportable , $ serializer ] ; } | Add the resource normalizer to registry |
2,871 | public function has ( ) { if ( empty ( $ this -> _message ) ) throw new RuntimeException ( "A message has not been set" ) ; return ( bool ) preg_match ( $ this -> _regex , $ this -> _message ) ; } | Check if the message actually contains what we re trying to strip . |
2,872 | public function strip ( ) { if ( empty ( $ this -> _message ) ) throw new RuntimeException ( "A message has not been set" ) ; $ messageBody = $ this -> _message ; if ( preg_match_all ( $ this -> _regex , $ messageBody , $ matches ) ) { foreach ( $ matches [ 0 ] as $ k => $ header ) { $ startPos = strpos ( $ messageBody... | Remove unwanted section |
2,873 | private function cast ( $ value , $ type ) { switch ( $ type ) { case 'bool' : return ( bool ) $ value ; case 'float' : return ( float ) $ value ; case 'int' : return ( int ) $ value ; default : return $ value ; } } | Cast the value . |
2,874 | private function findOption ( $ key , $ short , $ argv ) { foreach ( $ argv as $ i => $ arg ) { if ( preg_match ( '/^-(-)?([\w-]+)(?:=(.*))?$/s' , $ arg , $ match ) ) { if ( ( ! empty ( $ match [ 1 ] ) && $ match [ 2 ] === $ key ) || ( empty ( $ match [ 1 ] ) && $ match [ 2 ] === $ short ) ) { $ value = isset ( $ match... | Find the option . |
2,875 | private function printParameters ( $ name , $ def , $ length ) { $ name .= str_repeat ( ' ' , 2 + $ length - strlen ( $ name ) ) ; $ this -> stdio -> write ( $ name , false , [ Stdio :: STYLE_GREEN ] ) ; $ this -> stdio -> write ( trim ( $ def [ 'description' ] ? : '' ) ) ; if ( array_key_exists ( 'default' , $ def ) )... | Print arguments and options . |
2,876 | public static function to360Range ( $ value ) { if ( $ value > 360 ) { return $ value * 1.0 - floor ( $ value / 360 ) * 360 ; } elseif ( $ value < 0 ) { return $ value * 1.0 + ( floor ( - $ value / 360 ) + 1 ) * 360 ; } return $ value ; } | Returns angle converted to 0 - 360 range . |
2,877 | public function getNodeType ( ) { static $ nodeType ; return $ nodeType ?? $ nodeType = $ this -> nodeType ?? ( static function ( $ className ) { return strtolower ( preg_replace ( '/(?<=\\w)([A-Z])/' , '_$1' , preg_replace ( '/^(?:\\w+\\\\)*(\\w+)Node$/' , '$1' , $ className ) ) ) ; } ) ( get_class ( $ this ) ) ; } | Getting the type of this node . |
2,878 | protected function loadConfig ( string $ name , IConfigProvider $ configProvider ) { $ config = $ configProvider -> getConfig ( $ this -> nodeType . '_nodes' , $ name ) ? : $ configProvider -> getConfig ( $ this -> nodeType . '_nodes' , '*' ) ; if ( isset ( $ config [ 'multiple' ] ) ) { foreach ( $ config [ 'multiple' ... | Loading node configuration . |
2,879 | public function assemble ( $ params = [ ] ) { $ params = array_merge ( $ this -> defaults , $ params ) ; $ parts = $ this -> parts ; $ return = [ ] ; foreach ( $ parts as $ part ) { if ( 0 === strpos ( $ part , '~' ) && 1 !== strpos ( $ part , ':' ) ) { continue ; } if ( 0 === strpos ( $ part , ':' ) ) { if ( ! isset (... | Assemble the route . |
2,880 | protected function compile ( ) { $ this -> parts = $ parts = preg_split ( '#\/#' , $ this -> path , - 1 , PREG_SPLIT_NO_EMPTY ) ; $ regex = '' ; foreach ( $ parts as & $ part ) { $ control = substr ( $ part , 0 , 2 ) ; if ( false !== strpos ( $ control , ':' ) ) { if ( ! preg_match ( '#\A(~)?(:){1}[a-zA-Z0-9]+\Z#' , $ ... | Compiles route . |
2,881 | public function serialize ( ) { return serialize ( [ $ this -> path , $ this -> schemes , $ this -> methods , $ this -> defaults , $ this -> constraints , $ this -> parts , $ this -> compiled , ] ) ; } | Serializes the route . |
2,882 | public function unserialize ( $ serialized ) { list ( $ this -> path , $ this -> schemes , $ this -> methods , $ this -> defaults , $ this -> constraints , $ this -> parts , $ this -> compiled ) = unserialize ( $ serialized ) ; } | Constructs route . |
2,883 | public function variablize ( $ word ) : string { $ word = $ this -> camelize ( $ word ) ; return \ strtolower ( $ word [ 0 ] ) . \ substr ( $ word , 1 ) ; } | Same as camelize but first char is in lowercase . Converts a word like send_email to sendEmail . It will remove non alphanumeric character from the word so who s online will be converted to whoSOnline |
2,884 | public function pluck ( $ columnName ) { if ( is_array ( $ columnName ) ) { $ columnNames = $ columnName ; } else { $ columnNames = func_get_args ( ) ; } $ select = clone $ this -> select ; $ select -> columns ( $ columnNames ) ; $ records = $ this -> loadRecords ( $ select ) ; if ( count ( $ columnNames ) == 1 ) { ret... | Pass many string values or an array of strings . |
2,885 | public function count ( ) { $ select = clone $ this -> select ; $ select -> reset ( Select :: COLUMNS ) ; $ select -> columns ( [ 'c' => $ this -> raw ( 'COUNT(*)' ) ] ) ; $ rows = $ this -> loadRecords ( $ select ) ; if ( isset ( $ rows [ 0 ] [ 'c' ] ) ) { return ( int ) $ rows [ 0 ] [ 'c' ] ; } return false ; } | Issues a count query and returns the result . |
2,886 | public static function fail ( $ format , $ args = null , $ _ = null ) { throw new EnsureException ( vsprintf ( $ format , array_slice ( func_get_args ( ) , 1 ) ) ) ; } | Simply fails with the given message in sprintf format . May be used when the code has reached a point where it shouldn t be for example the default case of a switch . |
2,887 | private function _processTypeCondition ( $ pField , $ pType , $ pValue ) { $ escapedField = '`' . $ pField . '`' ; switch ( $ pType ) { case self :: IN : case self :: NOTIN : if ( is_array ( $ pValue ) ) { $ markers = '?' . str_repeat ( ', ?' , count ( $ pValue ) - 1 ) ; return sprintf ( $ pType , $ escapedField , $ ma... | Prepare the conditions for PDO . |
2,888 | private function _processTypeValue ( $ pType , $ pValue , & $ pPrepared ) { if ( is_array ( $ pValue ) ) { foreach ( $ pValue as $ subValue ) { $ pPrepared [ ] = ( string ) $ subValue ; } } else if ( $ pValue !== NULL ) { $ pPrepared [ ] = $ pValue ; } } | Prepare the values for PDO . |
2,889 | public function getPreparedConditions ( $ pDbContainer ) { $ prepared = array ( ) ; if ( ! empty ( $ this -> _conditions ) ) { foreach ( $ this -> _conditions as $ field => $ condition ) { $ subPrepared = array ( ) ; if ( is_array ( $ condition ) ) { foreach ( $ condition as $ type => $ value ) { if ( is_int ( $ type )... | Return a PDO prepared string representation of the conditions . |
2,890 | public function getPreparedValues ( ) { $ prepared = array ( ) ; if ( ! empty ( $ this -> _conditions ) ) { foreach ( $ this -> _conditions as $ condition ) { if ( is_array ( $ condition ) ) { foreach ( $ condition as $ type => $ value ) { if ( is_int ( $ type ) and is_array ( $ value ) ) { foreach ( $ value as $ subCo... | Return a PDO array with the prepared values . |
2,891 | public function user ( $ username , Bag $ bag = null ) { $ data = $ this -> createData ( array ( 'api_token' => $ this -> apiToken , 'username' => strtoupper ( $ username ) , ) , $ bag ) ; $ response = $ this -> send ( 'yo/' , InternalRequestInterface :: METHOD_POST , $ data ) ; $ content = json_decode ( $ response -> ... | Yo an user with or without a Bag object . |
2,892 | public function create ( $ username , $ password , $ callbackUrl = '' , $ email = '' , $ description = '' , $ needsLocation = false ) { $ data = array ( 'new_account_username' => strtoupper ( $ username ) , 'new_account_passcode' => $ password , 'callback_url' => $ callbackUrl , 'email' => $ email , 'description' => $ ... | Create new Yo account . |
2,893 | public function total ( ) { $ response = $ this -> send ( sprintf ( 'subscribers_count/?api_token=%s' , $ this -> apiToken ) ) ; $ content = json_decode ( $ response -> getBody ( ) ) ; return ( integer ) $ content -> count ; } | Get total of subscribers . |
2,894 | public function exists ( $ username ) { $ response = $ this -> send ( sprintf ( 'check_username/?api_token=%s&username=%s' , $ this -> apiToken , strtoupper ( $ username ) ) ) ; $ content = json_decode ( $ response -> getBody ( ) ) ; return ( boolean ) $ content -> exists ; } | Check if a given username exists or not . |
2,895 | public function getAuthenticateFromChallenge ( ChallengeMessage $ msg ) { $ token = [ 'id' => $ this -> authid , 'exp' => time ( ) + 60 , ] ; $ token = JWT :: encode ( $ token , Security :: salt ( ) ) ; return new AuthenticateMessage ( $ token ) ; } | Get Authenticate message from challenge message |
2,896 | protected function configure ( ) { $ this -> setDescription ( $ this -> shortDesc ) ; foreach ( $ this -> paramsArray as $ nameParam => $ arrayOptions ) { if ( $ arrayOptions [ 'optional' ] ) { $ this -> addOption ( $ nameParam , null , InputOption :: VALUE_OPTIONAL , $ arrayOptions [ 'comment' ] , null ) ; } else { $ ... | Extends configure from Symfony Command Class |
2,897 | public function getOption ( $ flag ) { return isset ( $ this -> options [ $ flag ] ) ? $ this -> options [ $ flag ] : null ; } | Return a single value that matches |
2,898 | public function denormalizeValue ( array $ data ) { $ processed = array ( ) ; foreach ( $ data as $ docId => $ content ) { $ cloned = $ content ; $ keys = array_keys ( $ cloned ) ; $ ofType = array_pop ( $ keys ) ; $ asArray = ( 'array' === $ ofType ) ? true : false ; $ value = $ content [ $ ofType ] ; Assertion :: isJ... | Converts a normalized array to the original value |
2,899 | protected function resolve ( ) { $ this -> content = '' ; $ this -> isBinary = null ; if ( ! self :: $ tmpCookies ) { self :: $ tmpCookies = str_replace ( '//' , '/' , sys_get_temp_dir ( ) . '/embed-cookies.txt' ) ; } $ connection = curl_init ( ) ; curl_setopt_array ( $ connection , [ CURLOPT_RETURNTRANSFER => false , ... | Resolves the current url and get the content and other data |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.