idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
1,700 | public function showPage ( Request $ request , $ path = '' ) { $ uri = $ request -> getRequestUri ( ) ; if ( strlen ( $ uri ) > 1 && substr ( $ uri , - 1 ) === '/' ) { return redirect ( rtrim ( $ request -> path ( ) , '/' ) , 301 ) ; } $ pathInfo = LocaleService :: parsePath ( $ path ) ; $ pagePath = $ pathInfo -> page... | Show the selected page |
1,701 | public static function setDefaultSeparator ( $ cSeparator , $ bMerge = true ) { self :: $ cDefaultSeparator = $ cSeparator ; self :: setSeparator ( $ cSeparator , $ bMerge ) ; } | Set default separator |
1,702 | public function addRoute ( array $ verbs , $ pattern , $ action , $ name = null ) { $ pattern = $ this -> resolvePatternValue ( $ pattern ) ; $ action = $ this -> resolveActionValue ( $ action ) ; $ name = $ this -> resolveNameValue ( $ name ) ; $ route = new Route ( $ pattern , $ action , $ verbs , $ name ) ; if ( $ f... | Create a new route instance and attach to Collection |
1,703 | private function prepareCondition ( $ q ) { $ condition = [ ] ; foreach ( $ this -> searchFields as $ field ) { $ condition [ ] = [ 'like' , $ field , $ q ] ; } if ( count ( $ this -> searchFields ) > 1 ) { array_unshift ( $ condition , 'or' ) ; } return $ condition ; } | Prepares query condition |
1,704 | public function push ( $ value ) : StackInterface { $ this -> resolver -> value ( function ( $ value ) : void { $ this -> items -> push ( $ value ) ; } , $ value ) ; return $ this ; } | Pushes one value onto the top of the stack . |
1,705 | public function pushAll ( iterable $ input ) : StackInterface { foreach ( $ input as $ value ) { $ this -> push ( $ value ) ; } return $ this ; } | Pushes zero or more values onto the top of the stack . |
1,706 | function checkPhpVersion ( int $ pMajor , int $ pMinor = NULL , int $ pRelease = NULL ) { $ requirementsMet = TRUE ; $ phpVersion = \ phpversion ( ) ; $ version = \ explode ( '.' , \ phpversion ( ) ) ; $ version [ 2 ] = \ str_replace ( '-dev' , '' , $ version [ 2 ] ) ; if ( $ version [ 0 ] < $ pMajor ) { $ requirements... | Check the PHP version and throws an error if it does not meet the minimum version . |
1,707 | function convertToClassName ( $ pString ) { $ className = \ basename ( $ pString , '.php' ) ; $ className = $ this -> camelCase ( $ className , TRUE ) ; return $ className ; } | Turn a string into camel - cased word . |
1,708 | public function getAuthorReviews ( $ author , $ size = SPIGET4PHP_DEFAULT , $ page = SPIGET4PHP_DEFAULT , $ sort = SPIGET4PHP_DEFAULT , $ fields = SPIGET4PHP_DEFAULT ) { $ function = 'authors/' . $ author . '/reviews' ; $ args = [ ] ; if ( ! is_null ( $ size ) ) $ args [ 'size' ] = $ size ; if ( ! is_null ( $ page ) ) ... | Get the reviews of an specific author . |
1,709 | public function getCategoryList ( $ size = SPIGET4PHP_DEFAULT , $ page = SPIGET4PHP_DEFAULT , $ sort = SPIGET4PHP_DEFAULT , $ fields = SPIGET4PHP_DEFAULT ) { $ function = 'categories' ; $ args = [ ] ; if ( ! is_null ( $ size ) ) $ args [ 'size' ] = $ size ; if ( ! is_null ( $ page ) ) $ args [ 'page' ] = $ page ; if ( ... | Get a list of categories . |
1,710 | public function getCategoryResources ( $ category , $ size = SPIGET4PHP_DEFAULT , $ page = SPIGET4PHP_DEFAULT , $ sort = SPIGET4PHP_DEFAULT , $ fields = SPIGET4PHP_DEFAULT ) { $ function = 'categories/' . $ category . '/resources' ; $ args = [ ] ; if ( ! is_null ( $ size ) ) $ args [ 'size' ] = $ size ; if ( ! is_null ... | Get a list of resources of an specific category . |
1,711 | public function getSearchResource ( $ resource , $ size = SPIGET4PHP_DEFAULT , $ page = SPIGET4PHP_DEFAULT , $ sort = SPIGET4PHP_DEFAULT , $ fields = SPIGET4PHP_DEFAULT ) { $ function = 'search/resources/' . $ resource ; $ args = [ ] ; if ( ! is_null ( $ size ) ) $ args [ 'size' ] = $ size ; if ( ! is_null ( $ page ) )... | Get a resource - search results .. |
1,712 | public function getSearchAuthors ( $ author , $ field = SPIGET4PHP_DEFAULT , $ size = SPIGET4PHP_DEFAULT , $ page = SPIGET4PHP_DEFAULT , $ sort = SPIGET4PHP_DEFAULT , $ fields = SPIGET4PHP_DEFAULT ) { $ function = 'search/authors/' . $ author ; $ args = [ ] ; if ( ! is_null ( $ field ) ) $ args [ 'field' ] = $ field ; ... | Get the search - result for an specific username . |
1,713 | private function getResult ( $ function , $ args = [ ] , $ post = false ) { $ qargs = ( $ post ? '' : '?' ) . http_build_query ( $ args ) ; $ curl = curl_init ( $ this -> spiget . $ function . ( ! $ post ? ( sizeof ( $ args ) > 0 ? $ qargs : '' ) : '' ) ) ; curl_setopt ( $ curl , CURLOPT_USERAGENT , $ this -> userargen... | Get the result of an api - request . |
1,714 | public static function getInstance ( $ useragent = 'Spiget4PHP' ) { if ( is_null ( SpigetAPI :: $ instance ) ) { SpigetAPI :: $ instance = new SpigetAPI ( $ useragent ) ; } return SpigetAPI :: $ instance ; } | Get the current instance of the api - wrapper or create a new one . |
1,715 | public function fill ( array $ input ) { $ this -> assertIsFillable ( ) ; ArrayMap :: of ( $ input ) -> only ( $ this -> getFillable ( ) ) -> each ( function ( $ value , $ key ) { $ setter = vsprintf ( 'set%s' , [ Str :: studly ( $ key ) ] ) ; if ( method_exists ( $ this , $ setter ) ) { $ this -> $ setter ( $ value ) ... | Fill properties in this object using an input array . |
1,716 | public function toArray ( ) { $ result = [ ] ; ArrayList :: of ( $ this -> getFillable ( ) ) -> append ( ArrayList :: of ( $ this -> getVisible ( ) ) ) -> unique ( SORT_STRING ) -> exceptValues ( $ this -> getHidden ( ) ) -> each ( function ( $ key ) use ( & $ result ) { $ getter = vsprintf ( 'get%s' , [ Str :: studly ... | Get an array representation of this entity . |
1,717 | public function handleRoute ( $ fullslug ) { if ( ! $ structure = $ this -> tree -> find ( $ fullslug ) ) { $ slugParts = explode ( '/' , $ fullslug ) ; foreach ( $ this -> tree -> findBySlug ( end ( $ slugParts ) ) as $ structure ) { if ( $ fullslug == $ structure -> full_slug ) { break ; } } } if ( $ structure ) { re... | Handle an Incoming Route . |
1,718 | private function renderPage ( $ structure ) { $ page = $ structure -> page ; $ template = $ structure -> template ? $ structure -> template : 'pages.' . strtolower ( substr ( strrchr ( get_class ( $ page ) , "\\" ) , 1 ) ) ; return view ( $ template , [ 'page' => $ page ] ) ; } | Render a Page |
1,719 | public function deleteFromCache ( $ key ) { $ file = $ this -> cachePath . $ this -> getEncodedKey ( $ key ) ; if ( file_exists ( $ file ) ) { unlink ( $ file ) ; } } | Supprime une valeur du cache |
1,720 | public function clearCache ( ) { $ files = glob ( $ this -> cachePath ) ; foreach ( $ files as $ file ) { if ( is_file ( $ file ) ) { unlink ( $ file ) ; } } } | Supprime tout le contenu du cache |
1,721 | public function setExceptionMessages ( Exception $ e ) { $ this -> flashMessenger ( ) -> addErrorMessage ( [ 'message' => $ e -> getMessage ( ) , 'title' => 'Error!' ] ) ; $ prevException = $ e -> getPrevious ( ) ; if ( $ prevException ) { while ( $ prevException ) { $ this -> flashMessenger ( ) -> addErrorMessage ( $ ... | Sets a exception message for flash plugin . |
1,722 | public function dispatch ( string $ class , string $ method , array $ vars , \ Psr \ Http \ Message \ RequestInterface $ request , \ Psr \ Http \ Message \ ResponseInterface $ response , array $ middlewares ) : \ Psr \ Http \ Message \ ResponseInterface { $ middlewares [ ] = Caller :: class ; $ relayBuilder = new Relay... | Resolver dispatch . |
1,723 | public function getAllTranslationByLanguage ( ) { $ messages = array ( ) ; foreach ( $ this -> getLanguageList ( ) as $ language ) { $ messages [ $ language ] = $ this -> getTranslationsForLanguage ( $ language ) ; } return $ messages ; } | Return the list of all translation . The table has 2 dimensions . The first is the language . The second is the key value of translation |
1,724 | public function getAllKey ( ) { $ keys = array ( ) ; foreach ( $ this -> getAllTranslationByLanguage ( ) as $ translations ) { $ keys = array_merge ( $ keys , $ translations ) ; } return array_keys ( $ keys ) ; } | Return an array with all the key create without language checking |
1,725 | public function internalize ( $ url = '' ) { if ( is_array ( $ url ) ) { $ url = implode ( '/' , $ url ) ; } if ( preg_match ( '|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i' , $ url ) ) return $ url ; $ sPath = $ this -> request -> getBasePath ( ) . "/" ; if ( ! empty ( $ url ) && $ sPath <> "/" ) { $ parts... | Resolves a url adds path if missing |
1,726 | public function externalize ( $ path , $ schema = "http" ) { if ( ! is_array ( $ path ) ) : if ( preg_match ( '|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i' , $ path ) ) return $ path ; endif ; $ sHost = $ this -> request -> getHost ( ) ; $ path = $ schema . "://" . $ sHost . static :: internalize ( $ path ... | Adds the schema host and path to an internal url path |
1,727 | public static function trimPattern ( $ value , array $ params ) { if ( empty ( $ value ) || empty ( $ params [ 'pattern' ] ) ) { return $ value ; } $ params [ 'limit' ] = Helper :: getValue ( $ params [ 'limit' ] , - 1 ) ; return StringHelper :: trimPattern ( $ value , $ params [ 'pattern' ] , $ params [ 'limit' ] ) ; ... | Trim by pattern . |
1,728 | public static function contains ( $ value , array $ params , Template $ template ) { if ( empty ( $ params ) || count ( $ params ) < 2 || ! isset ( $ params [ 'then' ] ) ) { throw new TemplateException ( TemplateException :: UNKNOWN_PARAM_FILTER , [ 'name' => __METHOD__ ] ) ; } $ params [ 'else' ] = isset ( $ params [ ... | Check contains word or char in string |
1,729 | public static function truncateWords ( $ value , array $ params ) { if ( empty ( $ params [ 'length' ] ) || ! is_numeric ( $ params [ 'length' ] ) ) { $ params [ 'length' ] = 100 ; } return StringHelper :: truncateWords ( $ value , ( int ) $ params [ 'length' ] ) ; } | Truncates a string to the number of words specified . |
1,730 | protected function updateAuthConfig ( ) { $ path = config_path ( 'auth.php' ) ; file_put_contents ( $ path , str_replace ( 'users' , 'SecUsers' , file_get_contents ( $ path ) ) ) ; file_put_contents ( $ path , str_replace ( 'App\User::class' , 'Alfredoem\Ragnarok\SecUsers\SecUser::class' , file_get_contents ( $ path ) ... | Update the auth configuration file . |
1,731 | public function generate ( $ length = 10 , $ availables = self :: CHAR_ALPHADIGIT , array $ tokens = array ( self :: CHAR_ALPHA , self :: CHAR_DIGIT ) ) { $ tokens = array_pad ( $ tokens , $ length , $ availables ) ; shuffle ( $ tokens ) ; $ password = '' ; foreach ( $ tokens as $ token ) { $ tokenChars = '' ; foreach ... | Generate a random complex password |
1,732 | public function bind ( $ id , $ concrete = null , $ shared = false ) { if ( null === $ concrete ) { $ concrete = $ id ; } $ id = $ this -> normalizeString ( $ id ) ; if ( is_object ( $ concrete ) && ! $ concrete instanceof \ Closure ) { $ instance = $ this -> applyExtenders ( $ id , $ concrete ) ; $ this -> sharedInsta... | Binds an id and value into the container . |
1,733 | public function extend ( $ id , callable $ extender ) { if ( ! $ this -> has ( $ id ) ) { throw new NotFoundException ( 'Alias (' . $ id . ') is not being managed by the container' ) ; } $ this -> extenders [ $ id ] [ ] = $ extender ; } | Allows registration of callbacks run before the instance is resolved from the container . |
1,734 | public function save ( ) { if ( ! $ entityMgr = $ this -> getEntityManager ( ) ) { throw new \ Exception ( 'Model can not be inserted without an Entity Manager (setEntityManager).' ) ; } if ( ! $ this -> getTableName ( ) ) { throw new \ Exception ( 'Model can not be inserted without a defined table name.' ) ; } $ stmtM... | Saves a model to the database . |
1,735 | public function slugify ( $ name , $ pluralize = true ) { if ( class_exists ( $ name ) ) { $ name = $ this -> shortName ( $ name ) ; } $ inflector = Inflector :: get ( ) ; if ( $ pluralize === true ) { $ name = $ inflector -> pluralize ( $ name ) ; } return $ inflector -> dasherize ( $ inflector -> underscore ( $ name ... | Constructs a slug for a class name or other subject for use in URLs . |
1,736 | public function pluralize ( $ className ) { $ className = $ this -> shortName ( $ className ) ; $ inflector = Inflector :: get ( ) ; return $ inflector -> pluralize ( $ className ) ; } | Pluralizes a class s name . |
1,737 | public final function enable ( $ state = true ) { $ old_state = $ this -> _enabled ; $ this -> _enabled = ( bool ) $ state ; return $ old_state ; } | Toggle the enabled - state of the Cache . |
1,738 | protected function validateValueSize ( $ value ) { $ size = strlen ( serialize ( $ value ) ) ; $ allowed = 1024 * 1024 * 4 ; if ( $ size > $ allowed ) { return false ; } return true ; } | Check if the serialized value is smaller than 2 MB . |
1,739 | public static function exists ( string $ file = '' ) : bool { $ file = static :: normalizePath ( $ file ) ; return static :: verifyPath ( $ file ) && \ file_exists ( $ file ) && \ is_file ( $ file ) ; } | Checks whether file exists . |
1,740 | public static function isLink ( string $ file = '' ) : bool { $ file = static :: normalizePath ( $ file ) ; return static :: exists ( $ file ) && \ is_link ( $ file ) ; } | Checks whether file is a link |
1,741 | public static function read ( string $ file = '' ) : string { $ result = false ; $ file = static :: normalizePath ( $ file ) ; if ( static :: exists ( $ file ) ) { $ result = @ \ file_get_contents ( $ file ) ; } return $ result ; } | Reads data from file . |
1,742 | public static function write ( string $ file = '' , string $ data = '' , bool $ doAppend = false ) : bool { $ result = false ; $ file = static :: normalizePath ( $ file ) ; if ( static :: verifyPath ( $ file ) && Directory :: create ( \ dirname ( $ file ) ) ) { $ flags = $ doAppend ? FILE_APPEND : 0 ; $ flags |= static... | Writes data to file . Creates directories if required . |
1,743 | public static function append ( string $ file = '' , string $ data = '' ) : bool { return static :: write ( $ file , $ data , true ) ; } | Appends data to file . |
1,744 | public static function getThemePath ( ) { $ reflector = new \ ReflectionClass ( get_called_class ( ) ) ; $ namespaceName = $ reflector -> getNamespaceName ( ) ; static :: $ themePath = '@' . str_replace ( '\\' , '/' , $ namespaceName ) ; return static :: $ themePath ; } | Gets the called theme class path . |
1,745 | public static function registerTranslations ( ) { if ( ! isset ( Yii :: $ app -> i18n -> translations [ static :: getThemePath ( ) . '/*' ] ) && ! isset ( Yii :: $ app -> i18n -> translations [ static :: getThemePath ( ) ] ) ) { Yii :: $ app -> i18n -> translations [ static :: getThemePath ( ) . '/*' ] = [ 'class' => '... | Registers the translation files . |
1,746 | function mf_redirect ( $ section = 'mf_dashboard' , $ action = 'main' , $ vars = array ( ) ) { $ url = $ this -> _get_url ( $ section , $ action , $ vars ) ; wp_safe_redirect ( $ url ) ; exit ; } | is a wrapper of wp_safe_redirect |
1,747 | function mf_flash ( $ message = 'Return dashoard' , $ url = array ( 'section' => 'mf_dashboard' , 'action' => 'main' , 'vars' => '' ) , $ type = 'error' ) { if ( is_array ( $ url ) ) { $ url = $ this -> _get_url ( $ url [ 'section' ] , $ url [ 'action' ] , $ url [ 'vars' ] ) ; } printf ( ' <div class="wrap"><div id="me... | Display a friendly message of error |
1,748 | public function get_custom_taxonomy_by_type ( $ type_taxonomy ) { global $ wpdb ; $ query = sprintf ( "SELECT * FROM %s WHERE type = '%s'" , MF_TABLE_CUSTOM_TAXONOMY , $ type_taxonomy ) ; $ custom_taxonomy = $ wpdb -> get_row ( $ query , ARRAY_A ) ; if ( $ custom_taxonomy ) { $ id = $ custom_taxonomy [ 'id' ] ; $ custo... | get a specific custom_taxonomy |
1,749 | public function get_groups_by_post_type ( $ post_type ) { global $ wpdb ; $ query = sprintf ( "SELECT * FROM %s WHERE post_type = '%s' ORDER BY id" , MF_TABLE_CUSTOM_GROUPS , $ post_type ) ; $ groups = $ wpdb -> get_results ( $ query , ARRAY_A ) ; return $ groups ; } | return all gruops of post type |
1,750 | public function get_default_custom_group ( $ post_type ) { global $ wpdb ; $ query = sprintf ( "SELECT id FROM %s WHERE name = '__default' AND post_type = '%s' " , MF_TABLE_CUSTOM_GROUPS , $ post_type ) ; $ group = $ wpdb -> get_col ( $ query ) ; if ( ! $ group ) { $ wpdb -> insert ( MF_TABLE_CUSTOM_GROUPS , array ( 'n... | Return id of default group for post type |
1,751 | public static function group_has_fields ( $ group_id ) { global $ wpdb ; $ sql = $ wpdb -> prepare ( "SELECT COUNT(1) FROM " . MF_TABLE_CUSTOM_FIELDS . " WHERE custom_group_id = %d" , $ group_id ) ; return $ wpdb -> get_var ( $ sql ) > 0 ; } | Return True if the group has at least one custom field |
1,752 | public function get_custom_fields_by_group ( $ id ) { global $ wpdb ; $ query = sprintf ( "SELECT * FROM %s WHERE custom_group_id = '%s' ORDER BY display_order" , MF_TABLE_CUSTOM_FIELDS , $ id ) ; $ fields = $ wpdb -> get_results ( $ query , ARRAY_A ) ; return $ fields ; } | return all fields of group |
1,753 | public static function get_unique_custom_fields_by_post_type ( $ post_type = "post" ) { global $ wpdb ; $ query = "SELECT DISTINCT(type) FROM " . MF_TABLE_CUSTOM_FIELDS . " WHERE post_type = '" . $ post_type . "'" ; $ fields = $ wpdb -> get_col ( $ query ) ; return $ fields ; } | return a unique type the fields of post type |
1,754 | public function get_custom_field_by_name ( $ name_custom_field , $ post_type ) { global $ wpdb ; $ query = sprintf ( 'SELECT * FROM %s WHERE name = "%s" AND post_type = "%s" ' , MF_TABLE_CUSTOM_FIELDS , $ name_custom_field , $ post_type ) ; $ field = $ wpdb -> get_row ( $ query , ARRAY_A ) ; return $ field ; } | return a field by name and post type |
1,755 | public function new_posttype ( $ data ) { global $ wpdb ; array_walk_recursive ( $ data , array ( $ this , 'escape_data' ) ) ; $ sql = $ wpdb -> prepare ( "INSERT INTO " . MF_TABLE_POSTTYPES . " (type, name, description, arguments, active)" . " values" . " (%s, %s, %s, %s, %d)" , $ data [ 'core' ] [ 'type' ] , $ data [... | Save a new post |
1,756 | public function update_post_type ( $ data ) { global $ wpdb ; array_walk_recursive ( $ data , array ( $ this , 'escape_data' ) ) ; $ sql = $ wpdb -> prepare ( "Update " . MF_TABLE_POSTTYPES . " SET type = %s, name = %s, description = %s, arguments = %s " . " WHERE id = %d" , $ data [ 'core' ] [ 'type' ] , $ data [ 'cor... | Update Post type data |
1,757 | public function new_custom_group ( $ data ) { global $ wpdb ; array_walk_recursive ( $ data , array ( $ this , 'escape_data' ) ) ; $ sql = $ wpdb -> prepare ( "INSERT INTO " . MF_TABLE_CUSTOM_GROUPS . " (name, label, post_type, duplicated, expanded) " . " VALUES (%s, %s, %s, %d, %d)" , $ data [ 'core' ] [ 'name' ] , $ ... | Add a new custom group |
1,758 | public function update_custom_group ( $ data ) { global $ wpdb ; array_walk_recursive ( $ data , array ( $ this , 'escape_data' ) ) ; $ sql = $ wpdb -> prepare ( "UPDATE " . MF_TABLE_CUSTOM_GROUPS . " SET name = %s, label =%s, duplicated = %d, expanded = %d " . " WHERE id = %d" , $ data [ 'core' ] [ 'name' ] , $ data [... | Update a custom group |
1,759 | public function new_custom_taxonomy ( $ data ) { global $ wpdb ; array_walk_recursive ( $ data , array ( $ this , 'escape_data' ) ) ; $ sql = $ wpdb -> prepare ( "INSERT INTO " . MF_TABLE_CUSTOM_TAXONOMY . " (type, name, description, arguments, active)" . " values" . " (%s, %s, %s, %s, %d)" , $ data [ 'core' ] [ 'type'... | Save a new custom taxonomy |
1,760 | public function update_custom_taxonomy ( $ data ) { global $ wpdb ; array_walk_recursive ( $ data , array ( $ this , 'escape_data' ) ) ; $ sql = $ wpdb -> prepare ( "Update " . MF_TABLE_CUSTOM_TAXONOMY . " SET type = %s, name = %s, description = %s, arguments = %s " . " WHERE id = %d" , $ data [ 'core' ] [ 'type' ] , $... | Update a custom taxonomy |
1,761 | function get ( $ name ) { if ( ! isset ( $ this -> db [ $ name ] ) ) { return null ; } $ r = $ this -> db [ $ name ] ; return $ r ( ) ; } | Get an object from the resource factory |
1,762 | public static function S2c ( $ theta , $ phi , array & $ c ) { $ cp ; $ cp = cos ( $ phi ) ; $ c [ 0 ] = cos ( $ theta ) * $ cp ; $ c [ 1 ] = sin ( $ theta ) * $ cp ; $ c [ 2 ] = sin ( $ phi ) ; return ; } | - - - - - - - i a u S 2 c - - - - - - - |
1,763 | public function run ( ) { if ( ! is_array ( $ rules = $ this -> getRules ( ) ) ) { $ rules = $ this -> convertToArray ( $ rules ) ; } if ( ! is_array ( $ datas = $ this -> getDatas ( ) ) ) { $ datas = $ this -> convertToArray ( $ datas ) ; } foreach ( $ rules as $ key => $ rule ) { $ parsedRules = explode ( "|" , $ rul... | determine datas is correct or not |
1,764 | private function handleRule ( $ rule , $ key , array $ allDatas ) { $ methodName = "run" ; if ( ! strstr ( $ rule , "_" ) ) { $ methodName .= ucfirst ( $ rule ) ; } else { $ parsedName = array_map ( function ( $ value ) { return ucfirst ( $ value ) ; } , explode ( "_" , $ rule ) ) ; $ methodName = $ methodName . join (... | handle the given rule |
1,765 | private function callMethod ( $ methodName , $ datas ) { if ( method_exists ( $ this , $ methodName ) ) { $ call = [ $ this , $ methodName ] ; } elseif ( isset ( $ this -> extends [ $ methodName ] ) ) { $ call = $ this -> extends [ $ methodName ] ; } else { throw new MethodNotExistsException ( sprintf ( '%s method is n... | calls method or callable function with given datas |
1,766 | protected function runNumeric ( $ key , $ datas , $ rule = '' ) { if ( ! isset ( $ datas [ $ key ] ) ) { if ( ! is_numeric ( $ datas [ $ key ] ) ) { $ this -> fails [ ] = $ messageKey = "numeric.$key" ; $ this -> addMessage ( $ key , $ rule , $ messageKey ) ; } } } | determine data is numeric |
1,767 | protected function runAlpha ( $ key , $ datas , $ rule ) { $ data = $ datas [ $ key ] ; if ( ! preg_match ( "([A-Z])" , $ data ) ) { $ this -> fails [ ] = $ messageKey = "alpha.$key" ; $ this -> addMessage ( $ key , $ rule , $ messageKey ) ; } } | determine the data is a variable alphabetic charecter |
1,768 | protected function runEmail ( $ key , $ datas , $ rule ) { $ email = $ datas [ $ key ] ; if ( filter_var ( $ email , FILTER_VALIDATE_EMAIL ) === false ) { $ this -> fails [ ] = $ messageKey = "email.$key" ; $ this -> addMessage ( $ key , $ rule , $ messageKey ) ; } } | determine email is right |
1,769 | protected function runJson ( $ key , $ datas , $ rule ) { if ( json_decode ( $ datas [ $ key ] ) === false ) { $ this -> fails [ ] = $ messageKey = "json.$key" ; $ this -> addMessage ( $ key , $ rule , $ messageKey ) ; } } | determine if given data is a valid json data |
1,770 | protected function runSizeBetween ( $ array , $ key , $ datas , $ rule ) { $ data = $ datas [ $ key ] ; $ min = $ array [ 0 ] ; $ max = $ array [ 1 ] ; if ( $ data < $ min || $ data > $ max ) { $ this -> fails [ ] = $ messageKey = "$rule.$key" ; $ this -> addMessage ( $ key , $ rule , $ messageKey , [ 'min' => $ min , ... | determine data is correct |
1,771 | protected function runRegex ( $ regex , $ key , $ datas , $ rule ) { if ( ! preg_match ( $ regex , $ datas [ $ key ] ) ) { $ this -> fails [ ] = $ messageKey = "regex.$key" ; $ this -> addMessage ( $ key , $ rule , $ messageKey ) ; } } | determine given regex is matching with given datas |
1,772 | protected function runSame ( $ same , $ key , $ datas , $ rule ) { if ( ! is_array ( $ same ) ) { $ sames = $ this -> convertToArray ( $ same ) ; } $ data = $ datas [ $ key ] ; $ status = true ; foreach ( $ sames as $ same ) { if ( $ same != $ data ) { $ status = false ; break ; } } if ( $ status === false ) { $ this -... | determine datas are same or not |
1,773 | protected function runUrl ( $ key , $ datas , $ rule ) { $ data = $ datas [ $ key ] ; if ( ! filter_var ( $ data , FILTER_SANITIZE_URL ) ) { $ this -> fails [ ] = $ messageKey = "url.$key" ; $ this -> addMessage ( $ key , $ rule , $ messageKey ) ; } } | determine url is valid |
1,774 | protected function runDate ( $ key , $ datas , $ rule ) { if ( false === strtotime ( $ datas [ $ key ] ) ) { $ this -> fails [ ] = $ messageKey = "date.$key" ; $ this -> addMessage ( $ key , $ rule , $ messageKey ) ; } } | determine the date is a valid value |
1,775 | protected function runTableExists ( $ key , $ datas , $ rule ) { $ data = $ datas [ $ key ] ; $ advanced = Database :: table ( $ data ) -> tableExists ( ) ; if ( ! $ advanced -> isSuccess ( ) ) { $ this -> fails [ ] = $ messageKey = "$rule.$key" ; $ this -> addMessage ( $ key , $ rule , $ messageKey ) ; } } | determine is table exists in database . base |
1,776 | protected function runColumnExists ( $ column , $ key , $ datas , $ rule ) { $ advanced = Database :: table ( $ datas [ $ key ] ) -> columnExists ( $ column ) ; if ( ! $ advanced -> isSuccess ( ) ) { $ this -> fails [ ] = $ messageKey = "$rule.$key" ; $ this -> addMessage ( $ key , $ rule , $ messageKey ) ; } } | determine is column exists in database . base |
1,777 | protected function addMessage ( $ key , $ rule , $ specialRule , array $ datas = [ ] ) { $ specialMessages = $ this -> getMessageReposity ( ) ; $ defaultMessages = $ this -> defaultErrorMessages ; if ( count ( $ datas ) === 0 ) { $ datas = [ $ key ] ; } if ( isset ( $ specialMessages [ $ specialRule ] ) ) { $ selectedM... | adds a error message |
1,778 | private function convertToArray ( $ notArray ) { if ( is_object ( $ notArray ) || is_string ( $ notArray ) || is_numeric ( $ notArray ) ) { return ( array ) $ notArray ; } else { throw new Exception ( sprintf ( 'your data could not convert to array' ) ) ; } } | tries convert given variable type to array |
1,779 | public function getMaxOpenFilesLimit ( ) { static $ limit = null ; if ( null === $ limit ) { $ process = new Process ( 'ulimit -n' ) ; $ process -> run ( ) ; if ( $ process -> isSuccessful ( ) ) { $ limit = ( int ) trim ( $ process -> getOutput ( ) ) ; } unset ( $ process ) ; } return $ limit ; } | Get max open files limit . |
1,780 | protected function getComposerCommand ( ) { static $ command = null ; if ( null !== $ command ) { return $ command ; } $ pharFile = $ this -> projectPath . '/composer.phar' ; if ( file_exists ( $ pharFile ) ) { return $ command = '/usr/bin/env php -d allow_url_fopen=On -d detect_unicode=Off "' . $ pharFile . '"' ; } $ ... | Get composer command . |
1,781 | protected function generateOptimizedClassmap ( ) { $ composerCommand = $ this -> getComposerCommand ( ) ; if ( ! $ composerCommand ) { $ this -> logger -> log ( '<error>Could not find composer command</error>' ) ; return false ; } $ process = new Process ( $ composerCommand . ' dump-autoload --optimize' , $ this -> pro... | Generate optimized classmap . |
1,782 | protected function addFile ( $ phar , $ file , $ strip = true ) { $ path = strtr ( str_replace ( $ this -> projectPath , '' , $ file -> getRealPath ( ) ) , '\\' , '/' ) ; $ content = file_get_contents ( $ file ) ; $ this -> logger -> log ( '<comment>Adding file</comment> ' . $ path ) ; switch ( true ) { case ( 'LICENSE... | Add file to phar package . |
1,783 | protected function addBinFile ( $ phar , $ binFile ) { $ relativeBinFile = str_replace ( $ this -> projectPath , '' , $ binFile ) ; $ this -> logger -> log ( '<comment>Adding file</comment> ' . $ relativeBinFile ) ; $ content = file_get_contents ( $ binFile ) ; $ content = preg_replace ( '{^#!/usr/bin/env php\s*}' , ''... | Add bin file . |
1,784 | protected function findFiles ( ) { $ finder = new Finder ( ) ; $ finder -> files ( ) -> ignoreVCS ( true ) -> exclude ( 'Tests' ) -> exclude ( 'tests' ) -> exclude ( 'composer.bak' ) ; if ( ! empty ( $ this -> excludeFiles ) ) { foreach ( $ this -> excludeFiles as $ file ) { $ finder -> notPath ( $ file ) ; } } return ... | Get finder . |
1,785 | public function run ( ) { $ this -> returnCode = static :: RETURN_SUCCESS ; $ this -> lastError = null ; $ this -> builtFile = null ; if ( ! $ this -> backupComposer ( ) ) { $ this -> lastError = 'Could not backup composer directory' ; return $ this -> returnCode = static :: RETURN_ERROR ; } try { if ( $ this -> flag &... | Run compiler . |
1,786 | public function service ( $ name ) { if ( isset ( $ this -> resolved [ $ name ] ) ) { return $ this -> resolved [ $ name ] ; } $ service = $ this -> resolver -> resolve ( $ name ) ; $ serviceArgs = $ this -> resolveFuncArgs ( $ service ) ; return $ this -> resolved [ $ name ] = $ service -> invoke ( $ serviceArgs ) ; } | Returns the built service by name . |
1,787 | public function inject ( $ injectable ) { $ func = new Func ( $ injectable ) ; $ args = $ this -> resolveFuncArgs ( $ func ) ; return $ func -> invoke ( $ args ) ; } | Gathers the parameters for and runs the injectable . |
1,788 | protected function resolveFuncArgs ( Func $ func ) { $ params = $ this -> reader -> read ( $ func ) ; $ args = array ( ) ; foreach ( $ params as $ param ) { $ name = $ param -> name ; $ inst = $ this -> tryService ( $ name ) ; if ( ! $ inst && $ param -> hasDefault ) { $ args [ $ name ] = $ param -> default ; } else if... | Guts of the operation - binds parameters to services . |
1,789 | public function createResponse ( ) { if ( ! $ this -> resource instanceof ResourceInterface ) { return $ this -> response ; } return $ this -> response -> setResource ( $ this -> resource ) -> create ( ) ; } | Create and return the resource data |
1,790 | public static function formatMessage ( $ callable , $ parameterName ) { switch ( true ) { case is_array ( $ callable ) : $ message = sprintf ( '%s::%s()' , get_class ( $ callable [ 0 ] ) , $ callable [ 1 ] ) ; break ; case is_object ( $ callable ) : $ message = get_class ( $ callable ) ; break ; default : $ message = (... | Method to format the exception message |
1,791 | public function setModule ( $ name , $ module , $ parameters = null ) { $ name = strtolower ( $ name ) ; if ( class_exists ( $ module , true ) ) { $ instance = new $ module ( $ parameters ) ; $ this -> registerModule ( $ name , $ instance ) ; } return $ this ; } | Set and register new module . |
1,792 | public function setService ( $ name , $ service , $ parameters = null ) { $ name = strtolower ( $ name ) ; if ( $ service instanceof \ Closure ) { $ this -> registerService ( $ name , $ service ) ; } elseif ( class_exists ( $ service , true ) ) { $ this -> registerService ( $ name , new $ service ( $ parameters ) ) ; }... | Set and register a new services |
1,793 | public function getServiceInstance ( $ service , $ new = false ) { if ( isset ( $ this -> services -> $ service ) ) { if ( $ new === true ) { return clone $ this -> services -> $ service ; } else { return $ this -> services -> $ service ; } } return null ; } | Get a instance of the requested service . |
1,794 | protected function hasOption ( $ name , $ shortcut = null ) { return ( $ shortcut && array_key_exists ( $ shortcut , $ _GET ) ) ? true : array_key_exists ( $ name , $ _GET ) ; } | Check option exists |
1,795 | protected function writeTable ( array $ headers , array $ rows ) { $ columnCount = count ( $ headers ) ; $ rowCount = count ( $ rows ) + 1 ; $ columns = array_fill ( 0 , $ columnCount , 0 ) ; $ tables = [ ] ; foreach ( array_merge ( [ $ headers ] , $ rows ) as $ row ) { $ i = - 1 ; $ newRow = [ ] ; foreach ( $ row as $... | Write simple table |
1,796 | public function getProjectRoot ( string $ tail = '' ) : string { if ( empty ( $ this -> root ) || ! is_dir ( $ this -> root ) ) { throw new \ Exception ( "Invalid root dir or not set yet!" ) ; } return realpath ( $ this -> root ) . $ tail ; } | Get absolute project directory path |
1,797 | public function getCurrentUrl ( ) : string { $ wp = Core :: get ( WP :: class ) ; return $ this -> wpProvider -> homeUrl ( $ this -> wpProvider -> addQueryArg ( [ ] , $ wp -> request ) ) ; } | Get current url with WP global query |
1,798 | public function dispatch ( $ call = null ) { $ command = $ this -> routes -> get ( $ this -> arguments -> getCommand ( 1 ) , false ) ; if ( $ this -> routes -> get ( $ call , false ) ) { $ command = $ this -> routes -> get ( $ call , false ) ; } if ( $ command ) { $ handler = new ClassMethodHandler ( $ command , $ this... | Dispatches the command handler . |
1,799 | public static function getLogger ( Configuration $ configuration ) : LoggerInterface { $ identifier = $ configuration -> getIdentifier ( ) ; if ( isset ( self :: $ _loggers [ $ identifier ] ) ) { return self :: $ _loggers [ $ identifier ] ; } switch ( $ configuration -> getImplementation ( ) ) { case CsvLogger :: class... | Creates a new logger with the help of the given configuration data . This method has no effect if another logger with the same identifier exists yet . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.