idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
5,100 | public function getCacheDir ( ) { if ( is_null ( $ this -> __project_cache_dir ) ) { $ this -> __project_cache_dir = new File ( "." . uniqid ( ) , $ this -> projectRootDir -> getAbsolutePath ( ) ) ; } return $ this -> __project_cache_dir ; } | Set the Cache directory for this project . |
5,101 | public static function PrepareCache ( $ CacheName , $ ExistingCacheArray = NULL , $ CacheMode = 'flat' ) { if ( ! is_array ( self :: $ Caches ) ) self :: $ Caches = array ( ) ; if ( $ CacheName != 'locale' ) return ; if ( ! array_key_exists ( $ CacheName , self :: $ Caches ) ) { self :: $ Caches [ $ CacheName ] = array... | Prepare a cache library for use either by loading it from file filling it with pre existing data in array form or leaving it empty and waiting for new entries . |
5,102 | protected static function Import ( $ CacheName , $ CacheContents , $ AutoSave = FALSE ) { if ( ! array_key_exists ( $ CacheName , self :: $ Caches ) ) return FALSE ; self :: $ Caches [ $ CacheName ] [ 'cache' ] = array_merge ( self :: $ Caches [ $ CacheName ] [ 'cache' ] , $ CacheContents ) ; self :: $ Caches [ $ Cache... | Import an existing well formed cache chunk into the supplied library |
5,103 | public static function ClearCache ( $ CacheName = FALSE ) { Gdn_Autoloader :: SmartFree ( ) ; if ( $ CacheName != 'locale' ) return ; if ( ! array_key_exists ( $ CacheName , self :: $ Caches ) ) return self :: PrepareCache ( $ CacheName ) ; $ UseCache = ( Gdn :: Cache ( ) -> Type ( ) == Gdn_Cache :: CACHE_TYPE_MEMORY &... | Clear the contents of the supplied cache and remove it from disk |
5,104 | public static function CacheReady ( $ CacheName ) { if ( ! array_key_exists ( $ CacheName , self :: $ Caches ) ) return FALSE ; if ( ! sizeof ( self :: $ Caches [ $ CacheName ] [ 'cache' ] ) ) return FALSE ; return TRUE ; } | Detect whether the cache has any items in it |
5,105 | public static function GetCache ( $ CacheName , $ CacheKey ) { if ( $ CacheName != 'locale' ) return ; if ( ! array_key_exists ( $ CacheName , self :: $ Caches ) ) self :: PrepareCache ( $ CacheName ) ; if ( self :: $ Caches [ $ CacheName ] [ 'mode' ] == 'flat' ) $ Target = & self :: $ Caches [ $ CacheName ] [ 'cache' ... | Retrieve an item from the cache |
5,106 | public static function SaveCache ( $ CacheName ) { if ( $ CacheName != 'locale' ) return ; if ( ! array_key_exists ( $ CacheName , self :: $ Caches ) ) return FALSE ; $ UseCache = ( Gdn :: Cache ( ) -> Type ( ) == Gdn_Cache :: CACHE_TYPE_MEMORY && Gdn :: Cache ( ) -> ActiveEnabled ( ) ) ; if ( $ UseCache ) { $ CacheKey... | Save the provided library s data to the on disk location . |
5,107 | public function setReplacements ( array $ replacements ) { $ this -> replacements = array ( ) ; foreach ( $ replacements as $ property => $ value ) { $ this -> replacements [ '%' . $ property . '%' ] = $ value ; } return $ this ; } | Sets the replacements . |
5,108 | public function load ( array $ files , Config $ config = null ) { if ( is_null ( $ config ) ) { $ config = new Config ( ) ; } if ( ! $ this -> isValidFileList ( $ files ) ) { throw new \ RuntimeException ( 'Invalid config file list given. At least one config file must exist.' ) ; } foreach ( $ files as $ file ) { if ( ... | Load multiple config files . Each file gets merged into a single config instance . |
5,109 | public function loadArray ( array $ options , Config $ config = null ) { Assertion :: notEmpty ( $ options ) ; if ( is_null ( $ config ) ) { $ config = new Config ( ) ; } $ options = $ this -> doReplacements ( $ options ) ; $ config -> merge ( new Config ( $ options ) ) ; return $ config ; } | Load a config array . |
5,110 | private function isValidFileList ( array $ files ) { Assertion :: notEmpty ( $ files , 'Files array can\'t be empty' ) ; $ valid = false ; foreach ( $ files as $ file ) { if ( $ this -> isFileExisting ( $ file ) ) { $ valid = true ; } } return $ valid ; } | Check if a valid file list is given . |
5,111 | private function loadFile ( $ file ) { Assertion :: file ( $ file , 'Can\'t parse config file. File does not exist: ' . $ file ) ; $ array = $ this -> parseConfigFile ( $ file ) ; $ array = $ this -> doReplacements ( $ array ) ; return new Config ( $ array ) ; } | Load a config file . |
5,112 | private function parseConfigFile ( $ file ) { Assertion :: file ( $ file , 'Can\'t parse config file. File does not exist: ' . $ file ) ; $ config = Yaml :: parse ( file_get_contents ( $ file ) ) ; if ( is_null ( $ config ) ) { $ config = array ( ) ; } return $ config ; } | Parses config file and returns array . |
5,113 | public function getPaginatorHtml ( Pagination $ pagination , $ routeName = null , $ routeParameters = array ( ) ) { return $ this -> templating -> render ( 'TadckaPaginatorBundle::pagination.html.twig' , array ( 'pagination' => $ pagination , 'route_name' => $ routeName , 'route_parameters' => $ routeParameters , 'pagi... | Get paginator html . |
5,114 | public function init ( $ formatStr , $ removeLeadSpace = true ) { $ this -> _formatStr = preg_replace ( array ( self :: SPEC_FIND . '[aA]/u' , self :: SPEC_FIND . 'H/u' , self :: SPEC_FIND . '[qQ]/u' , self :: SPEC_FIND . 'S/u' , self :: SPEC_FIND . '[tT]/u' ) , array ( '\'$1s\'' , '$1s' , '"$1s"' , '$1s' , '`$1s`' ) ,... | Set format specification string . Can be chained . |
5,115 | public function bind ( $ aIn ) { $ aIn = ( is_array ( $ aIn ) ? array_values ( $ aIn ) : func_get_args ( ) ) ; foreach ( $ this -> _specsToEsc as $ s ) { $ aIn [ $ s ] = preg_replace ( self :: ESCAPE_REG , '\\\\$1' , $ aIn [ $ s ] ) ; } foreach ( $ this -> _specsToHex as $ s ) { $ aIn [ $ s ] = ( $ aIn [ $ s ] === '' ?... | Bind input values to the stored format string by position . May have an array or any number of scalar arguments . |
5,116 | public function listForSelect ( ) { $ object = Country :: orderBy ( 'name' , 'asc' ) -> get ( [ 'id' , 'name' ] ) ; return $ this -> response -> collection ( $ object , CountryForSelectResource :: class ) ; } | List for select |
5,117 | public function getUsers ( $ items ) { $ result = [ ] ; foreach ( $ items as $ item ) { $ result [ ] = new User ( $ item ) ; } return $ result ; } | Returns array of users . |
5,118 | private function getFilters ( ) { $ filters = [ ] ; $ regions = [ 'fieldID' => 'region_id' , 'type' => 'dropDownList' , 'label' => trans ( 'HCRegions::regions_countries.region' ) , 'options' => HCContinents :: all ( ) -> toArray ( ) , 'showNodes' => [ 'name' ] , ] ; $ filters [ ] = addAllOptionToDropDownList ( $ region... | Generating filters required for admin view |
5,119 | public function get ( $ key ) { return isset ( $ this -> _elements [ $ key ] ) ? $ this -> _elements [ $ key ] : null ; } | Returns a value of an element in the list . |
5,120 | protected function _findRecursive ( $ pattern , $ sort = false ) { list ( $ dirs , $ files ) = $ this -> read ( $ sort ) ; $ found = array ( ) ; foreach ( $ files as $ file ) { if ( preg_match ( '/^' . $ pattern . '$/i' , $ file ) ) { $ found [ ] = Folder :: addPathElement ( $ this -> path , $ file ) ; } } $ start = $ ... | Private helper function for findRecursive . |
5,121 | public function inPath ( $ path = '' , $ reverse = false ) { $ dir = Folder :: slashTerm ( $ path ) ; $ current = Folder :: slashTerm ( $ this -> pwd ( ) ) ; if ( ! $ reverse ) { $ return = preg_match ( '/^(.*)' . preg_quote ( $ dir , '/' ) . '(.*)/' , $ current ) ; } else { $ return = preg_match ( '/^(.*)' . preg_quot... | Returns true if the File is in given path . |
5,122 | public function chmod ( $ path , $ mode = false , $ recursive = true , $ exceptions = array ( ) ) { if ( ! $ mode ) { $ mode = $ this -> mode ; } if ( $ recursive === false && is_dir ( $ path ) ) { if ( @ chmod ( $ path , intval ( $ mode , 8 ) ) ) { $ this -> _messages [ ] = __d ( 'cake_dev' , '%s changed to %s' , $ pa... | Change the mode on a directory structure recursively . This includes changing the mode on files as well . |
5,123 | public function tree ( $ path = null , $ exceptions = false , $ type = null ) { if ( ! $ path ) { $ path = $ this -> path ; } $ files = array ( ) ; $ directories = array ( $ path ) ; if ( is_array ( $ exceptions ) ) { $ exceptions = array_flip ( $ exceptions ) ; } $ skipHidden = false ; if ( $ exceptions === true ) { $... | Returns an array of nested directories and files in each directory |
5,124 | public function messages ( $ reset = true ) { $ messages = $ this -> _messages ; if ( $ reset ) { $ this -> _messages = array ( ) ; } return $ messages ; } | get messages from latest method |
5,125 | public function errors ( $ reset = true ) { $ errors = $ this -> _errors ; if ( $ reset ) { $ this -> _errors = array ( ) ; } return $ errors ; } | get error from latest method |
5,126 | public function existsMessage ( $ language , $ category , $ message ) { $ key = $ language . '/' . $ category ; if ( ! isset ( static :: $ _messages [ $ key ] ) ) { static :: $ _messages [ $ key ] = $ this -> loadMessages ( $ category , $ language ) ; } if ( isset ( static :: $ _messages [ $ key ] [ $ message ] ) && st... | Check to exists message translation |
5,127 | protected function getModuleByTransCategory ( $ category ) { foreach ( TranslationsBuilder :: $ transCatToModule as $ pattern => $ module ) { if ( 0 === strpos ( $ category , rtrim ( $ pattern , '*' ) ) ) { return $ module ; } } } | Get module by translation category |
5,128 | public function getCache ( string $ driverName = '' ) : \ Nofuzz \ SimpleCache \ CacheInterface { if ( empty ( $ driverName ) ) { return ( array_values ( $ this -> drivers ) [ 0 ] ?? null ) ; } else { return $ this -> drivers [ strtolower ( $ driverName ) ] ?? null ; } } | Get a generated Cache Driver |
5,129 | public function deleteDependents ( Event $ event , $ ids , $ count ) { $ rfk = $ this -> getRelatedForeignKey ( ) ; $ this -> query ( Query :: UPDATE ) -> where ( $ rfk , $ ids ) -> save ( [ $ rfk => null ] ) ; } | Child records should not be deleted but will have the foreign key modified . Use database level ON DELETE CASCADE for cascading deletion . |
5,130 | public function onSignal ( array $ ids , callable $ onAck ) { $ this -> encoder -> encode ( SignalResponse :: success ( new Signal ( $ ids ) ) ) ; while ( true ) { $ ackRequest = $ this -> decoder -> decode ( SignalAckRequest :: class ) ; try { call_user_func ( $ onAck , $ ackRequest -> isAck ( ) ) ; $ this -> encoder ... | Callback method meant to be called by signal handlers when a new signal is available |
5,131 | public function byUsernameOrEmail ( $ usernameOrEmail ) { if ( filter_var ( $ usernameOrEmail , FILTER_VALIDATE_EMAIL ) ) { return $ this -> byEmail ( $ usernameOrEmail ) ; } return $ this -> byUsername ( $ usernameOrEmail ) ; } | Finds a user by the given email . |
5,132 | public static function make ( array $ server = null ) { $ scheme = UriSchemeFactory :: make ( $ server ) ; $ host = UriHostFactory :: make ( $ server ) ; $ port = UriPortFactory :: make ( $ server ) ; $ path = UriPathFactory :: make ( $ server ) ; $ query = UriQueryFactory :: make ( $ server ) ; $ url = '' ; if ( $ hos... | Makes the instance of Es \ Http \ Uri . |
5,133 | public static function register ( $ defaultDateFormat = 'd/m/Y' ) { Container :: extensionMethod ( 'addDatePicker' , function ( Container $ container , $ name , $ label = NULL ) use ( $ defaultDateFormat ) { $ control = $ container [ $ name ] = new DatePicker ( $ label ) ; $ control -> setDateFormat ( $ defaultDateForm... | Registers method addDatePicker adding DatePicker to form |
5,134 | public function newAction ( ) { $ inventory = new Inventory ( ) ; $ today = new \ DateTime ( ) ; ; $ inventory -> setDate ( $ today ) ; $ inventory -> setUser ( $ this -> getUser ( ) ) ; $ inventory -> setStatus ( Inventory :: STATUS_DRAFT ) ; $ defaultCode = $ this -> getInventoryService ( ) -> getNextCode ( ) ; $ inv... | Displays a form to create a new Inventory entity . |
5,135 | public function createAction ( Request $ request ) { $ inventory = new Inventory ( ) ; $ inventory -> setStatus ( Inventory :: STATUS_DRAFT ) ; $ form = $ this -> createForm ( new InventoryType ( ) , $ inventory ) ; if ( $ form -> handleRequest ( $ request ) -> isValid ( ) ) { $ em = $ this -> getDoctrine ( ) -> getMan... | Creates a new Inventory entity . |
5,136 | public function saveStock ( InventoryItem $ inventoryItem , Request $ request ) { $ answer = $ this -> get ( 'flower.stock.service.inventory' ) -> itemIsValid ( $ inventoryItem ) ; if ( $ answer == true ) { $ inventoryItem -> setStock ( $ request -> get ( 'stock' ) ) ; return true ; } return false ; } | Edits an existing Inventory entity . |
5,137 | public static function nl2br ( $ input ) { $ output = str_replace ( PHP_EOL , '<br />' , $ input ) ; $ output = str_replace ( "\r\n" , '<br />' , $ output ) ; return $ output ; } | My own extended version of nl2br which works in a lot of cases where the standard nl2br doesnot |
5,138 | public static function convertLineEndings ( $ input ) { $ output = str_replace ( "\r\n" , "\n" , $ input ) ; $ output = str_replace ( "\r" , "\n" , $ output ) ; $ output = str_replace ( "\n" , PHP_EOL , $ output ) ; return $ output ; } | Converts any newlines to the systems format . The use of instead of is very important! |
5,139 | public static function encrypt ( $ message , $ key ) { $ md5Key = md5 ( $ key ) ; $ encrypted = mcrypt_encrypt ( MCRYPT_RIJNDAEL_256 , $ md5Key , $ message , MCRYPT_MODE_CBC , md5 ( $ md5Key ) ) ; $ encoded_encryption = base64_encode ( $ encrypted ) ; return $ encoded_encryption ; } | Encrypt a String |
5,140 | public static function decrypt ( $ encrypted_text , $ key ) { $ md5Key = md5 ( $ key ) ; $ decrypted_text = mcrypt_decrypt ( MCRYPT_RIJNDAEL_256 , $ md5Key , base64_decode ( $ encrypted_text ) , MCRYPT_MODE_CBC , md5 ( $ md5Key ) ) ; $ trimmed_decryption = rtrim ( $ decrypted_text , "\0" ) ; return $ trimmed_decryption... | Decrypt a String |
5,141 | private function clearCache ( ) : void { try { $ cacheTag = config ( 'netcore.module-category.cache_tag' ) ; $ isRedis = cache ( ) -> getStore ( ) instanceof RedisStore ; if ( $ cacheTag && $ isRedis ) { cache ( ) -> tags ( [ $ cacheTag ] ) -> flush ( ) ; } else { cache ( ) -> flush ( ) ; } } catch ( Exception $ except... | Clear cache . |
5,142 | private function modifySlugs ( Request & $ request ) : void { $ translations = $ request -> input ( 'translations' , [ ] ) ; $ existingSlugs = [ ] ; $ i = 1 ; foreach ( $ translations as $ iso => $ translationData ) { if ( ! $ slug = array_get ( $ translationData , 'slug' ) ) { continue ; } $ slug = SlugService :: crea... | Check and modify custom slug . |
5,143 | public function getAll ( ) { $ all = parent :: getAll ( ) ; $ res = [ ] ; foreach ( $ all as $ key => $ raw ) { $ res [ $ key ] = $ raw [ 'value' ] ; } return $ res ; } | Get Normalized Data Array |
5,144 | public function getOriginal ( string $ key , $ default = null ) { if ( $ this -> has ( $ key ) ) { return parent :: get ( Formater :: normalize ( $ key ) ) [ 'key' ] ; } return $ default ; } | Get Original Key from any Format |
5,145 | protected function generateMedia ( $ fileName , $ folderReference , $ name , array $ keywordReferencesArray , array $ languagesArray ) { $ folder = $ this -> getReference ( $ folderReference ) ; $ filePath = __DIR__ . '/Files/' . $ fileName ; $ tmpFilePath = $ this -> container -> getParameter ( 'open_orchestra_media_a... | Generate a media |
5,146 | public function getPage ( ) { return $ this -> offset > $ this -> limit ? floor ( $ this -> offset / $ this -> limit ) : 1 ; } | Get current page number . |
5,147 | public function getPages ( ) { return $ this -> total > $ this -> limit ? ceil ( $ this -> total / $ this -> limit ) : 1 ; } | Count all pages . |
5,148 | public function contentType ( $ type = false ) { if ( headers_sent ( ) ) { if ( self :: $ exceptOnHeaders ) { throw new \ Exception ( 'Headers already sent. Content-type cannot be changed.' ) ; } else { return ; } } if ( ! $ type ) { $ type = "text/html" ; } self :: $ contentType = $ type . "; charset=" . strtolower ( ... | Set the HTTP content type |
5,149 | public function redirect ( $ path , $ type = 302 , $ end = true ) { if ( headers_sent ( ) ) { if ( self :: $ exceptOnHeaders ) { throw new \ Exception ( 'Headers already sent. Redirect cannot be initiated.' ) ; } else { return ; } } if ( self :: $ outputBuffering ) { $ this -> cleanBuffer ( ) ; } $ this -> code ( $ typ... | Redirect the client |
5,150 | public function getCommandConfiguration ( $ command ) { $ url = "selendroid/configure/command/{$command}" ; $ result = $ this -> driver -> curl ( $ this -> driver -> factoryCommand ( $ url , WebDriver_Command :: METHOD_GET ) ) ; return isset ( $ result [ 'value' ] ) ? $ result [ 'value' ] : [ ] ; } | Gets command configuration . |
5,151 | public function setCommandConfiguration ( $ command , array $ properties ) { $ url = "selendroid/configure/command/{$command}" ; $ properties [ 'command' ] = $ command ; $ this -> driver -> curl ( $ this -> driver -> factoryCommand ( $ url , WebDriver_Command :: METHOD_POST , $ properties ) ) ; return $ this ; } | Sets command configuration . |
5,152 | public function route ( string $ uri , Response $ response ) : void { $ this -> reroutes ++ ; if ( $ this -> reroutes > 10 ) { FW ( ) -> log -> critical ( 'The request for ' . $ uri . ' has redirected too many times!' ) ; $ response -> setStatusCode ( 508 ) ; return ; } $ url_array = $ this -> processURL ( $ uri ) ; $ ... | Do the routing |
5,153 | protected function processURL ( string $ url ) : array { $ url = trim ( $ url , '/' ) ; $ url_array = explode ( '/' , $ url ) ; return $ url_array ; } | Splits the URL into an array |
5,154 | protected function extractLocale ( array & $ url_array , Response $ response ) : void { if ( count ( $ url_array ) > 0 && preg_match ( '/^([a-z0-9]{2,3})-([a-z0-9]{4}-?)?([a-z0-9]{2,3})?$/i' , $ url_array [ 0 ] ) ) { $ response -> setLocale ( array_shift ( $ url_array ) ) ; } reset ( $ url_array ) ; } | Remove the locale from the first element in the array if one is set . |
5,155 | protected function matchRoute ( array $ url_array ) : array { if ( ! isset ( $ this -> route_definitions ) ) { $ this -> loadRoutes ( ) ; } $ url = '/' . implode ( '/' , $ url_array ) ; $ matches = $ this -> doRouteMatching ( $ url ) ; if ( false === $ matches ) { throw new \ Exception ( 'Unable to route url ' . $ url ... | Take the url pieces and compare them to the routes set in the configuration file to extract variables . |
5,156 | protected function doRouteMatching ( $ url ) { $ matches = array ( ) ; foreach ( $ this -> route_definitions as $ name => $ route ) { if ( preg_match ( $ route [ 'regex' ] , $ url , $ matches ) ) { $ matches [ 0 ] = $ name ; return $ matches ; } } return false ; } | Processs the url . |
5,157 | protected function loadRoutes ( ) : void { $ routeConfig = Core :: i ( ) -> config -> getConfiguration ( 'routes' ) ; if ( isset ( $ routeConfig [ 'default' ] ) ) { $ default_route = $ routeConfig [ 'default' ] ; unset ( $ routeConfig [ 'default' ] ) ; $ routeConfig [ 'default' ] = $ default_route ; } foreach ( $ route... | Load the routes from the configuration |
5,158 | protected function newDepance ( ) { if ( is_array ( $ this -> depandeClass ) && ! empty ( $ this -> depandeClass ) ) { if ( ! isset ( $ this -> depandeClass [ 'class' ] ) ) { $ depanceModels = [ ] ; foreach ( $ this -> depandeClass as $ key => $ depance ) { $ name = StringHelper :: basename ( $ depance [ 'class' ] ) ; ... | new depance model |
5,159 | public function has ( $ key , $ locale = null ) { $ locale = $ this -> locale ( $ locale ) ; return $ this -> get ( $ key , [ ] , $ locale ) !== $ key ; } | Check if has translation . |
5,160 | public static function getCurrentUser ( $ dontThrowException = false ) { if ( ! self :: $ currentUser instanceof MbWpUser ) { try { self :: $ currentUser = self :: findOrFail ( get_current_user_id ( ) ) ; } catch ( \ Exception $ e ) { self :: $ currentUser = new self ( ) ; self :: $ currentUser -> forceFill ( [ 'ID' =>... | Get current user logged |
5,161 | public function write ( $ file = '' ) { if ( $ file == '' ) { $ file = $ this -> outSourceFile ; } file_put_contents ( $ file , $ this -> generate ( ) ) ; } | Generates the code and writes it to a source file . |
5,162 | public function validate ( $ subject ) : bool { if ( \ is_array ( $ this -> schema [ 'patternProperties' ] ) ) { foreach ( $ this -> schema [ 'patternProperties' ] as $ pattern => $ patternSchema ) { foreach ( $ subject as $ propertyName => $ propertyData ) { if ( \ preg_match ( sprintf ( '/%s/' , $ pattern ) , $ prope... | Validates subject against patternProperties |
5,163 | public static function countDecimals ( float $ value ) { return ( int ) $ value == $ value ? 0 : ( strlen ( $ value ) - strrpos ( $ value , '.' ) - 1 ) ; } | Returns the number of decimal places contained in the given number . |
5,164 | protected function getAttrAlias ( Attr $ attr ) { $ stringPath = $ attr -> getStringPath ( ) ; if ( array_key_exists ( $ stringPath , $ this -> joins ) ) return [ $ this -> joins [ $ stringPath ] -> getAlias ( ) , $ this -> joins [ $ stringPath ] -> getProfile ( ) ] ; $ path = $ attr -> getPath ( ) ; $ current = $ this... | Obtains an alias for a given Attr instance used in a sql predicate |
5,165 | public function setParent ( $ object ) { if ( ! is_object ( $ object ) ) { throw new \ InvalidArgumentException ( "Expecting object, given: " . gettype ( $ object ) ) ; } $ this -> parent = $ object ; return $ this ; } | Sets the config parent object . |
5,166 | public function set ( $ key , $ value ) { $ previous = $ this -> get ( $ key ) ; parent :: set ( $ key , $ value ) ; return $ previous ; } | Set method returns the previous value . |
5,167 | public final function getHeaderArrayAsString ( ehough_shortstop_api_HttpMessage $ message ) { $ headers = $ message -> getAllHeaders ( ) ; if ( ! is_array ( $ headers ) ) { return '' ; } $ toReturn = '' ; foreach ( $ headers as $ name => $ value ) { $ toReturn .= "$name: $value\r\n" ; } return $ toReturn ; } | Gets a string representation of the headers of the given HTTP message . |
5,168 | public final function getArrayOfHeadersFromRawHeaderString ( $ rawHeaderString ) { if ( is_string ( $ rawHeaderString ) ) { $ rawHeaderString = str_replace ( "\r\n" , "\n" , $ rawHeaderString ) ; $ rawHeaderString = preg_replace ( '/\n[ \t]/' , ' ' , $ rawHeaderString ) ; $ headers = explode ( "\n" , $ rawHeaderString ... | Given a raw string of headers return an associative array of the headers . |
5,169 | public function addRootSkills ( $ id , $ data ) { $ model = $ this -> get ( $ id ) ; if ( $ model === null ) { return new NotFound ( [ 'message' => 'Kstruktur not found.' ] ) ; } try { $ this -> doAddRootSkills ( $ model , $ data ) ; } catch ( ErrorsException $ e ) { return new NotValid ( [ 'errors' => $ e -> getErrors... | Adds RootSkills to Kstruktur |
5,170 | public function create ( $ data ) { $ serializer = Kstruktur :: getSerializer ( ) ; $ model = $ serializer -> hydrate ( new Kstruktur ( ) , $ data ) ; $ this -> hydrateRelationships ( $ model , $ data ) ; $ this -> dispatch ( KstrukturEvent :: PRE_CREATE , $ model , $ data ) ; $ this -> dispatch ( KstrukturEvent :: PRE... | Creates a new Kstruktur with the provided data |
5,171 | public function removeRootSkills ( $ id , $ data ) { $ model = $ this -> get ( $ id ) ; if ( $ model === null ) { return new NotFound ( [ 'message' => 'Kstruktur not found.' ] ) ; } try { $ this -> doRemoveRootSkills ( $ model , $ data ) ; } catch ( ErrorsException $ e ) { return new NotValid ( [ 'errors' => $ e -> get... | Removes RootSkills from Kstruktur |
5,172 | public function updateRootSkills ( $ id , $ data ) { $ model = $ this -> get ( $ id ) ; if ( $ model === null ) { return new NotFound ( [ 'message' => 'Kstruktur not found.' ] ) ; } try { $ this -> doUpdateRootSkills ( $ model , $ data ) ; } catch ( ErrorsException $ e ) { return new NotValid ( [ 'errors' => $ e -> get... | Updates RootSkills on Kstruktur |
5,173 | protected function doRemoveRootSkills ( Kstruktur $ model , $ data ) { $ errors = [ ] ; foreach ( $ data as $ entry ) { if ( ! isset ( $ entry [ 'id' ] ) ) { $ errors [ ] = 'Missing id for Skill' ; } else { $ related = SkillQuery :: create ( ) -> findOneById ( $ entry [ 'id' ] ) ; $ model -> removeRootSkill ( $ related... | Interal mechanism to remove RootSkills from Kstruktur |
5,174 | protected function doUpdateRootSkills ( Kstruktur $ model , $ data ) { SkillQuery :: create ( ) -> filterByKstrukturRoot ( $ model ) -> delete ( ) ; $ errors = [ ] ; foreach ( $ data as $ entry ) { if ( ! isset ( $ entry [ 'id' ] ) ) { $ errors [ ] = 'Missing id for Skill' ; } else { $ related = SkillQuery :: create ( ... | Internal update mechanism of RootSkills on Kstruktur |
5,175 | public static function Tttai ( $ tt1 , $ tt2 , & $ tai1 , & $ tai2 ) { $ dtat = TTMTAI / DAYSEC ; if ( $ tt1 > $ tt2 ) { $ tai1 = $ tt1 ; $ tai2 = $ tt2 - $ dtat ; } else { $ tai1 = $ tt1 - $ dtat ; $ tai2 = $ tt2 ; } return 0 ; } | - - - - - - - - - i a u T t t a i - - - - - - - - - |
5,176 | public static function isInt ( $ number , $ gt = false , $ lt = false ) { if ( is_string ( $ number ) ) { if ( trim ( $ number ) == '' ) return false ; $ sign = '' ; if ( $ number [ 0 ] == '+' || $ number [ 0 ] == '-' ) { $ sign = $ number [ 0 ] ; $ number = substr ( $ number , 1 ) ; } $ number = ( $ sign == '-' ? '-' ... | Checks if the number is an int and can be check the range |
5,177 | public static function isFloat ( $ number , $ gt = false , $ lt = false ) { if ( is_string ( $ number ) ) { if ( trim ( $ number ) == '' ) return false ; $ sign = '' ; if ( $ number [ 0 ] == '+' || $ number [ 0 ] == '-' ) { $ sign = $ number [ 0 ] ; $ number = substr ( $ number , 1 ) ; } $ number = ( $ sign == '-' ? '-... | Checks if the number is a float and if is in the range of the given values . |
5,178 | public static function isString ( $ var , $ minLenght = false , $ maxLenght = false ) { if ( ! is_string ( $ var ) ) return false ; if ( $ minLenght && strlen ( $ var ) < $ minLenght ) return false ; if ( $ maxLenght && strlen ( $ var ) > $ maxLenght ) return false ; return true ; } | Check if a var is a string and can be check the size of it |
5,179 | public static function isEmail ( $ email ) { if ( ! is_string ( $ email ) || strlen ( $ email ) > 255 ) return false ; if ( Tools :: phpVersionCompareTo ( '5.3.3' ) >= 0 ) return ( boolean ) filter_var ( $ email , FILTER_VALIDATE_EMAIL ) ; else return ( boolean ) preg_match ( '`^(?!\.)[.\w!#$%&\'*+/=?^_\`{|}~-]+@(?!-)[... | Checks if the string is a well formed email address .. |
5,180 | public static function isIp ( $ ip , $ allowIpV4 = true , $ allowIpV6 = true ) { if ( $ allowIpV6 && $ allowIpV4 ) return \ filter_var ( $ ip , FILTER_VALIDATE_IP ) !== false ; if ( ! $ allowIpV6 && $ allowIpV4 ) return \ filter_var ( $ ip , FILTER_VALIDATE_IP , FILTER_FLAG_IPV4 ) !== false ; if ( $ allowIpV6 && ! $ al... | Check if the variable is a representation of ip |
5,181 | protected function getLabels ( ) { $ pluralName = $ this -> getPluralName ( ) ; $ singularName = $ this -> getSingularName ( ) ; return array ( 'name' => _x ( $ pluralName , strtolower ( $ pluralName ) ) , 'singular_name' => _x ( $ singularName , strtolower ( $ singularName ) ) , 'search_items' => __ ( 'Search ' . $ pl... | Gets the labels used in the args |
5,182 | public static function get_thumbnail ( $ the_post , $ args ) { $ thumbnail = [ 'src' => '' , 'width' => '' , 'height' => '' , 'alt' => '' , ] ; if ( has_post_thumbnail ( $ the_post -> ID ) ) { $ size = apply_filters ( Filter :: THUMBNAIL_SIZE , 'thumbnail' , $ the_post , $ args ) ; $ attachment_id = get_post_thumbnail_... | Get the thumbnail |
5,183 | public static function get_terms ( $ the_post ) { $ taxonomies = get_object_taxonomies ( $ the_post ) ; $ post_terms = [ ] ; foreach ( $ taxonomies as $ taxonomy ) { $ post_terms [ $ taxonomy ] = [ ] ; $ terms = wp_get_post_terms ( $ the_post -> ID , $ taxonomy ) ; foreach ( $ terms as $ term ) { $ post_terms [ $ taxon... | Get all taxonomies and terms for this post . |
5,184 | public static function loadRepeater ( $ repeater , $ itemId , $ mapping ) { if ( have_rows ( $ repeater , $ itemId ) ) { $ data = [ ] ; $ n = 0 ; while ( have_rows ( $ repeater , $ itemId ) ) { the_row ( ) ; $ data [ $ n ] = [ ] ; foreach ( $ mapping as $ key => $ value ) { $ data [ $ n ] [ $ key ] = get_sub_field ( $ ... | Build an array from an ACF repeater s data |
5,185 | public static function getImage ( $ post , $ name , $ size , $ dimensions = false ) { if ( get_field ( $ name , $ post ) ) { $ data = get_field ( $ name , $ post ) ; return getAcfImageFromArray ( $ data , $ size , $ dimensions ) ; } else { return false ; } } | Get an acf image array with optional dimentions |
5,186 | public static function getImageFromArray ( $ data , $ size , $ dimensions = false ) { if ( $ dimensions === true ) { $ image = ( object ) [ 'url' => $ data [ 'sizes' ] [ $ size ] , 'width' => $ data [ 'sizes' ] [ $ size . '-width' ] , 'height' => $ data [ 'sizes' ] [ $ size . '-height' ] ] ; } else { $ image = $ data [... | Build a simplified array of ACF image data |
5,187 | private function dependencyDefs ( ) { return [ Logger :: class => function ( ) { $ level = $ this -> getCfgValue ( 'deasilworks.log.level' , 10 ) ; $ gelfHandler = new GelfHandler ( new Publisher ( new UdpTransport ( $ this -> getCfgValue ( 'deasilworks.log.host' , '4klift-graylog' ) , $ this -> getCfgValue ( 'deasilwo... | Dependency Definitions . |
5,188 | public function getCfgValue ( $ key , $ default = null ) { $ value = $ default ; $ cfg = $ this -> config -> getCfg ( ) ; if ( $ cfg ) { $ value = $ cfg -> get ( $ key , $ default ) ; } return $ value ; } | Get a value from the CFG Config if one exists if not return the provided default otherwise null . |
5,189 | public function getBuildingNumber ( ) : ? string { if ( ! $ this -> hasBuildingNumber ( ) ) { $ this -> setBuildingNumber ( $ this -> getDefaultBuildingNumber ( ) ) ; } return $ this -> buildingNumber ; } | Get building number |
5,190 | public static function getCommandPath ( $ cmd ) { $ os_cmd = exec ( 'which ' . $ cmd ) ; if ( empty ( $ os_cmd ) ) { throw new CommandNotFoundException ( $ cmd ) ; } return $ os_cmd ; } | Get the system path of a command |
5,191 | function JSON ( $ object = null ) { header ( "Expires: Mon, 26 Jul 1997 05:00:00 GMT" ) ; header ( "Last-Modified: " . gmdate ( "D, d M Y H:i:s" ) . "GMT" ) ; header ( "Cache-Control: no-cache, must-revalidate" ) ; header ( "Pragma: no-cache" ) ; header ( 'Content-type: application/json' ) ; if ( is_array ( $ object ) ... | Output an object or string as JSON |
5,192 | function clean ( $ separator = '-' , $ length = - 1 ) { $ this -> replace ( '/[^a-z0-9]/i' , $ separator ) ; if ( ! empty ( $ separator ) ) { $ this -> replace ( '/' . preg_quote ( $ separator ) . '[' . preg_quote ( $ separator ) . ']*/' , $ separator ) ; } if ( $ length > - 1 && $ this -> length ( ) > $ length ) { $ t... | Strip non alpha numeric characters form the string |
5,193 | public function compareTo ( $ str2 , $ caseSensitive = true ) { $ str2 = $ caseSensitive ? $ str2 : strtolower ( $ str2 ) ; $ string = $ caseSensitive ? $ this -> returnValue : strtolower ( $ this -> returnValue ) ; return ( $ string == $ str2 ) ; } | Checks if this string object is equal to another . |
5,194 | public function contains ( $ needle , $ caseSensitive = true ) { $ needle = $ caseSensitive ? $ needle : strtolower ( $ needle ) ; $ string = $ caseSensitive ? $ this -> returnValue : strtolower ( $ this -> returnValue ) ; return ( ! ( strpos ( $ string , $ needle ) === false ) ) ; } | Checks if this string contains another . |
5,195 | public function stripLineBreak ( $ replacement = '' ) { $ this -> returnValue = str_replace ( $ this -> lineBreaks , $ replacement , $ this -> returnValue ) ; return $ this ; } | Strip all linebreack characters from this string |
5,196 | public function isEmail ( $ checkDNS = true ) { $ isValid = filter_var ( $ this -> returnValue , FILTER_VALIDATE_EMAIL ) !== false ; if ( $ isValid && $ checkDNS ) { $ domain = substr ( strrchr ( $ this -> returnValue , "@" ) , 1 ) ; $ isValid = checkdnsrr ( $ domain , "MX" ) && checkdnsrr ( $ domain , "A" ) ; } return... | Valid if the string is an email address |
5,197 | public function neatTruncate ( $ length , $ marker = '...' ) { $ length = $ length - ( strlen ( $ marker ) ) ; $ len = $ this -> length ( ) ; if ( $ len > $ length ) { $ matches = array ( ) ; preg_match ( '/(.{' . $ length . '}.*?)\b/' , $ this -> returnValue , $ matches ) ; $ result = end ( $ matches ) ; $ this -> ret... | Truncates a string to a maximum length neatly and adds a truncation marker when this happens . The maximum length of the string returned will be the maxlength of the string - the truncation marker length . It will not truncate the string in the middle of a word . Insead it will truncate to the next blank space . |
5,198 | public function truncate ( $ length , $ marker = '...' ) { if ( $ this -> length ( ) > $ length ) { $ this -> returnValue = substr ( $ this -> returnValue , 0 , ( $ length - strlen ( $ marker ) ) ) . $ marker ; } return $ this ; } | Truncates a string to a maximum length and adds a truncation marker when this happens . The maximum length of the string returned will be the maxlength of the string - the truncation marker length . |
5,199 | public function longestWord ( ) { $ words = str_word_count ( $ this -> returnValue , 1 ) ; $ longestWordLength = 0 ; $ longestWord = "" ; foreach ( $ words as $ word ) { if ( strlen ( $ word ) > $ longestWordLength ) { $ longestWordLength = strlen ( $ word ) ; $ longestWord = $ word ; } } return self :: create ( $ long... | Get the longest word in a sring |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.