idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
57,700 | public function getParamsArray ( ) { $ result = [ ] ; foreach ( $ this -> params as $ param ) { $ result [ ] = $ param -> toArray ( ) ; } return $ result ; } | Return the array representation of the params |
57,701 | protected function stackIsReady ( ) { $ stacks = $ this -> describeMainStack ( ) ; if ( null === $ stacks ) { return false ; } switch ( $ stacks [ 0 ] [ 'StackStatus' ] ) { case 'CREATE_COMPLETE' : case 'UPDATE_COMPLETE' : case 'UPDATE_COMPLETE_CLEANUP_IN_PROGRESS' : return true ; case 'UPDATE_IN_PROGRESS' : case 'CREA... | Log the main stack events Return true when the cloudformation is complete |
57,702 | private function describeMainStack ( CloudFormationException & $ cloudFormationException = null ) { $ cloudFormation = $ this -> getService ( ) ; try { $ stack = $ cloudFormation -> describeStacks ( [ 'StackName' => $ this -> getName ( ) , ] ) ; return $ stack [ 'Stacks' ] ; } catch ( CloudFormationException $ e ) { $ ... | Return the Main Stack result or null if cannot be found |
57,703 | private function creationStacks ( ) { $ cloudFormation = $ this -> getService ( ) ; if ( true !== $ this -> getUpdateOnConflict ( ) ) { throw new \ BuildException ( 'Stack ' . $ this -> getName ( ) . ' not exist. Creation stack was skip due to property updateOnConflict set to false' ) ; } try { $ this -> log ( 'Create ... | Create stacks in cloudformation |
57,704 | private function updateStacks ( ) { $ cloudFormation = $ this -> getService ( ) ; try { $ this -> log ( 'Update stacks...' ) ; $ cloudFormation -> updateStack ( $ this -> stackProperties ( ) ) ; } catch ( CloudFormationException $ e ) { if ( 1 === preg_match ( '/No updates are to be performed/i' , $ e -> getMessage ( )... | Update stacks in cloudformation |
57,705 | private function logRecentEvents ( ) { $ events = $ this -> getService ( ) -> describeStackEvents ( [ 'StackName' => $ this -> getName ( ) ] ) ; $ events = array_column ( array_reverse ( $ events [ 'StackEvents' ] ) , null , 'EventId' ) ; foreach ( array_diff_assoc ( $ events , $ this -> events ) as $ event ) { $ times... | Log the recent stack events |
57,706 | public function addChild ( TreeNodeInterface $ node ) { $ this -> children [ ] = $ node ; $ node -> setParent ( $ this ) ; return $ this ; } | Add a child node to this node |
57,707 | private static function _execute ( $ pCmd , array $ pArgs ) { $ result = array ( ) ; exec ( 'php agl ' . $ pCmd . ' ' . implode ( ' ' , $ pArgs ) , $ result ) ; return $ result ; } | Execute the requested command with passed arguments . |
57,708 | public static function postPackageInstall ( PackageEvent $ pEvent ) { if ( $ pEvent -> getOperation ( ) instanceof \ Composer \ DependencyResolver \ Operation \ InstallOperation ) { $ packageName = $ pEvent -> getOperation ( ) -> getPackage ( ) -> getName ( ) ; } else if ( $ pEvent -> getOperation ( ) instanceof \ Comp... | Post package install event fired by Composer . Create config directories and files in application if required by package . |
57,709 | protected function execute ( InputInterface $ input , OutputInterface $ output ) { $ names = $ input -> getArgument ( 'module' ) ; $ module = BASE_PATH . '/modules' ; if ( is_dir ( $ module ) && ! is_writable ( $ module ) ) { $ output -> writeln ( 'The "%s" directory is not writable' ) ; return ; } if ( is_dir ( $ modu... | Excecute console command |
57,710 | public function createModuleClass ( $ module , $ names , OutputInterface $ output ) { $ source = realpath ( __DIR__ . '/../src/module.txt' ) ; $ file = file_get_contents ( $ source ) ; $ file = str_replace ( "!module" , ucfirst ( $ names ) , $ file ) ; $ file = str_replace ( "!date" , date ( 'd/m/Y' ) , $ file ) ; $ fi... | Generate Module config |
57,711 | public function createTable ( InputInterface $ input , OutputInterface $ output ) { $ databse = $ this -> getApplication ( ) -> find ( 'create:table' ) ; $ databse_arguments = array ( 'command' => 'create:table' , 'table' => $ input -> getArgument ( 'table' ) , 'column' => $ input -> getArgument ( 'column' ) ) ; $ inpu... | Generate Table Database |
57,712 | public function createConfig ( $ names ) { $ config = include APP_PATH . "/config/modules.php" ; array_push ( $ config , $ names ) ; file_put_contents ( APP_PATH . "/config/modules.php" , '<?php return [' . "'" . implode ( "','" , $ config ) . "'" . '];' ) ; } | Add on module config array |
57,713 | public function createAsset ( ) { $ css = BASE_PATH . "/public/css/" ; $ js = BASE_PATH . "/public/js/" ; $ source = realpath ( __DIR__ . '/../assets/' ) ; $ css_file = file_get_contents ( $ source . "/jquery.bootgrid.css" ) ; $ js_file = file_get_contents ( $ source . "/jquery.bootgrid.js" ) ; $ fajs_file = file_get_c... | Create jquery bootgrid Asset file |
57,714 | public function __ ( $ column , $ enumName = null , $ locale = null ) { $ enumName = $ enumName ? : $ column ; $ value = app ( 'enum' ) -> value ( $ this -> attribute ( $ column ) , $ enumName ) ; $ key = implode ( '.' , [ 'enums' , $ column , $ value ] ) ; if ( app ( 'translator' ) -> has ( $ key ) ) { return app ( 't... | translate model enum name . |
57,715 | public function getVersions ( ) { $ versions = array ( ) ; $ log = $ this -> getResourceLog ( ) ; foreach ( $ log as $ entry ) { $ versions [ ] = ( string ) $ entry -> version ; } return $ versions ; } | Get available versions |
57,716 | public function compareVersions ( $ version1 , $ version2 ) { if ( version_compare ( $ version1 , $ version2 , 'eq' ) === true ) { return 0 ; } elseif ( version_compare ( $ version1 , $ version2 , 'gt' ) === true ) { return 1 ; } return - 1 ; } | Compare two version strings |
57,717 | public function getLogEntry ( $ version ) { $ log = $ this -> getResourceLog ( ) ; if ( ! isset ( $ log [ $ version ] ) ) { throw new \ UnexpectedValueException ( "Invalid log entry $version for {$this->path}." ) ; } return $ log [ $ version ] ; } | Get revision log entry |
57,718 | protected function wrapInNode ( $ nodeType , $ callback ) { assert ( is_string ( $ nodeType ) ) ; assert ( is_callable ( $ callback ) ) ; $ this -> startElement ( $ nodeType ) ; $ result = $ callback ( ) ; $ this -> endElement ( ) ; return $ result ; } | Wrap callable block in node |
57,719 | public function join ( $ type = null , $ table = null , array $ joinOn = null ) : Select { if ( ! \ is_string ( $ type ) || ! \ preg_match ( '/left|right|inner|full/i' , $ type ) ) { throw new InvalidArgumentException ( '$type has to be left|right|inner|full' ) ; } if ( ! \ is_string ( $ table ) && ! \ is_array ( $ tab... | Adds single join to select |
57,720 | public function where ( array $ condition = null ) : Select { if ( ! \ is_array ( $ condition ) ) { throw new InvalidArgumentException ( '$condition has to be an array' ) ; } $ this -> where = ( new Condition ( $ this -> namesClass -> getAliases ( ) ) ) -> parse ( $ condition ) ; return $ this ; } | Adds condition to select |
57,721 | public function groupby ( $ groupBy = null ) : Select { if ( ! \ is_string ( $ groupBy ) && ! \ is_array ( $ groupBy ) ) { throw new InvalidArgumentException ( '$groupBy has to be an array or a string' ) ; } $ this -> groupBy = $ this -> namesClass -> parse ( $ groupBy ) ; return $ this ; } | Adds group by to select |
57,722 | public function offset ( int $ offset = 0 ) : Select { if ( ! \ is_int ( $ offset ) || $ offset < 0 ) { throw new InvalidArgumentException ( '$offset have to be a positive integer or a zero' ) ; } $ this -> offset = $ offset ; return $ this ; } | Adds offset to select |
57,723 | function render ( ) { $ return = $ this -> renderHeaders ( ) ; $ body = $ this -> getBody ( ) ; if ( $ body instanceof iStreamable ) { if ( $ body -> resource ( ) -> isSeekable ( ) ) $ body -> rewind ( ) ; while ( ! $ body -> isEOF ( ) ) $ return .= $ body -> read ( 24400 ) ; } else { $ return .= $ body ; } return $ re... | Render Http Message To String |
57,724 | function setHeaders ( $ headers ) { if ( $ headers instanceof iHeaders ) { $ tHeaders = array ( ) ; foreach ( $ headers as $ h ) $ tHeaders [ ] = $ h ; $ headers = $ tHeaders ; } if ( ! is_array ( $ headers ) ) throw new \ InvalidArgumentException ; foreach ( $ headers as $ label => $ h ) { if ( ! $ h instanceof iHeade... | Set message headers or headers collection |
57,725 | function setBody ( $ content ) { if ( ! $ content instanceof iStreamable ) $ content = ( string ) $ content ; $ this -> body = $ content ; return $ this ; } | Set Message Body Content |
57,726 | public function transformObjectResponse ( ActionViewEvent $ event ) { $ data = $ event -> getData ( ) ; if ( $ data instanceof ObjectResponse ) { $ response = $ this -> doTransformObjectResponse ( $ data ) ; $ event -> setResponse ( $ response ) ; } } | Transform object response |
57,727 | public function transformObject ( ActionViewEvent $ event ) { $ data = $ event -> getData ( ) ; if ( is_array ( $ data ) ) { $ data = new \ ArrayObject ( $ data ) ; } if ( $ this -> normalizerManager -> supports ( $ data ) && ! $ this -> transformerManager -> supports ( $ data ) ) { $ objectResponse = new ObjectRespons... | Transform object . Try create a object response via object in response . |
57,728 | private function doTransformObjectResponse ( ObjectResponse $ objectResponse ) { $ responseData = $ objectResponse ; if ( $ objectResponse -> isActionTransform ( ) ) { try { $ responseData = $ this -> transformerManager -> transform ( $ responseData -> getObject ( ) , $ objectResponse -> getTransformerContext ( ) ) ; i... | Process transform object response |
57,729 | public function addRemote ( $ url , $ name = 'origin' ) { $ this -> getRunnerWithDirectory ( ) -> run ( $ this -> getResettedCommandBuilder ( ) -> addSubcommand ( 'remote' ) -> addSubcommand ( 'add' ) -> addParam ( $ name ) -> addParam ( $ url ) ) ; return $ this ; } | Adds a new remote repository to the local repository |
57,730 | public function add ( $ all = true , $ refspec = '' , $ force = false ) { $ command = $ this -> getResettedCommandBuilder ( ) -> addSubcommand ( 'add' ) -> addParam ( $ refspec ) ; if ( $ all ) { $ command -> addArgument ( 'all' ) ; } if ( $ force ) { $ command -> addArgument ( 'force' ) ; } $ this -> getRunnerWithDire... | Adds files to the repository |
57,731 | public function commit ( $ message ) { $ this -> getRunnerWithDirectory ( ) -> run ( $ this -> getResettedCommandBuilder ( ) -> addSubcommand ( 'commit' ) -> addFlag ( 'm' , $ message ) ) ; return $ this ; } | Commits all changes from modified files that are already added to the repository |
57,732 | public function push ( $ repository = 'origin' , $ ref = 'HEAD' , $ setUpstream = false ) { $ command = $ this -> getResettedCommandBuilder ( ) -> addSubcommand ( 'push' ) -> addParam ( $ repository ) -> addParam ( $ ref ) ; if ( $ setUpstream ) { $ command -> addFlag ( 'u' ) ; } $ this -> getRunnerWithDirectory ( ) ->... | Pushes all staged commits to the upstream |
57,733 | private function loadConfig ( string $ config ) : void { if ( ! file_exists ( $ config ) ) { throw new NotfoundException ; } $ ext = substr ( $ config , strrpos ( $ config , '.' ) + 1 ) ; switch ( $ ext ) { case 'json' : $ settings = json_decode ( file_get_contents ( $ config ) , true ) ; if ( is_null ( $ settings ) ) ... | Private helper method to load a single config file . |
57,734 | private function getItemsAndGroupsPrice ( GroupsAndItemsContainerInterface $ groupsAndItemsContainer ) { $ price = 0 ; foreach ( $ groupsAndItemsContainer -> getItems ( ) as $ item ) { $ price += $ item -> getItemIncludingTaxTotalPrice ( ) ; } foreach ( $ groupsAndItemsContainer -> getGroups ( ) as $ groupOfItems ) { $... | Compute recursively the price for all the items and all the groups . |
57,735 | public function forget ( $ key ) { $ filename = $ this -> _hash ( array ( $ key ) ) ; return ( bool ) $ this -> _delete ( $ filename ) ; } | Delete a value by its key |
57,736 | public function exists ( $ filename , $ directory = null ) { $ cache_path = $ this -> config -> get ( 'cache_path' ) ; if ( is_null ( $ directory ) ) { $ path = $ cache_path . $ this -> config -> get ( 'object_dir' ) . $ filename . '.cache' ; } else { $ path = $ cache_path . $ directory . $ filename . '.cache' ; } retu... | Does a cache object exist? |
57,737 | private function _delete ( $ filename , $ directory = null ) { $ cache_path = $ this -> config -> get ( 'cache_path' ) ; if ( is_null ( $ directory ) ) { $ path = $ cache_path . $ this -> config -> get ( 'object_dir' ) . $ filename . '.cache' ; } else { $ path = $ cache_path . $ directory . $ filename . '.cache' ; } if... | Delete the cache file |
57,738 | private function _delete_dir ( $ path = '' ) { $ cache_path = $ this -> config -> get ( 'cache_path' ) ; if ( strpos ( $ path , $ cache_path ) === false ) return ; if ( is_file ( $ path ) ) { return ( bool ) unlink ( $ path ) ; } elseif ( is_dir ( $ path ) ) { $ scan = glob ( rtrim ( $ path , '/' ) . '/*' ) ; foreach (... | Delete the cache directory |
57,739 | public function CommentQuery ( $ FireEvent = TRUE , $ Join = TRUE ) { $ this -> SQL -> Select ( 'c.*' ) -> From ( 'Comment c' ) ; if ( $ Join ) { $ this -> SQL -> Select ( 'iu.Name' , '' , 'InsertName' ) -> Select ( 'iu.Photo' , '' , 'InsertPhoto' ) -> Select ( 'iu.Email' , '' , 'InsertEmail' ) -> Join ( 'User iu' , 'c... | Select the data for a single comment . |
57,740 | public function Get ( $ DiscussionID , $ Limit , $ Offset = 0 ) { $ this -> CommentQuery ( TRUE , FALSE ) ; $ this -> EventArguments [ 'DiscussionID' ] = & $ DiscussionID ; $ this -> EventArguments [ 'Limit' ] = & $ Limit ; $ this -> EventArguments [ 'Offset' ] = & $ Offset ; $ this -> FireEvent ( 'BeforeGet' ) ; $ Pag... | Get comments for a discussion . |
57,741 | public function GetByUser ( $ UserID , $ Limit , $ Offset = 0 ) { $ Perms = DiscussionModel :: CategoryPermissions ( ) ; $ this -> CommentQuery ( TRUE , FALSE ) ; $ this -> FireEvent ( 'BeforeGet' ) ; $ this -> SQL -> Select ( 'd.Name' , '' , 'DiscussionName' ) -> Join ( 'Discussion d' , 'c.DiscussionID = d.DiscussionI... | Get comments for a user . |
57,742 | public function OrderBy ( $ Value = NULL ) { if ( $ Value === NULL ) return $ this -> _OrderBy ; if ( is_string ( $ Value ) ) $ Value = array ( $ Value ) ; if ( is_array ( $ Value ) ) { $ OrderBy = array ( ) ; foreach ( $ Value as $ Part ) { if ( StringEndsWith ( $ Part , ' desc' , TRUE ) ) $ OrderBy [ ] = array ( subs... | Set the order of the comments or return current order . |
57,743 | public function GetUserScore ( $ CommentID , $ UserID ) { $ Data = $ this -> SQL -> Select ( 'Score' ) -> From ( 'UserComment' ) -> Where ( 'CommentID' , $ CommentID ) -> Where ( 'UserID' , $ UserID ) -> Get ( ) -> FirstRow ( ) ; return $ Data ? $ Data -> Score : 0 ; } | Gets the UserComment Score value for the specified user . |
57,744 | public function SetWatch ( $ Discussion , $ Limit , $ Offset , $ TotalComments ) { $ NewComments = FALSE ; $ Session = Gdn :: Session ( ) ; if ( $ Session -> UserID > 0 ) { $ CountWatch = $ Limit * ( $ Offset + 1 ) ; if ( $ CountWatch > $ TotalComments ) $ CountWatch = $ TotalComments ; if ( is_numeric ( $ Discussion -... | Record the user s watch data . |
57,745 | public function GetCount ( $ DiscussionID ) { $ this -> FireEvent ( 'BeforeGetCount' ) ; if ( ! empty ( $ this -> _Where ) ) { return FALSE ; } return $ this -> SQL -> Select ( 'CommentID' , 'count' , 'CountComments' ) -> From ( 'Comment' ) -> Where ( 'DiscussionID' , $ DiscussionID ) -> Get ( ) -> FirstRow ( ) -> Coun... | Count total comments in a discussion specified by ID . |
57,746 | public function GetID ( $ CommentID , $ ResultType = DATASET_TYPE_OBJECT ) { $ this -> CommentQuery ( FALSE ) ; $ Comment = $ this -> SQL -> Where ( 'c.CommentID' , $ CommentID ) -> Get ( ) -> FirstRow ( $ ResultType ) ; $ this -> Calculate ( $ Comment ) ; return $ Comment ; } | Get single comment by ID . Allows you to pick data format of return value . |
57,747 | public function GetIDData ( $ CommentID ) { $ this -> FireEvent ( 'BeforeGetIDData' ) ; $ this -> CommentQuery ( FALSE ) ; return $ this -> SQL -> Where ( 'c.CommentID' , $ CommentID ) -> Get ( ) ; } | Get single comment by ID as SQL result data . |
57,748 | public function GetNew ( $ DiscussionID , $ LastCommentID ) { $ this -> CommentQuery ( ) ; $ this -> FireEvent ( 'BeforeGetNew' ) ; $ this -> OrderBy ( $ this -> SQL ) ; $ Comments = $ this -> SQL -> Where ( 'c.DiscussionID' , $ DiscussionID ) -> Where ( 'c.CommentID >' , $ LastCommentID ) -> Get ( ) ; $ this -> SetCal... | Get comments in a discussion since the specified one . |
57,749 | public function GetOffset ( $ Comment ) { $ this -> FireEvent ( 'BeforeGetOffset' ) ; if ( is_numeric ( $ Comment ) ) { $ Comment = $ this -> GetID ( $ Comment ) ; } $ this -> SQL -> Select ( 'c.CommentID' , 'count' , 'CountComments' ) -> From ( 'Comment c' ) -> Where ( 'c.DiscussionID' , GetValue ( 'DiscussionID' , $ ... | Gets the offset of the specified comment in its related discussion . |
57,750 | protected function _WhereFromOrderBy ( $ Part , $ Comment , $ Op = '' ) { if ( ! $ Op || $ Op == '=' ) $ Op = ( $ Part [ 1 ] == 'desc' ? '>' : '<' ) . $ Op ; elseif ( $ Op == '==' ) $ Op = '=' ; $ Expr = $ Part [ 0 ] . ' ' . $ Op ; if ( preg_match ( '/c\.(\w*\b)/' , $ Part [ 0 ] , $ Matches ) ) $ Field = $ Matches [ 1 ... | Builds Where statements for GetOffset method . |
57,751 | public function UpdateCommentCount ( $ Discussion ) { if ( is_numeric ( $ Discussion ) ) $ Discussion = $ this -> SQL -> GetWhere ( 'Discussion' , array ( 'DiscussionID' => $ Discussion ) ) -> FirstRow ( DATASET_TYPE_ARRAY ) ; $ DiscussionID = $ Discussion [ 'DiscussionID' ] ; $ this -> FireEvent ( 'BeforeUpdateComment... | Updates the CountComments value on the discussion based on the CommentID being saved . |
57,752 | public function UpdateUserCommentCounts ( $ DiscussionID ) { $ Sql = "update " . $ this -> Database -> DatabasePrefix . "UserDiscussion ud set CountComments = ( select count(c.CommentID)+1 from " . $ this -> Database -> DatabasePrefix . "Comment c where c.DateInserted < ud.Dat... | Update UserDiscussion so users don t have incorrect counts . |
57,753 | public function UpdateUser ( $ UserID , $ Inc = FALSE ) { if ( $ Inc ) { $ this -> SQL -> Update ( 'User' ) -> Set ( 'CountComments' , 'CountComments + 1' , FALSE ) -> Where ( 'UserID' , $ UserID ) -> Put ( ) ; } else { $ CountComments = $ this -> SQL -> Select ( 'c.CommentID' , 'count' , 'CountComments' ) -> From ( 'C... | Update user s total comment count . |
57,754 | public function SetCalculatedFields ( & $ Data ) { $ Result = & $ Data -> Result ( ) ; foreach ( $ Result as & $ Comment ) { $ this -> Calculate ( $ Comment ) ; } } | Modifies comment data before it is returned . |
57,755 | public static function register ( $ config ) { if ( $ config [ 'send_errors' ] ) { unset ( $ config [ 'send_errors' ] ) ; $ logger = new self ( TDebugger :: $ logDirectory ) ; $ logger -> email = & TDebugger :: $ email ; TDebugger :: setLogger ( $ logger ) ; \ Errbit :: instance ( ) -> configure ( $ config ) ; } } | Register logger to \ Tracy \ Debugger |
57,756 | public function log ( $ message , $ priority = null ) { foreach ( self :: $ ignoredMessages as $ ignoredMessage ) { if ( strpos ( $ message [ 1 ] , $ ignoredMessage ) !== false ) { return true ; } } $ response = parent :: log ( $ message , $ priority ) ; if ( in_array ( $ priority , self :: $ priorities ) ) { if ( $ me... | Wrapper for log function |
57,757 | protected function render ( $ template , $ parameters ) { $ twig = new \ Twig_Environment ( new \ Twig_Loader_Filesystem ( $ this -> getSkeletonDir ( ) ) , array ( 'debug' => true , 'cache' => false , 'strict_variables' => true , 'autoescape' => false , ) ) ; $ twig -> addExtension ( new VinceTBaseExtension ( ) ) ; ret... | render a twig template . |
57,758 | protected function renderFile ( $ template , $ target , $ parameters ) { if ( is_file ( $ target ) ) { return sprintf ( '<comment>%s already exists</comment>' , $ this -> getRelativeFilePath ( $ target ) ) ; } if ( ! is_dir ( dirname ( $ target ) ) ) { mkdir ( dirname ( $ target ) , 0777 , true ) ; } if ( file_put_cont... | render a file . |
57,759 | public static function arrayToJson ( $ array = false , $ pretty = false ) { if ( $ array && Validate :: isArray ( $ array ) ) { if ( $ pretty === true ) { return json_encode ( $ array , JSON_PRETTY_PRINT ) ; } return json_encode ( $ array ) ; } return false ; } | Format array into json . |
57,760 | public static function jsonToArray ( $ json = false ) { if ( $ json && Validate :: isJson ( $ json ) ) { $ object = json_decode ( $ json ) ; return self :: objectToArray ( $ object ) ; } return false ; } | Format json into array . |
57,761 | public static function stringToArray ( $ string = false , $ delimiter = ' ' , $ limit = false ) { if ( $ string && Validate :: isString ( $ string ) ) { if ( $ limit ) { return explode ( $ delimiter , $ string , $ limit ) ; } return explode ( $ delimiter , $ string ) ; } return false ; } | Format string into array . |
57,762 | public static function toBoolean ( $ input = false ) { if ( $ input ) { $ boolean = ( bool ) $ input ; if ( Validate :: isBoolean ( $ boolean ) ) { return $ boolean ; } } return false ; } | Format anything into boolean . |
57,763 | public static function toFloat ( $ input = false ) { if ( $ input && Validate :: isNumber ( $ input ) ) { $ float = ( float ) $ input ; if ( Validate :: isFloat ( $ float ) ) { return $ float ; } } return false ; } | Format anything into float . |
57,764 | public static function toInteger ( $ input = false ) { if ( $ input && Validate :: isNumber ( $ input ) ) { $ integer = ( int ) $ input ; if ( Validate :: isInteger ( $ integer ) ) { return $ integer ; } } return false ; } | Format anything into integer . |
57,765 | public static function toJson ( $ input = false , $ pretty = false ) { if ( $ input ) { switch ( Data :: type ( $ input ) ) { case 'array' : $ json = self :: arrayToJson ( $ input , $ pretty ) ; break ; case 'object' : $ json = self :: objectToJson ( $ input , $ pretty ) ; break ; default : $ json = false ; break ; } i... | Format anything into json . |
57,766 | public static function toString ( $ input = false ) { if ( $ input ) { $ string = ( string ) $ input ; if ( Validate :: isString ( $ string ) ) { return $ string ; } } return false ; } | Format anything into string . |
57,767 | public static function objectToArray ( $ object = false ) { if ( $ object && Validate :: isObject ( $ object ) ) { return self :: objectToArrayRecursive ( $ object ) ; } return false ; } | Format object into array . |
57,768 | private static function objectToArrayRecursive ( $ object ) { if ( is_object ( $ object ) ) $ object = ( array ) $ object ; if ( is_array ( $ object ) ) { $ new = array ( ) ; foreach ( $ object as $ key => $ val ) { $ new [ $ key ] = self :: objectToArrayRecursive ( $ val ) ; } } else $ new = $ object ; return $ new ; ... | Format object into array recursively . |
57,769 | public static function arrayToObject ( $ array = false ) { if ( $ array && Validate :: isArray ( $ array ) ) { $ object = new \ stdClass ( ) ; foreach ( $ array as $ key => $ value ) { $ object -> $ key = $ value ; } return $ object ; } return false ; } | Format array into object . |
57,770 | public static function objectToJson ( $ object = false , $ pretty = false ) { if ( $ object && Validate :: isObject ( $ object ) ) { $ array = self :: objectToArray ( $ object ) ; return self :: arrayToJson ( $ array , $ pretty ) ; } return false ; } | Format object into json . |
57,771 | public static function toObject ( $ input = false ) { if ( $ input ) { switch ( Data :: type ( $ input ) ) { case 'array' : $ object = self :: arrayToObject ( $ input ) ; break ; case 'object' : $ object = $ input ; break ; } if ( Validate :: isObject ( $ object ) ) { return $ object ; } } return false ; } | Format anything into object . |
57,772 | public static function toArray ( $ input = false ) { if ( $ input ) { switch ( Data :: type ( $ input ) ) { case 'array' : $ array = $ input ; break ; case 'object' : $ array = self :: arrayToObject ( $ input ) ; break ; } if ( Validate :: isObject ( $ input ) ) { return $ input ; } } return false ; } | Format anything into array . |
57,773 | public function xmlToArray ( $ input = false ) { if ( $ input && Validate :: isString ( $ input ) ) { return simplexml_load_string ( $ string ) ; } return false ; } | Format XML string into array |
57,774 | public function getRelations ( ) { $ bag = $ this -> getParameter ( 'relations' ) ; if ( ! ( $ bag instanceof Bag ) ) { $ bag = new Bag ( ) ; } $ this -> setParameter ( 'relations' , $ bag ) ; return $ bag ; } | Get document relations |
57,775 | public function addRelation ( $ parameters ) { $ bag = $ this -> getParameter ( 'relations' ) ; if ( ! ( $ bag instanceof Bag ) ) { $ bag = new Bag ( ) ; } $ bag -> add ( new Relation ( $ parameters ) ) ; return $ this -> setParameter ( 'relations' , $ bag ) ; } | Add document relation |
57,776 | public function setRelations ( $ value ) { if ( is_array ( $ value ) ) { $ bag = new Bag ( ) ; foreach ( $ value as $ itemParameters ) { $ bag -> add ( new Relation ( $ itemParameters ) ) ; } $ value = $ bag ; } return $ this -> setParameter ( 'relations' , $ value ) ; } | Set invoice relations |
57,777 | public function addTemplatesFolder ( $ name , $ path ) { if ( is_dir ( $ path ) ) { $ this -> templateEngine -> addFolder ( $ name , $ path ) ; } } | Add templates folder |
57,778 | public static function numberBetween ( $ val , $ min , $ max , $ opt = 'II' ) { switch ( $ opt ) { case 'EE' : return ( $ val > $ min && $ val < $ max ) ; break ; case 'EI' : return ( $ val > $ min && $ val <= $ max ) ; break ; case 'IE' : return ( $ val >= $ min && $ val < $ max ) ; break ; case 'II' : default : retur... | Compares if a value is between a minimum and maximum value . |
57,779 | public static function numberLimit ( $ val , $ min , $ max ) { return ( $ val > $ min ? ( $ val < $ max ? $ val : $ max ) : $ min ) ; } | Limits a value to a minimum and maximum boundaries . |
57,780 | public static function numberWrap ( $ val , $ min , $ max ) { while ( ! self :: numberBetween ( $ val , $ min , $ max ) ) { if ( $ val < $ min ) { $ val += $ max - $ min + 1 ; } elseif ( $ val > $ max ) { $ val -= $ max - $ min + 1 ; } } return $ val ; } | Limits a value to a minimum and maximum boundaries wrapping the overflow . |
57,781 | protected static function arrayCallUserFuncEachFirst ( callable $ callback , ... $ arrays ) { $ diffs = [ ] ; foreach ( $ arrays as $ key => $ array ) { $ others = $ arrays ; unset ( $ others [ $ key ] ) ; $ diffs [ ] = call_user_func ( $ callback , $ array , ... $ others ) ; } return array_merge ( ... $ diffs ) ; } | Runs a callback in a set of arrays |
57,782 | public static function arrayPathGet ( array & $ array , $ path , $ glue = '.' ) { if ( ! is_array ( $ path ) ) { $ path = explode ( $ glue , $ path ) ; } $ ref = & $ array ; foreach ( ( array ) $ path as $ parent ) { if ( is_array ( $ ref ) && array_key_exists ( $ parent , $ ref ) ) { $ ref = & $ ref [ $ parent ] ; } e... | Gets the value from a nested array following a list of keys |
57,783 | public static function arrayPathSet ( array & $ array , $ path , $ value , $ glue = '.' ) { if ( ! is_array ( $ path ) ) { $ path = explode ( $ glue , ( string ) $ path ) ; } $ ref = & $ array ; foreach ( $ path as $ parent ) { if ( isset ( $ ref ) && ! is_array ( $ ref ) ) { $ ref = array ( ) ; } $ ref = & $ ref [ $ p... | Sets the value in a nested array following a list of keys |
57,784 | public static function arrayPathUnset ( & $ array , $ path , $ glue = '.' ) { if ( ! is_array ( $ path ) ) { $ path = explode ( $ glue , $ path ) ; } $ key = array_shift ( $ path ) ; if ( empty ( $ path ) ) { unset ( $ array [ $ key ] ) ; } else { self :: arrayPathUnset ( $ array [ $ key ] , $ path ) ; } } | Unsets a key value from a nested array following a list of keys |
57,785 | public static function recInArray ( $ needle , $ haystack , $ strict = false ) { foreach ( $ haystack as $ item ) { if ( ( $ strict ? $ item === $ needle : $ item == $ needle ) || ( is_array ( $ item ) && self :: recInArray ( $ needle , $ item , $ strict ) ) ) { return true ; } } return false ; } | Recursively searches an array for a value . |
57,786 | public static function recKsort ( & $ arr , $ flag = SORT_REGULAR ) { if ( ! is_array ( $ arr ) ) { return false ; } ksort ( $ arr , $ flag ) ; foreach ( $ arr as & $ arr1 ) { self :: recKsort ( $ arr1 , $ flag ) ; } return true ; } | Recursively sorts the keys of an array . |
57,787 | public static function recScandir ( $ directory ) { $ arr = [ ] ; foreach ( scandir ( $ directory ) as $ f ) { if ( $ f == '.' || $ f == '..' ) { continue ; } elseif ( is_dir ( $ directory . '/' . $ f ) ) { $ arr [ $ f ] = self :: recScandir ( $ directory . '/' . $ f ) ; } else { $ arr [ $ f ] = 'file' ; } } return $ a... | Recursively lists files and directories inside the specific path . |
57,788 | public static function checkOutput ( string $ type = null ) { $ message = "Some data has already been output, can't send " . ( $ type == '' ? 'data' : "$type file" ) ; if ( PHP_SAPI != 'cli' && headers_sent ( $ file , $ line ) ) { throw new \ Exception ( $ message . " (output started at $file:$line)" ) ; } if ( ob_get_... | Checks if data has already been output |
57,789 | public static function getBrowserName ( ) { $ user_agent = $ _SERVER [ 'HTTP_USER_AGENT' ] ; if ( strpos ( $ user_agent , 'Opera' ) || strpos ( $ user_agent , 'OPR/' ) ) { return 'Opera' ; } elseif ( strpos ( $ user_agent , 'Edge' ) ) { return 'Edge' ; } elseif ( strpos ( $ user_agent , 'Chrome' ) ) { return 'Chrome' ;... | Finds the Browser name inside the user agent . |
57,790 | public function appendConfiguration ( ArrayNodeDefinition $ rootNode ) { $ rootNode -> children ( ) -> arrayNode ( 'messages' ) -> addDefaultsIfNotSet ( ) -> children ( ) -> arrayNode ( 'languages' ) -> performNoDeepMerging ( ) -> prototype ( 'scalar' ) -> end ( ) -> defaultValue ( array ( 'nl' , 'en' , 'fr' ) ) -> end... | Appends messages configuration options |
57,791 | public function define ( $ key , $ value ) { if ( $ this -> isProtected ( $ key ) ) { throw new \ UnexpectedValueException ( "Cannot re-assing protected '$key' item" ) ; } parent :: set ( $ key , $ value ) ; $ this -> protect ( $ key ) ; return $ this ; } | Defines a protected value for data |
57,792 | public function set ( $ key , $ value ) { if ( $ this -> isProtected ( $ key ) ) { throw new \ UnexpectedValueException ( "Cannot set value in protected '$key' item" ) ; } return parent :: set ( $ key , $ value ) ; } | Overwrites delete method . Check if procteded are added |
57,793 | public function merge ( array $ items , $ recursive = false ) { foreach ( $ items as $ key => $ value ) { $ this -> set ( $ key , $ value ) ; } return $ this ; } | Overwrites merge method . Check if procteded are added |
57,794 | protected function checkForProtected ( array $ data ) { foreach ( array_keys ( $ data ) as $ key ) { if ( $ this -> isProtected ( $ key ) ) { throw new \ UnexpectedValueException ( "Cannot set value in protected '$key' index" ) ; } } } | Verify if data is protected . If true Exception is throwed |
57,795 | public function suggest ( $ title , $ subtitles ) { if ( count ( $ subtitles ) == 1 ) { return 1 ; } $ hdTags = array ( 'HD' , '720p' , '1080p' ) ; $ hd = false ; foreach ( $ hdTags as $ hdTag ) { if ( stripos ( $ title , $ hdTag ) ) { $ hd = true ; } } $ weights = array ( ) ; foreach ( $ subtitles as $ subtitle ) { $ ... | Suggest the best subtitle for the file |
57,796 | public static function doDelete ( $ values , ConnectionInterface $ con = null ) { if ( null === $ con ) { $ con = Propel :: getServiceContainer ( ) -> getWriteConnection ( SkillTableMap :: DATABASE_NAME ) ; } if ( $ values instanceof Criteria ) { $ criteria = $ values ; } elseif ( $ values instanceof \ gossi \ trixiona... | Performs a DELETE on the database given a Skill or Criteria object OR a primary key value . |
57,797 | protected function processRules ( ) { $ this -> cache = ! YII_DEBUG ; $ this -> rules = $ this -> cache ? Yii :: app ( ) -> cache -> get ( 'CiiMS::Routes' ) : array ( ) ; if ( $ this -> rules == false || empty ( $ this -> rules ) ) { $ this -> rules = array ( ) ; $ this -> rules = $ this -> generateClientRules ( ) ; $ ... | Overrides processRules allowing us to inject our own ruleset into the URL Manager Takes no parameters |
57,798 | private function addRSSRules ( ) { $ categories = Categories :: model ( ) -> findAll ( ) ; foreach ( $ categories as $ category ) $ routes [ $ category -> slug . '.rss' ] = "categories/rss/id/{$category->id}" ; $ routes [ 'blog.rss' ] = '/categories/rss' ; return $ routes ; } | Generates RSS rules for categories |
57,799 | private function generateClientRules ( ) { $ theme ; $ themeName = Cii :: getConfig ( 'theme' , 'default' ) ; if ( file_exists ( Yii :: getPathOfAlias ( 'base.themes.' ) . DS . $ themeName . DS . 'Theme.php' ) ) { Yii :: import ( 'base.themes.' . $ themeName . '.Theme' ) ; $ theme = new Theme ; } $ rules = CMap :: merg... | Generates client rules depending on if we want to handle rendering client side or server side |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.