idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
49,400 | public static function preSlash ( $ str , $ unify = false ) { return self :: _slash ( $ str , '/' , true , true , $ unify ) ; } | add slash to the front of the string . |
49,401 | public static function preDS ( $ str , $ unify = false ) { return self :: _slash ( $ str , DIRECTORY_SEPARATOR , true , true , $ unify ) ; } | add DIRECTORY_SEPARATOR to the front of the string . |
49,402 | public static function preBackSlash ( $ str , $ unify = false ) { return self :: _slash ( $ str , '\\' , true , true , $ unify ) ; } | add backslash to the front of the string . |
49,403 | public static function is_cleanPath ( $ path , $ clean = false , $ regex = '!_-\w\/\\\ ' ) { if ( $ clean === true ) { $ path = self :: get_directPath ( $ path ) ; } if ( preg_match ( '/[^' . $ regex . ']/' , $ path ) ) { return false ; } return $ path ; } | Checks if the path has invalid characters . |
49,404 | public static function get_static_var ( $ classname , $ key ) { $ vars = get_class_vars ( $ classname ) ; if ( isset ( $ vars [ $ key ] ) ) { return $ vars [ $ key ] ; } } | Getter for Static Variables of Named Classes |
49,405 | public static function get_dirArray ( $ dir , $ filenameKey = false , $ filter = null , $ positive = false ) { if ( empty ( $ filter ) ) { $ filter = array ( '.' , '_' ) ; } elseif ( is_object ( $ filter ) ) { $ filter = self :: ar ( $ filter , null , true ) ; } elseif ( ! is_array ( $ filter ) ) { $ filter = array ( $... | returns an array of files in a specific folder excluding files starting with . or _ |
49,406 | public static function getRequiredArgsError ( $ args , $ requiredArgs ) { if ( ! is_array ( $ args ) && ! is_object ( $ args ) ) { return sprintf ( __ ( 'invalid type "%s" for $args' , 'themaster' ) , gettype ( $ args ) ) ; } if ( ! is_array ( $ requiredArgs ) && ! is_object ( $ args ) ) { return sprintf ( __ ( 'invali... | Checks if Array 1 has all required keys specified by Array 2 |
49,407 | public static function filter_urlQuery ( & $ url , $ filterArr , $ method = null , array $ add = array ( ) ) { if ( $ method === null ) { $ method = 'remove' ; } $ pUrl = parse_url ( $ url ) ; $ qry ; if ( isset ( $ pUrl [ 'query' ] ) ) { parse_str ( $ pUrl [ 'query' ] , $ qry ) ; } else { $ qry = array ( ) ; } self ::... | Parses an url adds and removes get - query arguments and rebuilds the url . |
49,408 | public static function filter_data ( & $ data , $ filterArr , $ method = null , $ add = false ) { if ( $ method === null ) { $ method = 'keep' ; } foreach ( $ data as $ k => $ v ) { if ( ( $ method == 'remove' && in_array ( $ k , $ filterArr ) ) || ( $ method == 'keep' && ! in_array ( $ k , $ filterArr ) ) ) { if ( is_... | Filters entries of an array . |
49,409 | public static function merge_data ( $ a , $ b ) { $ args = func_get_args ( ) ; $ t = $ args [ 0 ] ; $ array = is_array ( $ t ) ; foreach ( $ args as $ k => $ a ) { $ args [ $ k ] = self :: ar ( $ a ) ; } $ args = call_user_func_array ( 'array_merge' , $ args ) ; if ( ! $ array ) { $ args = self :: sc ( $ args ) ; } ret... | Allows merging of arrays and objects . same usage as array_merge . |
49,410 | public static function merge_data_recursive ( $ a , $ b ) { $ args = func_get_args ( ) ; $ t = $ args [ 0 ] ; $ array = is_array ( $ t ) ; foreach ( $ args as $ k => $ a ) { $ args [ $ k ] = self :: ar ( $ a , null , true ) ; } $ args = call_user_func_array ( 'array_merge_recursive' , $ args ) ; if ( ! $ array ) { $ ar... | Allows deep merging of arrays and objects . same usage as array_merge_recursive . |
49,411 | public function driver ( $ driver = null ) { $ shortener = $ this -> app [ 'config' ] [ 'shortener' ] ; $ driver = $ driver ? : $ shortener [ 'default' ] ; $ driverMethod = 'create' . ucfirst ( $ driver ) . 'Driver' ; if ( method_exists ( $ this , $ driverMethod ) ) { return $ this -> { $ driverMethod } ( $ shortener )... | Get a shortener driver instance . |
49,412 | public function validate ( $ value ) { $ result = Ok :: unit ( ) ; foreach ( $ this -> allowedTypes as $ type ) { $ typeChecker = preg_match ( '/^&/' , $ type ) ? $ this -> getCustomType ( $ type ) : $ this -> createProperty ( $ type ) ; $ result = $ typeChecker -> validate ( $ value ) ; if ( $ result instanceof Ok ) {... | Tells if a given value adhere s to one of the property s allowed types . |
49,413 | protected function getCustomType ( $ type ) { $ root = $ this ; while ( $ cur = $ root -> getParent ( ) ) { $ root = $ cur ; } $ customTypes = $ root -> getSchema ( ) -> getCustomTypes ( ) ; $ type = ltrim ( $ type , '&' ) ; if ( isset ( $ customTypes [ $ type ] ) ) { return $ customTypes [ $ type ] ; } throw new Excep... | Retrieves a custom type definition by name that will be used to proxy the property s validation to . |
49,414 | protected function createProperty ( $ type ) { return $ this -> getSchema ( ) -> getFactory ( ) -> createProperty ( [ 'type' => $ type , 'name' => $ this -> getName ( ) . '_item' , 'required' => true ] , $ this -> getSchema ( ) , $ this ) ; } | Creates a child - property that will be used as a proxy - target for the parent property s validation . |
49,415 | public function parse ( $ raw ) { $ lines = explode ( "\n" , $ raw ) ; preg_match ( '/HTTP\/(\d\.\d) (\d\d\d) (.*)/' , $ lines [ 0 ] , $ statusLine ) ; $ response = ( new Response ( ) ) -> withProtocolVersion ( $ statusLine [ 1 ] ) -> withStatus ( $ statusLine [ 2 ] , $ statusLine [ 3 ] ) ; unset ( $ lines [ 0 ] ) ; fo... | Parses a Raw HTTP response and converts it into a response object |
49,416 | public function getNick ( ) { return $ this -> tracker -> getInfo ( $ this -> token , \ Erebot \ Module \ IrcTracker :: INFO_NICK ) ; } | Returns the nickname of the user represented by this identity . |
49,417 | public function getIdent ( ) { return $ this -> tracker -> getInfo ( $ this -> token , \ Erebot \ Module \ IrcTracker :: INFO_IDENT ) ; } | Returns the identity string of the user represented by this identity . |
49,418 | public function getHost ( $ canonical ) { return $ this -> tracker -> getInfo ( $ this -> token , \ Erebot \ Module \ IrcTracker :: INFO_HOST , array ( $ canonical ) ) ; } | Returns the host of the user represented by this identity . |
49,419 | public function getMask ( $ canonical ) { return $ this -> tracker -> getInfo ( $ this -> token , \ Erebot \ Module \ IrcTracker :: INFO_MASK , array ( $ canonical ) ) ; } | Returns a mask which can later be used to match against this user . |
49,420 | public function isOn ( ) { return $ this -> tracker -> getInfo ( $ this -> token , \ Erebot \ Module \ IrcTracker :: INFO_ISON ) ; } | Indicates whether the person associated with this token is still connected . |
49,421 | public function getInput ( ) { $ options = $ this -> htmlOptions ; $ options [ 'class' ] = ( isset ( $ options [ 'class' ] ) ? $ options [ 'class' ] . ' ' : '' ) . 'input autocomplete' ; $ options [ 'autc_ajax' ] = ( $ this -> ajaxUpdate ? '1' : '0' ) ; $ options [ 'autc_url' ] = $ this -> ajaxURL ; $ options [ 'autc_f... | Get the input ; |
49,422 | public function init ( $ config = [ ] ) { foreach ( $ config as $ key => $ value ) { switch ( $ key ) { case 'level' : $ this -> _level = ( int ) $ value ; break ; case 'mailer' : $ this -> _mailer = $ value ; break ; case 'formatter' : $ this -> _formatter = new $ value ( ) ; break ; default : break ; } } } | Initialises the handler . |
49,423 | public static function normalizePath ( $ path ) { $ path = rtrim ( $ path , '/' ) ; $ path = rtrim ( $ path , '\\' ) ; $ path .= DIRECTORY_SEPARATOR ; return $ path ; } | Normalize a path for insertion in the stack |
49,424 | public function resolve ( $ name ) { if ( preg_match ( '#\.\.[\\\/]#' , $ name ) ) { throw new Exception \ DomainException ( 'Requested asset may not include parent directory traversal ("../", "..\\" notation)' ) ; } if ( ! count ( $ this -> paths ) ) { return null ; } $ files = array ( ) ; foreach ( $ this -> paths as... | Retrieve the filesystem path to a view script |
49,425 | public function cmdGetProductClassField ( ) { $ result = $ this -> getListProductClassField ( ) ; $ this -> outputFormat ( $ result ) ; $ this -> outputFormatTableProductClassField ( $ result ) ; $ this -> output ( ) ; } | Callback for product - class - field - get command |
49,426 | public function cmdUpdateProductClassField ( ) { $ params = $ this -> getParam ( ) ; if ( empty ( $ params [ 0 ] ) || count ( $ params ) < 2 ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid command' ) ) ; } if ( ! is_numeric ( $ params [ 0 ] ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid argument' ) ) ;... | Callback for product - class - field - update command |
49,427 | protected function getListProductClassField ( ) { $ id = $ this -> getParam ( 0 ) ; if ( ! isset ( $ id ) ) { return $ this -> product_class_field -> getList ( array ( 'limit' => $ this -> getLimit ( ) ) ) ; } if ( $ this -> getParam ( 'class' ) ) { return $ this -> product_class_field -> getList ( array ( 'product_cla... | Returns an array of product class fields |
49,428 | protected function addProductClassField ( ) { if ( ! $ this -> isError ( ) ) { $ id = $ this -> product_class_field -> add ( $ this -> getSubmitted ( ) ) ; if ( empty ( $ id ) ) { $ this -> errorAndExit ( $ this -> text ( 'Unexpected result' ) ) ; } $ this -> line ( $ id ) ; } } | Add a new product class field |
49,429 | protected function updateProductClassField ( $ product_class_field_id ) { if ( ! $ this -> isError ( ) && ! $ this -> product_class_field -> update ( $ product_class_field_id , $ this -> getSubmitted ( ) ) ) { $ this -> errorAndExit ( $ this -> text ( 'Unexpected result' ) ) ; } } | Updates a product class field |
49,430 | protected function submitAddProductClassField ( ) { $ this -> setSubmitted ( null , $ this -> getParam ( ) ) ; $ this -> validateComponent ( 'product_class_field' ) ; $ this -> addProductClassField ( ) ; } | Add a new product class field at once |
49,431 | protected function wizardAddProductClassField ( ) { $ this -> validatePrompt ( 'product_class_id' , $ this -> text ( 'Product class' ) , 'product_class_field' ) ; $ this -> validatePrompt ( 'field_id' , $ this -> text ( 'Field ID' ) , 'product_class_field' ) ; $ this -> validatePrompt ( 'required' , $ this -> text ( 'R... | Add a new product class field step by step |
49,432 | private function searchRedirect ( ) : void { $ pathway = $ this -> getPathInfo ( ) ; $ routing = App :: $ Properties -> getAll ( 'Routing' ) ; if ( ! Any :: isArray ( $ routing ) || ! isset ( $ routing [ 'Redirect' ] ) || ! Any :: isArray ( $ routing [ 'Redirect' ] ) ) { return ; } if ( array_key_exists ( $ pathway , $... | Check if current url in redirect map |
49,433 | private function setPathdata ( ? array $ pathArray = null ) : void { if ( ! Any :: isArray ( $ pathArray ) || count ( $ pathArray ) < 1 ) { return ; } $ this -> controller = ucfirst ( Str :: lowerCase ( array_shift ( $ pathArray ) ) ) ; if ( count ( $ pathArray ) > 0 ) { $ this -> action = ucfirst ( Str :: lowerCase ( ... | Working with path array data |
49,434 | public function add ( $ key , $ value = null ) { $ this -> _view -> with ( $ key , $ value ) ; return $ this ; } | Adds data to the view class that will pass on to the view . |
49,435 | public function withErrors ( $ validator ) { foreach ( $ validator -> errors ( ) as $ key => $ value ) { if ( count ( $ value ) > 1 ) { for ( $ i = 0 ; $ i < count ( $ value ) ; $ i ++ ) { $ data [ $ key ] [ $ i ] = $ value [ $ i ] ; } } else { $ data [ $ key ] = $ value [ 0 ] ; } $ this -> _errors -> add ( ( object ) ... | Flash errors grabbed from a request . |
49,436 | public function renderWithData ( $ path , $ data = [ ] ) { foreach ( $ data as $ key => $ value ) { $ this -> add ( $ key , $ value ) ; } $ this -> render ( $ path ) ; return $ this ; } | Renders a view with data to pass on to the view . |
49,437 | public function redirectWith ( $ url , $ data ) { $ this -> _session -> flash ( 'redirect_data' , $ data ) ; $ this -> redirect ( $ url ) ; } | Redirects to a URL with data passed in as a temp flash session . |
49,438 | public function group ( $ name , $ data = [ ] ) { $ app = 'App\Groups\\' . ucwords ( $ name ) ; $ core = 'Scara\Http\Groups\\' . ucwords ( $ name ) ; if ( class_exists ( $ app ) ) { $ class = new $ app ( ) ; } else { if ( class_exists ( $ core ) ) { $ class = new $ core ( ) ; } else { throw new \ Exception ( "$name gro... | Loads in a group for given controller method . |
49,439 | public function load ( Router $ router , $ basepath ) { $ loader = new RouteLoader ( ) ; $ loader -> registerRouter ( $ router ) ; $ this -> _route = $ loader -> getRequestedRoute ( $ basepath ) ; if ( isset ( $ this -> _route [ 'method' ] ) && $ this -> _route [ 'method' ] == $ _SERVER [ 'REQUEST_METHOD' ] ) { $ contr... | Loads the controller with the requested route . |
49,440 | public function loadErrorPage ( $ errorType ) { switch ( $ errorType ) { case 'notfound' : $ code = '404' ; break ; case 'badrequest' : $ code = '400' ; break ; default : $ code = $ errorType ; break ; } require_once \ Config :: from ( 'app' ) -> get ( 'errors' ) ; if ( isset ( $ errors ) ) { foreach ( $ errors as $ er... | Loads a requested error page . |
49,441 | protected function getReflectionMethod ( $ class , $ name ) { $ reflectionClass = new ReflectionClass ( $ class ) ; $ method = $ reflectionClass -> getMethod ( $ name ) ; $ method -> setAccessible ( true ) ; return $ method ; } | Gets a reflection method object . |
49,442 | protected function getReflectionProperty ( $ objectOrClass , $ name ) { $ reflectionClass = new ReflectionClass ( $ objectOrClass ) ; $ property = $ reflectionClass -> getProperty ( ( string ) $ name ) ; $ property -> setAccessible ( true ) ; return $ property ; } | Gets a reflection property object . |
49,443 | protected function setPropertyValue ( $ object , $ propertyName , $ value ) { $ this -> getReflectionProperty ( $ object , $ propertyName ) -> setValue ( $ object , $ value ) ; return $ this ; } | Sets value in object property . |
49,444 | protected function getPath ( $ path ) { $ hasHttp = strpos ( $ path , 'http' ) ; if ( false === $ hasHttp || $ hasHttp !== 0 ) { return $ this -> options [ 'base_url' ] . $ path ; } return $ path ; } | Generate a complete URL using the option base_url |
49,445 | public static function createRequest ( $ method , $ path , $ body = [ ] , array $ headers = [ ] ) { return new Request ( $ method , $ path , $ body , $ headers ) ; } | Generate a request object |
49,446 | private function _escape ( $ value , $ htmlEntities = false ) { if ( get_magic_quotes_gpc ( ) ) { if ( $ htmlEntities ) { return htmlspecialchars ( $ value ) ; } return $ value ; } if ( is_array ( $ value ) ) { return array_map ( function ( $ n ) use ( $ htmlEntities ) { $ val = stripslashes ( $ n ) ; if ( $ htmlEntiti... | escape string value . |
49,447 | public static function map ( RecordInterface $ source , $ destination , array $ rules ) { if ( ! is_object ( $ destination ) ) { throw new InvalidArgumentException ( 'Destination must be an object' ) ; } $ data = $ source -> getProperties ( ) ; foreach ( $ data as $ key => $ value ) { if ( strpos ( $ key , '_' ) !== fa... | Method which can map all fields of a record to an arbitrary class by calling the fitting setter methods if available |
49,448 | public function hash ( string $ data , $ file = false ) { if ( $ file === false ) { return $ this -> hashContent ( $ data ) ; } return $ this -> hashFile ( $ file ) ; } | Hash by message |
49,449 | private function hashFile ( string $ filename ) { $ hash = hash_hmac_file ( $ this -> algorithm , $ filename , $ this -> key ) ; return $ this -> validate ( $ hash ) ; } | Hash by filename |
49,450 | private function hashContent ( string $ data ) { $ hash = hash_hmac ( $ this -> algorithm , $ data , $ this -> key ) ; return $ this -> validate ( $ hash ) ; } | Hash by content |
49,451 | public function json ( array $ array = [ ] , int $ code = null ) { $ this -> data = $ array ; if ( $ code != null ) { $ this -> code = $ code ; header ( 'HTTP/1.1 ' . $ this -> code ) ; return $ this -> send ( ) ; } return $ this ; } | Attach json data |
49,452 | public function withHeaders ( array $ array , int $ code = null ) { foreach ( $ array as $ field => $ i ) { array_push ( $ this -> headers , $ field . ': ' . $ i ) ; } if ( $ code != null ) { $ this -> code = $ code ; header ( 'HTTP/1.1 ' . $ this -> code ) ; return $ this -> send ( ) ; } return $ this ; } | Set response header s |
49,453 | public function view ( string $ path , array $ data = [ ] , bool $ return = false ) { if ( $ this -> headers !== [ 'Content-Type: application/json' ] ) { foreach ( $ this -> headers as $ header ) { header ( $ header ) ; } } return View :: make ( $ path , $ data , $ return ) ; } | Return a view response |
49,454 | public function download ( string $ location , ? string $ filename = null , ? array $ headers = [ ] ) { if ( ! file_exists ( $ location ) ) { header ( "HTTP/1.1 404 Not Found" ) ; return ; } $ size = filesize ( $ location ) ; $ time = date ( 'r' , filemtime ( $ location ) ) ; $ fm = @ fopen ( $ location , 'rb' ) ; if (... | Reads the requested portion of a file and sends its contents to the client with the appropriate headers . This HTTP_RANGE compatible read file function is necessary for allowing streaming media to be skipped around in . |
49,455 | public function resolveString ( $ value , array $ resolving = array ( ) ) { if ( preg_match ( '/^%([^%\s]+)%$/' , $ value , $ match ) ) { $ key = $ match [ 1 ] ; $ lcKey = strtolower ( $ key ) ; if ( isset ( $ resolving [ $ lcKey ] ) ) { throw new ParameterCircularReferenceException ( array_keys ( $ resolving ) ) ; } $... | Resolves parameters inside a string . |
49,456 | static function contents ( $ directory ) { if ( ! self :: exists ( $ directory ) ) return null ; $ dircontents = [ ] ; $ contents = scandir ( $ directory ) ; foreach ( $ contents as $ content ) { if ( $ content != '.' && $ content != '..' ) { array_push ( $ dircontents , $ content ) ; } } return $ dircontents ; } | Returns the contents of directory |
49,457 | public static function getInstance ( $ cloneInstance = false ) : Factory { if ( $ cloneInstance === true || self :: $ cloneInstances === true ) { return clone self :: $ sharedFactoryInstance ; } return self :: $ sharedFactoryInstance ; } | Get a new instance of the Factory class . |
49,458 | public function newInstance ( $ className , $ namespace = 'FuzeWorks\\' ) : self { $ instanceName = strtolower ( $ className ) ; $ className = $ namespace . ucfirst ( $ className ) ; if ( ! isset ( $ this -> { $ instanceName } ) ) { throw new FactoryException ( "Could not load new instance of '" . $ instanceName . "'. ... | Create a new instance of one of the loaded classes . It reloads the class . It does NOT clone it . |
49,459 | public function cloneInstance ( $ className ) : self { $ instanceName = strtolower ( $ className ) ; if ( ! isset ( $ this -> { $ instanceName } ) ) { throw new FactoryException ( "Could not clone instance of '" . $ instanceName . "'. Instance was not found." , 1 ) ; } $ this -> { $ instanceName } = clone $ this -> { $... | Clone an instance of one of the loaded classes . It clones the class . It does NOT re - create it . |
49,460 | public function removeInstance ( $ className ) : self { $ instanceName = strtolower ( $ className ) ; if ( ! isset ( $ this -> { $ instanceName } ) ) { throw new FactoryException ( "Could not remove instance of '" . $ instanceName . "'. Instance was not found." , 1 ) ; } unset ( $ this -> { $ instanceName } ) ; return ... | Remove an instance of one of the loaded classes . |
49,461 | protected function mergeMessages ( array $ customMessages = [ ] , array $ attributes = [ ] ) { $ globalMessages = [ ] ; if ( self :: $ globalMessageInstance instanceof MessageInterface ) { $ globalMessages = self :: $ globalMessageInstance -> getMessages ( ) ; } $ ruleMessages = Variable :: getDefaultRuleMessages ( ) ;... | Merge rule messages & custom messages & attributes |
49,462 | public function toCmsRequest ( Request $ request ) { $ cmsRequest = ( new CmsRequest ) -> duplicate ( $ request -> query -> all ( ) , $ request -> request -> all ( ) , $ request -> attributes -> all ( ) , $ request -> cookies -> all ( ) , $ request -> files -> all ( ) , $ request -> server -> all ( ) ) ; $ cmsRequest -... | Creates a CmsRequest out of an Illuminate Request |
49,463 | public function addAction ( array $ action ) { $ actions = $ this -> getAction ( ) ; $ actions [ ] = $ action ; return $ this -> setAction ( $ actions ) ; } | Set an array in the action array . |
49,464 | private function getPayloadAlertKeyValue ( ) { if ( $ this -> getSimpleAlert ( ) ) { return $ this -> getSimpleAlert ( ) ; } $ payloadAlert = array ( ) ; if ( $ this -> getAlertTitle ( ) ) { $ payloadAlert [ 'title' ] = $ this -> getAlertTitle ( ) ; } if ( $ this -> getAlertBody ( ) ) { $ payloadAlert [ 'body' ] = $ th... | Get the value of the payload alert key . |
49,465 | public function finish ( \ Caridea \ Validate \ Registry $ registry ) : \ Caridea \ Validate \ Rule { if ( $ this -> validator instanceof \ Caridea \ Validate \ Validator ) { return $ this ; } else { $ rule = clone $ this ; $ builder = $ registry -> builder ( ) ; switch ( $ this -> operator ) { case "nested_object" : c... | Finishes creating a rule using the parent builder . |
49,466 | protected function compileKey ( Blueprint $ blueprint , Fluent $ command , $ type ) { $ columns = $ this -> columnize ( $ command -> columns ) ; $ table = $ this -> wrapTable ( $ blueprint ) ; $ index = $ this -> wrap ( $ command -> index ) ; return "alter table {$table} add {$type} {$index}($columns)" ; } | Compile an index creation command . |
49,467 | protected function flatMap ( array $ flattened , MonadInterface $ result ) { $ value = $ result -> get ( ) ; if ( ! is_array ( $ value ) ) { $ value = [ $ value ] ; } return array_merge ( $ flattened , $ value ) ; } | Internal callback that is used in conjunction with php s array_reduce to flatten recursive chain results . |
49,468 | public function build ( array $ params = null ) { if ( null !== $ params ) { $ this -> setParams ( $ params ) ; } $ this -> adapter = $ this -> getDoctrinePaginatorAdapter ( ) ; $ this -> setCurrentPageNumber ( $ this -> getParam ( 'page' , 1 ) ) ; $ this -> setDefaultItemCountPerPage ( $ this -> getParam ( 'limit' , 3... | Build the instance |
49,469 | public function getParam ( $ param , $ default = null ) { if ( array_key_exists ( $ param , $ this -> params ) ) { return $ this -> params [ $ param ] ; } return $ default ; } | Get a specified param |
49,470 | protected function toEntityCollection ( $ result ) { switch ( true ) { case is_object ( $ result ) && is_subclass_of ( $ result , $ this -> collectionClass ) : $ collection = $ result ; break ; case $ result instanceof Collection : $ collection = new $ this -> collectionClass ( $ result -> toArray ( ) ) ; break ; case ... | Convert given array or Collection result set to managed entity collection class . |
49,471 | private function createFilteredQuery ( array $ filters ) { $ qb = $ this -> createQuery ( 'entity' ) ; foreach ( $ filters as $ field => $ filter ) { $ qb -> andWhere ( is_array ( $ filter ) ? sprintf ( 'entity.%s in (:%s)' , $ field , $ field ) : sprintf ( 'entity.%s = :%s' , $ field , $ field ) ) -> setParameter ( sp... | create query an filter it with given data . |
49,472 | public function validateParameters ( & $ parameters ) { if ( ! isset ( $ parameters [ 'username' ] ) ) { throw new InvalidArgumentException ( 'The \'username\' parameter must be defined for the Password grant type' , InvalidArgumentException :: MISSING_PARAMETER ) ; } elseif ( ! isset ( $ parameters [ 'password' ] ) ) ... | Adds a specific Handling of the parameters |
49,473 | public function handle ( RequestInterface $ request ) : RequestInterface { return $ request -> withHeader ( 'Authorization' , sprintf ( 'Basic %s' , base64_encode ( sprintf ( '%s:%s' , $ this -> user , $ this -> password ) ) ) ) ; } | Get the http headers associated with the authorization . |
49,474 | function equals ( $ other ) { if ( ! ( $ other instanceof Address ) ) { return false ; } return $ this === $ other || $ this -> asString ( ) === $ other -> asString ( ) ; } | Returns whether the address is equal to another given address . |
49,475 | public function getStartDate ( ) { $ now = $ this -> getNow ( ) ; $ endOfDay = $ this -> getToday ( ) -> modify ( '+18 hours' ) ; $ currentDay = $ this -> getToday ( ) ; if ( $ now > $ endOfDay ) { $ currentDay -> modify ( '+1 day' ) ; } return $ currentDay ; } | Gets the start date for the timeline |
49,476 | public function isBetween ( \ DateTime $ dateTime , \ DateTime $ start , \ DateTime $ end ) { return $ dateTime >= $ start && $ dateTime <= $ end ; } | Checks if a given date is beween a given start and end date |
49,477 | public function http404Action ( ) : void { $ header = Http :: status ( 404 ) ; $ this -> view -> header ( $ header ) ; $ this -> view -> snippet ( 'Base::error/http-404.phtml' ) ; $ this -> view -> assign ( 'message' , $ header ) ; } | default action for unknown pages |
49,478 | public static function getUtcDateTime ( BaseDateTime $ date ) { $ newDate = new BaseDateTime ( ) ; $ newDate -> setTimestamp ( $ date -> getTimestamp ( ) ) ; $ newDate -> setTimezone ( new DateTimeZone ( 'UTC' ) ) ; return $ newDate ; } | Converts the current date time object to UTC time . |
49,479 | public static function getUserDateTime ( BaseDateTime $ date , $ timezone = '' ) { $ newDate = new BaseDateTime ( ) ; $ newDate -> setTimestamp ( $ date -> getTimestamp ( ) ) ; if ( is_string ( $ timezone ) && ! empty ( $ timezone ) ) { $ timezone = new DateTimeZone ( $ timezone ) ; } if ( empty ( $ timezone ) ) { $ ti... | Converts the UTC date time object to user time . |
49,480 | public static function getSpan ( BaseDateTime $ date1 , BaseDateTime $ date2 , $ type = self :: SPAN_HOURS , $ absolute = TRUE ) { $ diff = $ date1 -> diff ( $ date2 , $ absolute ) ; $ span = 0 ; switch ( $ type ) { case self :: SPAN_YEARS : $ span = ( int ) $ diff -> y ; break ; case self :: SPAN_MONTHS : $ span = $ d... | Returns the span between the two dates . |
49,481 | public function setResources ( $ resources ) { if ( false === is_array ( $ resources ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type array, "%s" given' , __METHOD__ , gettype ( $ resources ) ) , E_USER_ERROR ) ; } $ this -> resources = $ resources ; } | Sets the resources |
49,482 | public function hasResource ( $ resource ) { if ( null !== $ resource && false === is_string ( $ resource ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ resource ) ) , E_USER_ERROR ) ; } return true === array_key_exists ( $ resource ,... | Check if a resource exists |
49,483 | public function route ( ) { global $ logger ; try { $ urlInterpreter = new UrlInterpreter ( ) ; $ command = $ urlInterpreter -> getCommand ( ) ; $ router = new Router ( $ command ) ; $ logger -> debug ( 'Routing to : ' . $ command -> getControllerName ( ) ) ; $ router -> route ( ) ; } catch ( Exception $ e ) { throw ne... | route Handles incoming requests . |
49,484 | public static function getExtensionMediaType ( string $ extension , ? string $ defaultMediaType = null ) : ? string { return self :: getMediaTypes ( ) [ strtolower ( $ extension ) ] ?? $ defaultMediaType ; } | Returns the media type for a given extension . |
49,485 | public static function getFilenameMediaType ( string $ filename , ? string $ defaultMediaType = null ) : ? string { if ( preg_match ( '|\\.([^.]+)$|u' , $ filename , $ matches ) ) { return self :: getExtensionMediaType ( $ matches [ 1 ] ) ; } return $ defaultMediaType ; } | Returns the media type for a given file name . |
49,486 | public static function getMediaTypeExtensions ( string $ mediaType ) : array { $ mediaType = strtolower ( $ mediaType ) ; $ extensions = [ ] ; foreach ( self :: getMediaTypes ( ) as $ extension => $ listMediaType ) { if ( $ listMediaType == $ mediaType ) { $ extensions [ ] = $ extension ; } } return $ extensions ; } | Returnes all the known extensions for a given media type . |
49,487 | public function count ( ) { return ( self :: $ assigned [ $ this -> type ] - self :: START_AT + self :: INCREMENT ) / self :: INCREMENT ; } | How many keys have been instantiated so far |
49,488 | public function next ( SourceBuffer $ generator ) { while ( isset ( $ this -> tokens [ $ this -> index ] ) ) { $ tok = $ this -> tokens [ $ this -> index ++ ] ; if ( is_array ( $ tok ) ) { switch ( $ tok [ 0 ] ) { case T_COMMENT : $ generator -> append ( $ tok ) ; $ this -> comment = '' ; continue 2 ; case T_WHITESPACE... | Read the next token from the stream comments and whitespace will be ignored . |
49,489 | public function peek ( $ distance = 1 ) { if ( $ distance < 0 ) { throw new \ InvalidArgumentException ( 'Peek must be a lookahead => distance must be greater than or equal to 0' ) ; } $ idx = $ this -> index + $ distance - 1 ; while ( isset ( $ this -> tokens [ $ idx ] ) ) { $ tok = $ this -> tokens [ $ idx ++ ] ; if ... | Lookahead at a token relative to the current position . |
49,490 | public function preceededBy ( $ token ) { if ( is_integer ( $ token ) ) { $ tok = $ this -> tokens [ $ this -> index - 1 ] ; if ( is_array ( $ tok ) && $ tok [ 0 ] == $ token ) { return true ; } } else { return $ token == $ this -> tokens [ $ this -> index - 1 ] ; } } | Check if the token at the current position is preceeded by the given token . |
49,491 | public function previous ( ) { if ( isset ( $ this -> tokens [ $ this -> index - 2 ] ) ) { return $ this -> tokens [ $ this -> index - 2 ] ; } return false ; } | Get the previous token returns false when there is no such token . |
49,492 | public function preceedingTokens ( array $ types ) { $ result = [ ] ; for ( $ x = $ this -> index - 2 ; $ x >= 0 ; $ x -- ) { $ tok = $ this -> tokens [ $ x ] ; if ( is_array ( $ tok ) ) { switch ( $ tok [ 0 ] ) { case T_COMMENT : case T_WHITESPACE : continue 2 ; } if ( ! in_array ( $ tok [ 0 ] , $ types , true ) ) { b... | Get all preceeding tokens matching the given token types will stop when a token is encountered that does not match the given filter . |
49,493 | private function createCache ( $ renderedContent ) { if ( ! CmsComponent :: isCmsLoggedIn ( ) ) { Cache :: getInstance ( ) -> setCacheForPath ( Request :: $ requestUri , $ renderedContent , json_encode ( ResponseHeaders :: getHeaders ( ) ) ) ; } } | Sets the new cache unless a cms user is logged in |
49,494 | private function getBundleClass ( SplFileInfo $ fileInfo ) { $ reflection = new ReflectionFile ( $ fileInfo -> getRealPath ( ) ) ; $ baseName = $ fileInfo -> getBasename ( '.php' ) ; foreach ( $ reflection -> getNamespaces ( ) as $ namespace ) { return $ namespace . '\\' . $ baseName ; } return null ; } | Returns FQCN for file |
49,495 | public static function alias ( $ file , array $ paths = array ( ) ) { if ( empty ( $ file ) ) { return '[internal]' ; } $ file = static :: ds ( $ file ) ; foreach ( array ( 'vendor' , 'app' , 'modules' , 'resources' , 'temp' , 'views' , 'web' ) as $ type ) { $ constant = strtoupper ( $ type ) . '_DIR' ; if ( empty ( $ ... | Parse the file path to remove absolute paths and replace with a constant name . |
49,496 | public static function ds ( $ path , $ endSlash = false ) { $ path = str_replace ( array ( '\\' , '/' ) , static :: SEPARATOR , $ path ) ; if ( $ endSlash && substr ( $ path , - 1 ) !== static :: SEPARATOR ) { $ path .= static :: SEPARATOR ; } return $ path ; } | Converts OS directory separators to the standard forward slash . |
49,497 | public static function includePath ( $ paths ) { $ current = array ( get_include_path ( ) ) ; if ( is_array ( $ paths ) ) { $ current = array_merge ( $ current , $ paths ) ; } else { $ current [ ] = $ paths ; } $ path = implode ( static :: DELIMITER , $ current ) ; set_include_path ( $ path ) ; return $ path ; } | Define additional include paths for PHP to detect within . |
49,498 | public static function join ( array $ paths , $ above = true , $ join = true ) { $ clean = array ( ) ; $ parts = array ( ) ; $ ds = static :: SEPARATOR ; $ up = 0 ; foreach ( $ paths as $ path ) { if ( ! is_string ( $ path ) ) { throw new InvalidTypeException ( 'Path parts must be strings' ) ; } $ path = trim ( static ... | Join all path parts and return a normalized path . |
49,499 | public static function relativeTo ( $ from , $ to ) { if ( static :: isRelative ( $ from ) || static :: isRelative ( $ to ) ) { throw new InvalidArgumentException ( 'Cannot determine relative path without two absolute paths' ) ; } $ ds = static :: SEPARATOR ; $ from = explode ( $ ds , static :: ds ( $ from , true ) ) ;... | Determine the relative path between two absolute paths . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.