idx int64 0 241k | question stringlengths 64 6.21k | target stringlengths 5 803 |
|---|---|---|
234,600 | final public function checkInjections ( $ className ) { if ( is_array ( $ this -> inject ( ) ) ) { foreach ( $ this -> inject ( ) as $ classArray ) { if ( ! is_array ( $ classArray ) || ( is_array ( $ classArray ) && ! isset ( $ classArray [ 'class' ] ) ) || ( is_array ( $ classArray ) && ! class_exists ( $ classArray ... | Checks the injection for cyclic dependencies |
234,601 | private function canInject ( array $ classArray , $ className = null ) { $ className = ( $ className === null ) ? $ this -> getClass ( ) : $ className ; if ( ! self :: addInjecting ( $ className ) ) { return false ; } $ refClass = new \ ReflectionClass ( $ classArray [ 'class' ] ) ; if ( $ refClass -> isSubclassOf ( 'D... | Checks if the class can be injected |
234,602 | private function doInject ( ) { foreach ( $ this -> prepareInject ( ) as $ alias => $ classArray ) { if ( ! is_array ( $ classArray ) ) { throw new \ Exception ( 'Injection failed. Values of injection array in class "' . $ this -> getClass ( ) . '" must be an array' ) ; } if ( ! isset ( $ classArray [ 'class' ] ) ) { t... | Performs the actual injection |
234,603 | private function addPropertiesAndConstantsForContainer ( ) { $ this -> addPropertiesAndConstantsFromReflection ( $ this -> containerClassReflection ) ; foreach ( $ this -> compositeClassReflectionArray as $ compositeClassReflection ) { $ paramName = $ this -> getComponentName ( $ compositeClassReflection ) ; $ newPrope... | Adds the properties and constants from the decorating class to the class being weaved . |
234,604 | public static function title ( $ link ) { if ( isset ( $ link [ 'title' ] ) || isset ( $ link [ 'label' ] ) ) { return ' title="' . trim ( isset ( $ link [ 'title' ] ) && ! empty ( trim ( $ link [ 'title' ] ) ) ? $ link [ 'title' ] : $ link [ 'label' ] ) . '"' ; } return false ; } | Returns the HTML title element |
234,605 | public static function label ( $ link ) { if ( isset ( $ link [ 'label' ] ) && ! empty ( trim ( $ link [ 'label' ] ) ) ) { return trim ( $ link [ 'label' ] ) ; } elseif ( isset ( $ link [ 'title' ] ) && ! empty ( trim ( $ link [ 'title' ] ) ) ) { return trim ( $ link [ 'title' ] ) ; } return false ; } | Returns the link label element |
234,606 | public static function href ( $ link ) { if ( isset ( $ link [ 'uri' ] ) || isset ( $ link [ 'fragment' ] ) ) { return ' href="' . URI :: getHref ( $ link ) . '"' ; } return false ; } | Returns the link href element |
234,607 | public static function htmlClass ( $ class , $ activeClass ) { if ( ( isset ( $ class ) && is_string ( $ class ) && ! empty ( trim ( $ class ) ) ) || ( is_string ( $ activeClass ) && ! empty ( trim ( $ activeClass ) ) ) ) { return ' class="' . trim ( trim ( $ class ) . ' ' . $ activeClass ) . '"' ; } return false ; } | Returns the HTML class element |
234,608 | public static function htmlID ( $ link ) { if ( isset ( $ link [ 'id' ] ) && is_string ( $ link [ 'id' ] ) && ! empty ( trim ( $ link [ 'id' ] ) ) ) { return ' id="' . trim ( $ link [ 'id' ] ) . '"' ; } return false ; } | Returns the HTML id element |
234,609 | public static function fontIcon ( $ link ) { if ( isset ( $ link [ 'font-icon' ] ) && is_string ( $ link [ 'font-icon' ] ) && ! empty ( trim ( $ link [ 'font-icon' ] ) ) ) { return '<span class="' . trim ( $ link [ 'font-icon' ] ) . '"></span> ' ; } return false ; } | Inserts a given font ion in a span class |
234,610 | public static function formatLink ( $ link , $ activeClass , $ hasChild = false , $ breadcrumbLink = false ) { return "<a" . self :: href ( $ link ) . self :: title ( $ link ) . self :: htmlClass ( ( $ breadcrumbLink ? '' : self :: $ linkDefaults [ 'a_default' ] . ' ' ) . ( isset ( $ link [ 'class' ] ) ? $ link [ 'clas... | Returns a formatted link with all of the attributes |
234,611 | private function hueToPoint ( float $ p , float $ q , float $ t ) : float { if ( $ t < 0 ) { $ t += 1 ; } if ( $ t > 1 ) { $ t -= 1 ; } switch ( true ) { case $ t < 1 / 6 : return $ p + ( $ q - $ p ) * 6 * $ t ; case $ t < 1 / 2 : return $ q ; case $ t < 2 / 3 : return $ p + ( $ q - $ p ) * ( 2 / 3 - $ t ) * 6 ; } retu... | Formula taken from the internet don t know what it means |
234,612 | public function addFilterConstraint ( ClassMetadata $ targetEntity , $ targetTableAlias ) { if ( ! $ targetEntity -> reflClass -> implementsInterface ( \ WellCommerce \ Bundle \ LocaleBundle \ Entity \ LocaleAwareInterface :: class ) ) { return "" ; } return $ targetTableAlias . '.locale = ' . $ this -> getParameter ( ... | Adds locale filter to query |
234,613 | protected function fromFollowingNodeIteratorParts ( ) { if ( is_null ( $ this -> typeTest ) ) { if ( is_null ( $ this -> nameTest ) ) $ this -> kind = XPathNodeType :: All ; else $ this -> kind = XPathNodeType :: Element ; } else $ this -> kind = $ this -> typeTest -> GetNodeKind ( ) ; } | Supports constructing an instance |
234,614 | public static function createFlexModel ( $ identifier , $ resource , $ cachePath ) { $ domDocument = new DOMDocument ( '1.0' , 'UTF-8' ) ; $ domDocument -> load ( $ resource ) ; $ domDocument -> xinclude ( ) ; $ flexModel = new FlexModel ( $ identifier ) ; $ flexModel -> load ( $ domDocument , $ cachePath ) ; return $ ... | Creates a new FlexModel instance . |
234,615 | public function call ( ) { if ( 'application/json' !== $ this -> app -> request ( ) -> headers ( 'Accept' ) ) { $ this -> next -> call ( ) ; return ; } $ callback = $ this -> app -> request ( ) -> get ( 'callback' ) ; $ this -> next -> call ( ) ; if ( empty ( $ callback ) ) { return ; } $ this -> app -> contentType ( '... | Adjust the content type accordingly and add the given callback name to the response for JSONP requests |
234,616 | public function defaultAction ( ) { $ lng = \ Cmf \ Language \ Factory :: get ( $ this ) ; HelperFactory :: getMeta ( ) -> clear ( ) ; HelperFactory :: getJS ( ) -> clear ( ) ; HelperFactory :: getStyle ( ) -> clear ( ) ; HelperFactory :: getTitle ( ) -> setTitle ( 'Redirect' ) ; if ( $ path = urldecode ( Application :... | This method display redirect page |
234,617 | public static function fromArray ( string $ id , string $ dsn , array $ properties ) : DatabaseConfiguration { $ self = new self ( $ id , $ dsn ) ; if ( isset ( $ properties [ 'username' ] ) ) { $ self -> userName = $ properties [ 'username' ] ; unset ( $ properties [ 'username' ] ) ; } if ( isset ( $ properties [ 'pas... | create connection data instance from an array |
234,618 | public function lateBind ( $ key , & $ item ) { if ( is_array ( $ item ) ) { return $ this -> classes [ $ key ] = $ item ; } return $ this -> registry -> rset ( $ key , $ item ) ; } | Binds by reference an existing object or an object definition to a key in the container . |
234,619 | public function current ( ) { $ keys = array_keys ( $ this -> tags ) ; return $ this -> tags [ $ keys [ $ this -> position ] ] ; } | Iterator current item |
234,620 | public function valid ( ) { $ keys = array_keys ( $ this -> tags ) ; return isset ( $ keys [ $ this -> position ] ) && isset ( $ this -> tags [ $ keys [ $ this -> position ] ] ) ; } | Iterator item exists |
234,621 | public function slice ( $ offset , $ length = null ) { $ this -> tags = array_slice ( $ this -> tags , $ offset , $ length , true ) ; return $ this ; } | Slice the tag cloud |
234,622 | public static function getByClass ( $ class ) { $ results = [ ] ; foreach ( static :: $ globals as $ k => $ v ) if ( $ v instanceof $ class ) $ results [ $ k ] = $ v ; return $ results ; } | Gets globals by their final class |
234,623 | public function start ( $ name , $ preset = null , $ isGlobalStart = false ) { if ( ! $ this -> isEnabled ( ) ) return ; $ t = $ this -> getTime ( ) ; $ this -> timers [ $ name ] = array ( 'name' => $ name , 'time' => $ preset == null ? $ t : $ preset , 'aggregate' => null , ) ; if ( ! $ this -> globalMode && $ isGloba... | Starts a timer with the given name |
234,624 | public function end ( $ name ) { if ( ! $ this -> isEnabled ( ) ) return ; $ aggregate = 0 ; $ oldTime = $ this -> firstTime ; if ( array_key_exists ( $ name , $ this -> timers ) ) $ oldTime = $ this -> timers [ $ name ] [ 'time' ] ; $ n = $ this -> getTime ( ) ; $ time = ( $ n - $ oldTime ) * 1000 ; if ( $ this -> glo... | Ends and stores the elapsed time for the timer with the given name |
234,625 | public function fromArray ( array $ opts ) { $ this -> _opts = \ Coast \ array_merge_smart ( $ this -> _opts , $ opts ) ; return $ this ; } | Import from an array . |
234,626 | protected static function errorToException ( $ level , $ message , $ file , $ line ) { try { throw new \ ErrorException ( $ message , 0 , $ level , $ file , $ line ) ; } catch ( \ ErrorException $ e ) { return $ e ; } } | Throws catches and returns an \ ErrorException created from error args |
234,627 | public function add ( $ type , $ message , $ data = FALSE , $ title = FALSE ) { $ messages = $ this -> _session_get ( ) ; if ( ! is_array ( $ messages ) ) { $ messages = array ( ) ; } if ( is_a ( $ message , 'Exception' ) ) { $ title = 'Exception Thrown!' ; $ message = $ message -> getMessage ( ) ; $ type = 'error' ; }... | Adds a message to the a list . |
234,628 | public function clear ( $ type = FALSE ) { if ( $ type === FALSE ) { $ this -> _session_unset ( ) ; } else { $ messages = $ this -> _session_get ( ) ; if ( is_array ( $ messages ) ) { foreach ( $ messages as $ i => $ message ) { if ( $ message -> type == $ type ) { unset ( $ messages [ $ i ] ) ; } } if ( ! $ this -> co... | Removes messages from the list . |
234,629 | public function peek ( $ type = FALSE ) { $ messages = $ this -> _session_get ( ) ; if ( ! is_array ( $ messages ) ) { return array ( ) ; } if ( $ type === FALSE ) { return $ messages ; } else { $ tmessages = array ( ) ; foreach ( $ messages as $ message ) { if ( $ message -> type == $ type ) { $ tmessages [ ] = $ mess... | Returns an array of messages to be displayed without removing them from the session |
234,630 | final private static function _hasFileKeys ( Array $ file ) : Bool { $ valid = true ; foreach ( [ 'error' , 'tmp_name' , 'type' , 'size' , 'name' ] as $ key ) { if ( ! array_key_exists ( $ key , $ file ) ) { $ valid = false ; break ; } } return $ valid ; } | Verifies that an array has all keys expected of a file upload |
234,631 | public function cmdGetCart ( ) { $ result = $ this -> getListCart ( ) ; $ this -> outputFormat ( $ result ) ; $ this -> outputFormatTableCart ( $ result ) ; $ this -> output ( ) ; } | Callback for cart - get command |
234,632 | public function cmdDeleteCart ( ) { $ id = $ this -> getParam ( 0 ) ; $ options = null ; if ( $ this -> getParam ( 'user' ) ) { $ options = array ( 'user_id' => $ id ) ; } else if ( $ this -> getParam ( 'sku' ) ) { $ options = array ( 'sku' => $ id ) ; } else if ( $ this -> getParam ( 'order' ) ) { if ( ! is_numeric ( ... | Callback for cart - delete command |
234,633 | protected function getListCart ( ) { $ id = $ this -> getParam ( 0 ) ; if ( ! isset ( $ id ) ) { return $ this -> cart -> getList ( array ( 'limit' => $ this -> getLimit ( ) ) ) ; } if ( $ this -> getParam ( 'user' ) ) { return $ this -> cart -> getList ( array ( 'user_id' => $ id , 'limit' => $ this -> getLimit ( ) ) ... | Returns an array of cart items |
234,634 | protected function submitAddCart ( ) { $ this -> setSubmitted ( null , $ this -> getParam ( ) ) ; $ this -> setSubmittedJson ( 'data' ) ; $ this -> validateComponent ( 'cart' ) ; $ this -> addAddCart ( ) ; } | Add a new cart item at once |
234,635 | protected function wizardAddCart ( ) { $ this -> validatePrompt ( 'user_id' , $ this -> text ( 'User ID' ) , 'cart' ) ; $ this -> validatePrompt ( 'product_id' , $ this -> text ( 'Product ID' ) , 'cart' ) ; $ this -> validatePrompt ( 'sku' , $ this -> text ( 'Product SKU' ) , 'cart' ) ; $ this -> validatePrompt ( 'stor... | Add a new cart item step by step |
234,636 | protected function addAddCart ( ) { if ( ! $ this -> isError ( ) ) { $ id = $ this -> cart -> add ( $ this -> getSubmitted ( ) ) ; if ( empty ( $ id ) ) { $ this -> errorAndExit ( $ this -> text ( 'Unexpected result' ) ) ; } $ this -> line ( $ id ) ; } } | Add a new cart item |
234,637 | protected function bindContext ( $ object = NULL ) { if ( $ object !== NULL && ! is_object ( $ object ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Expecting an object, given %s' , gettype ( $ object ) ) ) ; } $ previous = $ this -> context ; $ this -> context = $ object ; if ( $ object === NULL ) { $ this ->... | Bind the scope to the given object . |
234,638 | protected function unbindContext ( $ object , $ terminate = true ) { if ( ! is_object ( $ object ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Expecting an object, given %s' , gettype ( $ object ) ) ) ; } if ( $ this -> context === $ object ) { $ this -> context = NULL ; $ this -> proxies = new \ SplObjectSto... | Unbind scope from the given object will optionally destroy all contextual instances bound to the object . |
234,639 | protected function initializeProxy ( $ typeName , callable $ factory = NULL ) { $ proxyName = $ this -> container -> loadScopedProxy ( $ typeName ) ; if ( $ factory === NULL ) { $ factory = function ( ) { throw new ScopeNotActiveException ( sprintf ( 'Scope "%s" is not active' , $ this -> getScope ( ) ) ) ; } ; } retur... | Create a scoped proxy for the given type . |
234,640 | protected function bindFactoryProxy ( $ typeName , callable $ factory ) { $ proxy = $ this -> initializeProxy ( $ typeName , $ factory ) ; $ this -> scopedProxies [ $ proxy -> K2GetProxyBinding ( ) ] = $ proxy ; $ this -> container -> bindInstance ( $ typeName , $ proxy , true ) ; return $ proxy ; } | Creates a factory - based proxy for the target type and binds it to the DI container . |
234,641 | protected function removeFilesAndDirectories ( ) { $ this -> laravel [ 'files' ] -> deleteDirectory ( config ( 'lia.directory' ) ) ; $ this -> laravel [ 'files' ] -> deleteDirectory ( public_path ( 'vendor/lia/' ) ) ; $ this -> laravel [ 'files' ] -> delete ( config_path ( 'lia.php' ) ) ; $ this -> laravel [ 'files' ] ... | Remove files and directories . |
234,642 | public function addScheduleItem ( ProductionMenuCollectionEvent $ event ) : void { $ menu = $ event -> getMenu ( ) ; $ group = $ event -> getGroup ( ) ; $ schedule = $ this -> factory -> createItem ( 'menu_item.schedule' , [ 'route' => 'bkstg_calendar_production' , 'routeParameters' => [ 'production_slug' => $ group ->... | Add the schedule menu item . |
234,643 | public function setApiClient ( \ Inwendo \ Latex \ Common \ ApiClient $ apiClient ) { $ this -> apiClient = $ apiClient ; return $ this ; } | Set the API client |
234,644 | public function addAliases ( $ alias ) { foreach ( func_get_args ( ) as $ alias ) { $ this -> aliases [ $ alias ] = true ; } return $ this ; } | Add one or more aliases to the field |
234,645 | public function setExportHandler ( $ type ) { if ( $ type === self :: EXPORT_NORMAL || $ type === self :: EXPORT_ARRAY || $ type === self :: EXPORT_SKIP || is_callable ( $ type ) ) { $ this -> exportHandler = $ type ; return $ this ; } throw new InvalidArgumentException ( "invalid value provided for 'type'; " . "expect... | Set the method by which to export the value |
234,646 | public function addValue ( $ value , $ index = null ) { if ( $ this -> value === null ) { $ this -> value = [ ] ; } if ( $ index === null ) { $ this -> value [ ] = $ value ; } else { $ this -> value [ $ index ] = $ value ; } return $ this ; } | Add a value |
234,647 | public function setValue ( $ value , $ index = null ) { if ( $ index === null ) { $ this -> value = Arr :: cast ( $ value ) ; } else { $ this -> value [ $ index ] = $ value ; } return $ this ; } | Set one or all values |
234,648 | public function getValue ( $ index = 0 ) { if ( $ index === 0 && $ this -> value === null ) { return $ this -> defaultValue ; } return ( is_array ( $ this -> value ) && array_key_exists ( $ index , $ this -> value ) ) ? $ this -> value [ $ index ] : null ; } | Get a single value |
234,649 | private function getValuesAsArray ( ) { if ( $ this -> value === null ) { return is_array ( $ this -> defaultValue ) ? $ this -> defaultValue : [ $ this -> defaultValue ] ; } return $ this -> value ; } | Get all of the current values as an array of values |
234,650 | public function addRule ( Rule $ rule ) { $ classname = $ rule -> getClass ( ) ; if ( $ this -> hasRule ( $ classname ) === true ) { throw new Exception ( "failed to add rule; the field {$this->name} already has an " . "instance of '$classname'" ) ; } else if ( $ classname === Rule :: REQUIRED ) { $ this -> rules = [ $... | Add a validation rule to the field |
234,651 | public function validate ( Collection $ collection = null ) { $ this -> errors = [ ] ; foreach ( $ this -> getValuesAsArray ( ) as $ index => $ value ) { if ( $ value === null && $ this -> hasRule ( Rule :: REQUIRED ) === false ) { continue ; } foreach ( $ this -> rules as $ name => $ rule ) { $ rule -> setValue ( $ va... | Validate all the values in the field |
234,652 | public function matchRoot ( & $ request ) { if ( empty ( $ this -> _patterns ) ) { return true ; } $ path = $ request -> getPathToMatch ( ) ; $ method = $ request -> getMethod ( ) ; foreach ( $ this -> _patterns as $ pattern ) { if ( $ matched = Matcher :: verify ( $ pattern , $ path , $ method ) ) { if ( isset ( $ mat... | check if the requested path matches with the root . |
234,653 | public function flushAll ( ) { $ mask = '*' . self :: CACHE_FILE_SUFFIX ; foreach ( glob ( $ this -> basePath . $ mask ) as $ cacheFilePath ) { if ( ! unlink ( $ cacheFilePath ) ) { throw new \ RuntimeException ( "Failed to delete cache file '{$cacheFilePath}'." ) ; } } } | Deletes every cache file . |
234,654 | protected function loadRouting ( ) { $ parser = new YamlParser ( ) ; $ routes = array ( ) ; foreach ( $ this -> getRoutingFiles ( ) as $ file ) { $ routes = array_merge ( $ routes , $ parser -> parse ( file_get_contents ( $ file ) ) ) ; } foreach ( $ routes as $ name => $ routeInfos ) { $ this -> processRouteInfos ( $ ... | Load routing from routing files |
234,655 | private function processRouteInfos ( $ name , array $ routeInfos ) { $ className = null ; if ( isset ( $ routeInfos [ 'sequence' ] ) ) { $ className = $ routeInfos [ 'sequence' ] ; $ this -> container [ 'core' ] [ 'router' ] -> addRouteSequence ( $ className ) ; } if ( isset ( $ routeInfos [ 'pattern' ] ) ) { if ( ! is... | Process route infos |
234,656 | private function iterarEntradas ( $ busquedaLdap , array $ atributos ) { $ datos = array ( ) ; if ( ( $ entrada = ldap_first_entry ( $ this -> conexionLdap , $ busquedaLdap ) ) ) { do { $ datos [ ] = $ this -> mapa ( $ atributos , $ entrada ) ; } while ( $ entrada = ldap_next_entry ( $ this -> conexionLdap , $ entrada ... | Auxiliar directo de busqueda . Dado un ldap result itera por el para conseguir sus datos |
234,657 | public static function ordinalize ( $ number ) { if ( in_array ( ( $ number % 100 ) , range ( 11 , 13 ) ) ) { return $ number . 'th' ; } switch ( $ number % 10 ) { case 1 : return $ number . 'st' ; case 2 : return $ number . 'nd' ; case 3 : return $ number . 'rd' ; default : return $ number . 'th' ; } } | Converts number to its ordinal English form . For example converts 13 to 13th 2 to 2nd ... |
234,658 | public function pixelate ( $ blocksize = 5 , $ effect = 50 ) { $ this -> filter ( IMG_FILTER_PIXELATE , $ blocksize , $ effect ) ; return $ this -> image ; } | Give current image a pixelate filter |
234,659 | private function createImage ( $ x , $ y , $ width , $ height , $ new_width , $ new_height , $ interlace = false ) { $ resource = imagecreatetruecolor ( $ new_width , $ new_height ) ; if ( false === imagesavealpha ( $ resource , true ) ) { trigger_error ( 'Could not set the flag to save full alpha channel' , E_USER_ERR... | Creates new image resource . Returns false if failed . |
234,660 | public function substring ( ) { $ start = $ this -> getParameter ( 'start' ) ; $ length = $ this -> getParameter ( 'length' ) ; if ( empty ( $ start ) ) $ start = 0 ; if ( empty ( $ length ) ) $ length = strlen ( $ this -> getParameter ( 'value' ) ) - ( int ) $ start ; $ str = substr ( $ this -> getParameter ( 'value' ... | Returns a substring from param value . Returns the 1st letter if only value is specified |
234,661 | public function showVars ( ) { $ what = $ this -> getParameter ( 'scope' ) ; switch ( $ what ) { case 'global' : case 'globals' : case 'system' : case 'systems' : $ debug = $ this -> getGlobals ( ) ; break ; default : $ debug = $ this -> getLocals ( ) ; break ; } return '<pre>' . JSONUtils :: encode ( $ debug , true , ... | Returns debuggging information about the current vars |
234,662 | public function htmlEscape ( ) { if ( $ this -> getParameter ( 'value' ) == null ) return ; return str_replace ( '%' , '%' , htmlentities ( $ this -> getParameter ( 'value' ) , ENT_QUOTES , 'UTF-8' , false ) ) ; } | HTML - Escapes the specified parameter . Converts all html chars into their entities equivalent |
234,663 | function strReplace ( ) { if ( ( $ this -> getParameter ( 'needle' ) == null ) || ( $ this -> getParameter ( 'haystack' ) == null ) ) return $ this -> getParameter ( 'haystack' ) ; $ needle = $ this -> getParameter ( 'needle' ) ; if ( $ needle == '\n' ) $ needle = "\n" ; return str_replace ( $ needle , $ this -> getPar... | Performs a string replace on the specified param |
234,664 | public function pregReplace ( ) { if ( $ this -> getParameter ( 'pattern' ) == null ) return $ this -> getParameter ( 'subject' ) ; return preg_replace ( $ this -> getParameter ( 'pattern' ) , $ this -> getParameter ( 'replace' ) , $ this -> getParameter ( 'subject' ) ) ; } | Performs a regular expression search and replace |
234,665 | protected function firstLetter ( ) { $ string = trim ( ( string ) $ this -> getParameter ( 'string' ) ) ; $ lower = ( boolean ) $ this -> getParameter ( 'lower' ) ; return StringUtils :: firstLetter ( $ string , $ lower ) ; } | Return the first character from a string . |
234,666 | public function trim ( ) { return StringUtils :: trim ( $ this -> getParameter ( 'value' ) , $ this -> getParameter ( 'len' ) , $ this -> getParameter ( 'keeptags' ) , $ this -> getParameter ( 'decodehtml' ) , $ this -> getParameter ( 'stripurls' ) ) ; } | Trims a string to a specified length . It will allow tags listed in KeepTags to remain and will intelligently append the trimmed text with ... or - depending on if the trim ends on a word or a space . |
234,667 | public function wordCount ( ) { $ count = 0 ; foreach ( $ this -> getParameters ( ) as $ value ) $ count += str_word_count ( strip_tags ( $ value ) ) ; return $ count ; } | Returns the total count of all words in all params passed |
234,668 | public function charCount ( ) { $ count = 0 ; foreach ( $ this -> getParameters ( ) as $ value ) $ count += strlen ( strip_tags ( $ value ) ) ; return $ count ; } | Returns the total count of all characters in all params passed |
234,669 | public function pluralize ( ) { if ( $ this -> getParameter ( 'upperCaseFirst' ) == 'true' ) return ucfirst ( StringUtils :: pluralize ( $ this -> getParameter ( 'value' ) ) ) ; return StringUtils :: pluralize ( $ this -> getParameter ( 'value' ) ) ; } | Returns the plural version of the parameter in value |
234,670 | public function repeat ( ) { if ( $ this -> getParameter ( 'value' ) == null ) return ; $ value = $ this -> getParameter ( 'value' ) ; $ multiplier = $ this -> getParameter ( 'multiplier' ) ; $ offset = $ this -> getParameter ( 'offset' ) ; return str_repeat ( $ value , ( int ) $ multiplier + ( int ) $ offset ) ; } | Returns the supplied snippet repeated X times |
234,671 | public function implode ( ) { if ( ! is_array ( $ this -> getParameter ( 'value' ) ) ) { return $ this -> getParameter ( 'value' ) ; } $ glue = $ this -> getParameter ( 'glue' ) ; if ( $ glue === null ) { $ glue = ' ' ; } return implode ( $ glue , $ this -> getParameter ( 'value' ) ) ; } | Implode Array to String |
234,672 | public function sortBy ( $ columnName , $ asc = TRUE ) { $ sort = new \ stdClass ( ) ; $ sort -> column = $ columnName ; $ sort -> asc = ! ! $ asc ; $ this -> columnSorts [ ] = $ sort ; return $ this ; } | add ORDER BY clause |
234,673 | protected function buildQueryString ( ) { $ w = [ ] ; $ s = [ ] ; $ qc = $ this -> quoteChar ; $ this -> sql = 'SELECT ' ; if ( ! $ this -> columns || ! count ( $ this -> columns ) ) { $ this -> sql .= '*' ; } else { $ this -> sql .= $ qc . str_replace ( '.' , $ qc . '.' . $ qc , implode ( $ qc . ',' . $ qc , $ this ->... | builds query string by parsing WHERE and ORDER BY clauses |
234,674 | protected function buildValuesArray ( ) { foreach ( $ this -> whereClauses as $ where ) { if ( is_null ( $ where -> value ) ) { continue ; } if ( is_array ( $ where -> value ) ) { $ this -> valuesToBind = array_merge ( $ this -> valuesToBind , $ where -> value ) ; } else { $ this -> valuesToBind [ ] = $ where -> value ... | prepares array containing values which must be bound to prepared statement |
234,675 | protected function executeQuery ( ) { $ this -> lastQuerySql = $ this -> sql ; return $ this -> dbConnection -> doPreparedQuery ( $ this -> sql , $ this -> valuesToBind ) ; } | bind values and execute the SQL statement returns array of records |
234,676 | public static function fromArray ( array $ data ) { return new self ( ! empty ( $ data [ 'code' ] ) ? $ data [ 'code' ] : null , ! empty ( $ data [ 'message' ] ) ? $ data [ 'message' ] : null , ! empty ( $ data [ 'data' ] ) ? $ data [ 'data' ] : null ) ; } | Create object from array |
234,677 | public function toArray ( ) { $ error = array ( 'code' => $ this -> getCode ( ) , 'message' => $ this -> getMessage ( ) , ) ; if ( $ this -> getData ( ) ) { $ error [ 'data' ] = $ this -> getData ( ) ; } return $ error ; } | Transform object to array |
234,678 | public function getMessageString ( $ errorCode ) { return isset ( $ this -> errorMessages [ $ errorCode ] ) ? $ this -> errorMessages [ $ errorCode ] : null ; } | Return message string by code |
234,679 | public function getSane ( $ shift = 1 , $ limitOrFilter = null ) { $ backtrace = $ this -> trace ; while ( $ shift -- > 0 ) { array_shift ( $ backtrace ) ; } if ( is_numeric ( $ limitOrFilter ) ) { $ backtrace = array_slice ( $ backtrace , 0 , ( int ) $ limitOrFilter ) ; $ limitOrFilter = null ; } $ formattedTrace = ar... | Shift trace filter as required and fix the arguments object |
234,680 | private function traceComponentMakeSane ( $ trace ) { if ( isset ( $ trace [ 'args' ] ) ) { $ trace [ 'args' ] = array_map ( function ( $ arg ) { switch ( true ) { case is_object ( $ arg ) : return get_class ( $ arg ) ; case is_bool ( $ arg ) : return $ arg ? 'true' : 'false' ; case is_scalar ( $ arg ) : return $ arg ;... | Format a trace into a more managable output when massive objects are involved |
234,681 | public function release ( $ item ) { $ k = array_search ( $ item , $ this -> _inUseItems ) ; if ( $ k === FALSE ) return ; unset ( $ this -> _inUseItems [ $ k ] ) ; $ this -> _poolItems [ ] = $ item ; } | Free an item and replace it in the pool |
234,682 | public static function getLevelCode ( $ level ) { if ( is_string ( $ level ) && isset ( self :: $ levels [ $ level ] ) ) { return self :: $ levels [ $ level ] ; } throw new Exception \ InvalidArgumentException ( Message :: get ( Message :: INVALID_LOG_LEVEL , ( string ) $ level ) , Message :: INVALID_LOG_LEVEL ) ; } | Get level code by name |
234,683 | private static function _irr ( $ pval , $ payarray , $ fromdayone ) { $ low = 0.0 ; $ high = 100.0 ; $ lowval = self :: _npv ( $ pval , $ payarray , $ low , $ fromdayone ) ; $ highval = self :: _npv ( $ pval , $ payarray , $ high , $ fromdayone ) ; if ( $ lowval > 0.0 ) { return ( - 1 ) ; } do { $ mid = self :: _midpoi... | This function uses divide and conquer to numerically find the IRR Internal Rate of Return . It starts of by trying a low of 0% and a high of 100% . If this isn t enough it will double the interval up to 1000000% . Note that this is insanely high and if you try to convert an IRR that high to an APR you will get even mor... |
234,684 | private static function _fulpacc ( $ pval , $ rate , $ fee , $ minpay , $ payment , $ months , $ base ) { $ bal = $ pval ; $ payarray = array ( ) ; while ( ( $ months != 0 ) && ( $ bal > self :: $ accuracy ) ) { $ interest = $ bal * $ rate / ( 100.0 * 12 ) ; $ newbal = $ bal + $ interest + $ fee ; if ( $ minpay >= $ ne... | This is a simplified model of how our paccengine works if a client always pays their bills . It adds interest and fees and checks minimum payments . It will run until the value of the account reaches 0 and return an array of all the individual payments . Months is the amount of months to run the simulation . Important!... |
234,685 | private static function _aprAnnuity ( $ pval , $ months , $ rate , $ fee , $ minpay ) { $ payment = self :: _annuity ( $ pval , $ months , $ rate ) + $ fee ; if ( $ payment < 0 ) { return $ payment ; } $ payarray = self :: _fulpacc ( $ pval , $ rate , $ fee , $ minpay , $ payment , $ months , false ) ; $ apr = self :: ... | Calculate the APR for an annuity given the following inputs . |
234,686 | private static function _getPayArray ( $ sum , $ pclass , $ flags ) { $ monthsfee = 0 ; if ( $ flags === KlarnaFlags :: CHECKOUT_PAGE ) { $ monthsfee = $ pclass -> getInvoiceFee ( ) ; } $ startfee = 0 ; if ( $ flags === KlarnaFlags :: CHECKOUT_PAGE ) { $ startfee = $ pclass -> getStartFee ( ) ; } $ sum += $ startfee ; ... | Grabs the array of all monthly payments for specified PClass . |
234,687 | public static function pRound ( $ value , $ country ) { $ multiply = 1 ; $ country = KlarnaCountry :: getCode ( $ country ) ; switch ( $ country ) { case "FI" : case "DE" : case "NL" : case "AT" : $ multiply = 10 ; break ; } return floor ( ( $ value * $ multiply ) + 0.5 ) / $ multiply ; } | Rounds a value depending on the specified country . |
234,688 | public function where ( $ field , $ value , $ comparison = '==' , $ logical = 'and' ) { $ this -> conditions [ ] = [ $ field , $ value , $ comparison , $ logical ] ; return $ this ; } | Adds where condition to relation |
234,689 | protected function buildLocalKey ( $ entity , array $ pairs ) { $ keys = array_keys ( $ pairs ) ; return $ this -> buildKey ( $ entity , array_combine ( $ keys , $ keys ) ) ; } | Builds local key from field property pairs |
234,690 | protected function buildKey ( $ entity , array $ pairs ) { $ key = [ ] ; foreach ( $ pairs as $ local => $ refer ) { $ key [ ] = $ local . ':' . $ this -> accessor -> getPropertyValue ( $ entity , $ refer ) ; } return implode ( '-' , $ key ) ; } | Builds key from key - value pairs |
234,691 | protected function fetch ( $ entityName , array $ conditions , $ result = false ) { $ query = $ this -> storage -> read ( $ entityName ) ; foreach ( $ conditions as $ field => $ values ) { $ query -> where ( $ field , $ values ) ; } if ( ! $ result ) { return $ query -> execute ( ) ; } foreach ( $ this -> relations as ... | Fetches collection of entities matching set conditions Optionally sorts it and limits it |
234,692 | protected function assertInstance ( $ entity ) { $ entityClass = $ this -> definition -> entity ( ) ; if ( ! $ entity instanceof $ entityClass ) { throw new RelationException ( sprintf ( 'Relation entity must be instance of %s, got %s' , $ entityClass , $ this -> getType ( $ entity ) ) ) ; } return true ; } | Throws exception when entity is not required instance |
234,693 | protected function cleanup ( $ entityName , array $ collection , array $ conditions ) { if ( ! $ existing = $ this -> isCleanupNecessary ( $ entityName , $ conditions ) ) { return ; } $ identifiers = [ ] ; foreach ( $ collection as $ instance ) { $ identifiers [ ] = $ this -> identifyEntity ( $ instance , $ entityName ... | Removes obsolete entities that match conditions but don t exist in collection |
234,694 | private function isCleanupNecessary ( $ entityName , $ conditions ) { if ( empty ( $ conditions ) ) { return false ; } $ existing = $ this -> fetch ( $ entityName , $ conditions ) ; if ( empty ( $ existing ) ) { return false ; } return $ existing ; } | Returns array with entities that should be deleted or false otherwise |
234,695 | protected function identifyEntity ( $ instance , $ entityName ) { $ fields = $ this -> models -> get ( $ entityName ) -> primaryFields ( ) ; $ id = [ ] ; foreach ( $ fields as $ field ) { $ id [ ] = $ this -> accessor -> getPropertyValue ( $ instance , $ field -> name ( ) ) ; } return implode ( ':' , $ id ) ; } | Returns entity identifier If more than one primary keys entity will not be identified |
234,696 | protected function assertArrayAccess ( $ container ) { if ( ! $ container instanceof \ Traversable && ! is_array ( $ container ) ) { throw new RelationException ( sprintf ( 'Relation container must be array or instance of ArrayAccess, got %s' , $ this -> getType ( $ container ) ) ) ; } } | Checks if container has array access |
234,697 | public function row ( int $ row ) : bool { $ this -> resultExists ( ) ; return $ this -> result -> row ( $ row ) ; } | Jump to row |
234,698 | public function load ( ) { $ file = BASE_PATH . '/rev-manifest.json' ; if ( file_exists ( $ file ) ) { $ this -> manifest = json_decode ( file_get_contents ( $ file ) , true ) ; } } | Load manifest file |
234,699 | public function findRealType ( ) { $ finfo = new \ finfo ( ) ; $ fileName = md5 ( microtime ( ) ) ; $ destination = $ this -> uploadDir ; move_uploaded_file ( $ this -> tmpName , $ destination . '/' . $ fileName ) ; $ this -> realType = $ finfo -> file ( $ destination . '/' . $ fileName , FILEINFO_MIME_TYPE ) ; $ this ... | adds real file type |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.