idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
6,800 | private function split ( ) { if ( count ( $ parts = explode ( '/' , trim ( $ this -> product . '/' . $ this -> version , '/' ) , 2 ) ) === 2 ) { $ this -> product = $ parts [ 0 ] ; $ this -> version = $ parts [ 1 ] ; } return true ; } | Split Product and Version |
6,801 | private function blacklistCheck ( $ input ) { foreach ( [ 'mozilla' , 'compatible' , '(' , ')' , ] as $ string ) { if ( stripos ( $ input , $ string ) !== false ) { throw new Exceptions \ FormatException ( 'Invalid User-agent format (`' . trim ( $ this -> product . '/' . $ this -> version , '/' ) . '`). Examples of val... | Check for blacklisted strings or characters |
6,802 | public function getUserAgent ( ) { $ product = $ this -> getProduct ( ) ; $ version = $ this -> getVersion ( ) ; return $ version === null ? $ product : $ product . '/' . $ version ; } | Get User - agent |
6,803 | public function getMostSpecific ( array $ userAgents ) { $ array = [ ] ; foreach ( $ userAgents as $ string ) { $ array [ $ string ] = strtolower ( $ this -> strip ( $ string ) ) ; } foreach ( array_map ( 'strtolower' , $ this -> getUserAgents ( ) ) as $ generated ) { if ( ( $ result = array_search ( $ generated , $ ar... | Find the best matching User - agent |
6,804 | private function filterDuplicates ( $ array ) { $ result = [ ] ; foreach ( $ array as $ value ) { if ( ! in_array ( $ value , $ result ) ) { $ result [ ] = $ value ; } } return array_filter ( $ result ) ; } | Filter duplicates from an array |
6,805 | public static function deepReplace ( $ ini , $ search , $ replace ) { if ( is_object ( $ ini ) ) { foreach ( $ ini as $ key => & $ value ) { $ value = self :: deepReplace ( $ value , $ search , $ replace ) ; } } else { $ ini = str_replace ( $ search , $ replace , $ ini ) ; return $ ini ; } return $ ini ; } | Replaces text in every value of the config recursively |
6,806 | public function AllProducts ( $ sort = [ ] ) { if ( count ( $ sort ) == 0 ) { $ sort = array ( "SortOrder" => "ASC" , "Title" => "ASC" ) ; } $ ids = array ( $ this -> ID ) ; $ ids = array_merge ( $ ids , $ this -> getDescendantIDList ( ) ) ; $ products = CatalogueProduct :: get ( ) -> filter ( array ( "Categories.ID" =... | Get a list of all products from this category and it s children categories . |
6,807 | public function AllTags ( ) { $ products = $ this -> AllProducts ( ) ; if ( $ products -> exists ( ) ) { return ProductTag :: get ( ) -> filter ( "Products.ID" , $ products -> column ( "ID" ) ) -> Sort ( 'Sort' , 'ASC' ) ; } } | Get a list of all tags on products within this category |
6,808 | protected function serviceProviderIsRegistered ( $ class_name ) { if ( \ method_exists ( $ this -> app , 'getLoadedProviders' ) ) { $ loaded = \ array_keys ( $ this -> app -> getLoadedProviders ( ) ) ; return \ in_array ( $ class_name , $ loaded , true ) ; } return false ; } | Make check - service provider is loaded or not? |
6,809 | public function fetchAll ( ) { $ query = sprintf ( 'SELECT * FROM `%s`' , $ this -> table ) ; $ rows = array ( ) ; foreach ( $ this -> pdo -> query ( $ query ) as $ index => $ row ) { $ value = & $ row [ ConstProviderInterface :: CONFIG_PARAM_VALUE ] ; if ( $ this -> serializer -> isSerialized ( $ value ) ) { $ value =... | Fetches all configuration data |
6,810 | public function insert ( $ module , $ name , $ value ) { $ query = sprintf ( 'INSERT INTO `%s` (`module`, `name`, `value`) VALUES (:module, :name, :value)' , $ this -> table ) ; if ( $ this -> serializer -> isSerializeable ( $ value ) ) { $ value = $ this -> serializer -> serialize ( $ value ) ; } $ stmt = $ this -> pd... | Inserts a new record |
6,811 | public function deleteAllByModule ( $ module ) { $ query = sprintf ( 'DELETE FROM `%s` WHERE `module` =:module' , $ this -> table ) ; $ stmt = $ this -> pdo -> prepare ( $ query ) ; return $ stmt -> execute ( array ( ':' . ConstProviderInterface :: CONFIG_PARAM_MODULE => $ module ) ) ; } | Deletes all configuration data by associated module |
6,812 | final protected function setData ( $ value ) { $ this -> storage -> set ( $ this -> ns , $ value , TimeHelper :: YEAR ) ; } | Defines data s key |
6,813 | final protected function getData ( ) { if ( $ this -> storage -> has ( $ this -> ns ) ) { return $ this -> storage -> get ( $ this -> ns ) ; } else { return $ this -> default ; } } | Returns data from a storage if present If not returns default value |
6,814 | public function excludeDuplicates ( ) : LocationCollection { if ( $ this -> count ( ) < 2 ) { return $ this ; } $ explodedTerms = array_map ( function ( Location $ location ) : array { return explode ( ' ' , $ location -> getValue ( ) ) ; } , ( array ) $ this ) ; $ explodedTermsCount = count ( $ explodedTerms ) ; $ res... | Removes duplicates of location names if they have same names . |
6,815 | protected function build ( array $ data , $ depth = 0 , $ prevKey = null ) { $ valueOutput = "" ; $ arrayOutput = "" ; if ( $ depth > 2 ) { throw new ExceededMaxDepthException ( "Max INI Depth of 2 Exceeded" ) ; } $ position = 0 ; foreach ( $ data as $ key => $ val ) { if ( $ this -> skipNullValues && $ val === null ) ... | Recursive build function |
6,816 | public function escape ( $ value ) { $ value = ( string ) $ value ; if ( $ this -> enableBool ) { if ( $ value == '' ) { return 'false' ; } elseif ( $ value == '1' ) { return 'true' ; } } if ( $ this -> enableNumeric && is_numeric ( $ value ) ) { return ( string ) $ value ; } if ( $ this -> enableAlphaNumeric && is_str... | Escapes Values According to Currently Set Rules |
6,817 | public static function load ( $ directoryName = 'filters' ) : array { $ files = static :: getFilePattern ( $ directoryName ) ; return collect ( glob ( $ files ) ) -> map ( function ( $ filename ) { return include $ filename ; } ) -> flatten ( 1 ) -> toArray ( ) ; } | Load partials from a directory . |
6,818 | private function getNestedTypeInArray ( PropertyMetadata $ item ) { if ( isset ( $ item -> type [ 'name' ] ) && in_array ( $ item -> type [ 'name' ] , array ( 'array' , 'ArrayCollection' ) ) ) { if ( isset ( $ item -> type [ 'params' ] [ 1 ] [ 'name' ] ) ) { return $ item -> type [ 'params' ] [ 1 ] [ 'name' ] ; } if ( ... | Check the various ways JMS describes values in arrays and get the value type in the array |
6,819 | public function queue ( $ relation , array $ args ) { $ this -> queue [ ] = array ( self :: PARAM_RELATION => $ relation , self :: PARAM_ARGS => $ args ) ; } | Append new relation to the queue stack |
6,820 | public function process ( array $ rows ) { foreach ( $ this -> queue as $ queue ) { $ relation = $ queue [ self :: PARAM_RELATION ] ; $ args = $ queue [ self :: PARAM_ARGS ] ; switch ( $ relation ) { case 'asOneToMany' : $ relation = new OneToMany ( $ this -> db ) ; $ slaveTable = $ args [ 0 ] ; $ slaveColumnId = $ arg... | Processes a raw result - set appending relational data if necessary |
6,821 | private function extractPkName ( $ table ) { if ( is_null ( $ this -> pk ) ) { $ row = $ this -> db -> showKeys ( ) -> from ( $ table ) -> whereEquals ( 'Key_name' , 'PRIMARY' ) -> getStmt ( ) -> fetch ( ) ; $ this -> pk = $ row [ 'Column_name' ] ; } return $ this -> pk ; } | Extracts PK column from a table |
6,822 | protected function build ( ) { $ sql = "SELECT\n\t" . $ this -> columns . "\n" . $ this -> from . "\n" . ( $ this -> join ? $ this -> join : null ) . ( $ this -> where ? $ this -> where . "\n" : null ) . ( $ this -> groupby ? $ this -> groupby . "\n" : null ) . ( $ this -> orderby ? $ this -> orderby . "\n" : null ) . ... | Build SQL . |
6,823 | private function createJoin ( $ table , $ condition , $ type ) { $ this -> join .= $ type . " JOIN " . $ this -> prefix . $ table . "\n\tON " . $ condition . "\n" ; return $ this ; } | Create a inner or outer join . |
6,824 | public static function build ( array $ options = array ( ) , $ sessionBag = null ) { if ( is_null ( $ sessionBag ) ) { $ sessionBag = new StandaloneSessionBag ( ) ; } $ fontsDir = __DIR__ . '/Fonts/' ; $ fontFile = isset ( $ options [ 'font' ] ) ? $ options [ 'font' ] : 'Arimo.ttf' ; if ( ! is_file ( $ fontsDir . $ fon... | Glues everything and builds prepared CAPTCHA s instance |
6,825 | protected function resetSearchChoices ( ) { $ filteredChoices = [ ] ; foreach ( $ this -> choices as $ key => $ choice ) { if ( \ is_array ( $ choice ) ) { $ this -> resetSearchGroupChoices ( $ filteredChoices , $ key , $ choice ) ; } else { $ this -> resetSearchSimpleChoices ( $ filteredChoices , $ key , $ choice ) ; ... | Reset the choices for search . |
6,826 | protected function resetSearchGroupChoices ( array & $ filteredChoices , $ group , array $ choices ) { foreach ( $ choices as $ key => $ choice ) { list ( $ id , $ label ) = $ this -> getIdAndLabel ( $ key , $ choice ) ; if ( false !== stripos ( $ label , $ this -> search ) && ! \ in_array ( $ id , $ this -> getIds ( )... | Reset the search group choices . |
6,827 | protected function resetSearchSimpleChoices ( array & $ filteredChoices , $ key , $ choice ) { list ( $ id , $ label ) = $ this -> getIdAndLabel ( $ key , $ choice ) ; if ( false !== stripos ( $ label , $ this -> search ) && ! \ in_array ( $ id , $ this -> getIds ( ) ) ) { $ filteredChoices [ $ key ] = $ choice ; } } | Reset the search simple choices . |
6,828 | public function configure ( $ timestamp , $ ttl ) { if ( $ this -> isModified ( $ timestamp ) ) { $ this -> appendLastModified ( $ timestamp , $ ttl ) ; } else { $ this -> appendNotModified ( $ ttl ) ; } } | Starts to capture |
6,829 | private function appendLastModified ( $ timestamp , $ maxAge ) { $ headers = array ( 'Cache-Control' => sprintf ( 'public, max-age=%s' , $ maxAge ) , 'Last-Modified' => gmdate ( 'D, j M Y H:i:s' , $ timestamp ) . ' GMT' ) ; $ this -> headerBag -> setStatusCode ( 200 ) -> appendPairs ( $ headers ) ; } | Appends Last - Modified headers |
6,830 | private function isModified ( $ timestamp ) { $ target = 'If-Modified-Since' ; if ( $ this -> headerBag -> hasRequestHeader ( $ target ) ) { $ sinceTimestamp = strtotime ( $ this -> headerBag -> getRequestHeader ( $ target ) ) ; if ( $ sinceTimestamp != false && $ timestamp <= $ sinceTimestamp ) { return false ; } } re... | Checks whether it has been modified since provided timestamp |
6,831 | public function findByArea ( $ area ) { $ qb = $ this -> getQueryBuilder ( ) ; $ qb -> addSelect ( "fb_fa" ) -> addSelect ( "fb_fa_f" ) -> innerJoin ( "fb.filterAddeds" , "fb_fa" ) -> innerJoin ( "fb_fa.filter" , "fb_fa_f" ) -> andWhere ( "fb.area = :area" ) -> setParameter ( "area" , $ area ) ; $ qb -> orderBy ( "fb.o... | Busca los bloques de una area |
6,832 | public static function add ( array $ subjectArray , $ newElementKey , $ newElementValue ) { if ( ! is_null ( self :: get ( $ subjectArray , $ newElementKey ) ) ) { return $ subjectArray ; } self :: set ( $ subjectArray , $ newElementKey , $ newElementValue ) ; return $ subjectArray ; } | Add an element to an array using dot notation if it does NOT exist . |
6,833 | public static function exists ( $ arrayOrArrayAccess , $ keyOrOffset ) { if ( $ arrayOrArrayAccess instanceof ArrayAccess ) { return $ arrayOrArrayAccess -> offsetExists ( $ keyOrOffset ) ; } return array_key_exists ( $ keyOrOffset , $ arrayOrArrayAccess ) ; } | Check if the given key or offset exists in the provided array or array object . |
6,834 | public static function flatten ( array $ subjectArray , $ depth = INF ) { $ flattenArray = [ ] ; foreach ( $ subjectArray as $ value ) { if ( ! is_array ( $ value ) ) { $ flattenArray [ ] = $ value ; } elseif ( $ depth === 1 ) { $ flattenArray = array_merge ( $ flattenArray , array_values ( $ value ) ) ; } else { $ fla... | Flatten a multi - dimensional array into a single level . Keys are not preserved . |
6,835 | public static function flattenIntoDots ( array $ subjectArray , $ keyPrefix = '' ) { $ flattenArray = [ ] ; foreach ( $ subjectArray as $ key => $ value ) { $ newKey = $ keyPrefix . $ key ; if ( is_array ( $ value ) && ! empty ( $ value ) ) { $ flattenArray = array_merge ( $ flattenArray , self :: flattenIntoDots ( $ v... | Flatten a multi - dimensional array into a single level with the keys compressed into dot notation to indicate each depth level . |
6,836 | public static function get ( $ subjectArrayOrObject , $ dotNotationKeys , $ defaultValue = null ) { if ( is_null ( $ dotNotationKeys ) ) { return $ subjectArrayOrObject ; } return self :: walkArrayOrObject ( $ subjectArrayOrObject , $ dotNotationKeys , $ defaultValue ) ; } | Get an data from an array or property from an object using dot notation . |
6,837 | protected static function initEmptyArray ( array & $ subjectArray , $ key ) { if ( ! isset ( $ subjectArray [ $ key ] ) || ! is_array ( $ subjectArray [ $ key ] ) ) { $ subjectArray [ $ key ] = [ ] ; } return $ subjectArray ; } | If the key does not exist at this depth we will just create an empty array to hold the next value allowing us to create the arrays to hold final values at the correct depth . Then we ll keep digging into the array . |
6,838 | protected static function isArrayElementValidArray ( array $ array , $ key , $ validIfNotEmpty = true ) { if ( ! isset ( $ array [ $ key ] ) ) { return false ; } if ( ! is_array ( $ array [ $ key ] ) ) { return false ; } return ( ! $ validIfNotEmpty || ! empty ( $ array [ $ key ] ) ) ; } | Checks if the specified element indicated by the key is a valid array . |
6,839 | protected static function removeSegments ( array & $ array , $ key ) { $ parts = self :: explodeDotNotationKeys ( $ key ) ; while ( count ( $ parts ) > 1 ) { $ part = array_shift ( $ parts ) ; if ( isset ( $ array [ $ part ] ) && is_array ( $ array [ $ part ] ) ) { $ array = & $ array [ $ part ] ; } } unset ( $ array [... | Forget segments within the array |
6,840 | public function fieldLabels ( $ includerelations = true ) { $ labels = parent :: fieldLabels ( $ includerelations ) ; $ commentLabels = array ( 'Title' => _t ( 'Comment.TITLE' , 'Subject' ) , 'Name' => _t ( 'Comment.NAME' , 'Name' ) , 'Email' => _t ( 'Comment.EMAIL' , 'Email' ) , 'URL' => _t ( 'Comment.URL' , 'URL' ) ,... | Setup the fieldlabels and possibly the translations . |
6,841 | public function getFrontEndFields ( $ params = null ) { $ fields = parent :: getFrontEndFields ( $ params ) ; $ fields -> removeByName ( array ( 'MD5Email' , 'AkismetMarked' , 'Visible' , 'ShowGravatar' , 'News' , ) ) ; $ fields -> replaceField ( 'Email' , EmailField :: create ( 'Email' , $ this -> fieldLabel ( 'Email'... | Setup the fields for the frontend |
6,842 | public function onBeforeWrite ( ) { parent :: onBeforeWrite ( ) ; $ siteConfig = SiteConfig :: current_site_config ( ) ; if ( $ siteConfig -> MustApprove ) { $ this -> Visible = false ; } if ( substr ( $ this -> URL , 0 , 4 ) != 'http' && $ this -> URL != '' ) { $ this -> URL = 'http://' . $ this -> URL ; } $ this -> M... | Setup the visibility and check the URI because ppl forget about it . Also check Akismet . |
6,843 | public function getGravatar ( ) { $ siteConfig = SiteConfig :: current_site_config ( ) ; $ default = '' ; $ gravatarSize = '32' ; if ( $ siteConfig -> DefaultGravatarImageID != 0 ) { $ default = urlencode ( Director :: absoluteBaseURL ( ) . $ siteConfig -> DefaultGravatarImage ( ) -> Link ( ) ) ; } elseif ( $ siteConfi... | Setup the Gravatar because handling from the template is messy . |
6,844 | public function onAfterWrite ( ) { $ SiteConfig = SiteConfig :: current_site_config ( ) ; $ mail = Email :: create ( ) ; $ mail -> setTo ( $ SiteConfig -> NewsEmail ) ; $ mail -> setSubject ( _t ( 'Comment.COMMENTMAILSUBJECT2' , 'New post titled: {title} ' , array ( 'title' => $ this -> Title ) ) ) ; $ mail -> setFrom ... | I would actually advice to change a few things here personally . |
6,845 | private function checkAkismet ( SiteConfig $ siteConfig ) { try { $ akismet = new Akismet ( Director :: absoluteBaseURL ( ) , $ siteConfig -> AkismetKey ) ; $ akismet -> setCommentAuthor ( $ this -> Name ) ; $ akismet -> setCommentContent ( $ this -> Comment ) ; $ akismet -> setCommentAuthorEmail ( $ this -> Email ) ; ... | If we have Akismet configured check if this comment should be marked as spam . Or ham . Or bacon . Or steak! Steak would be good! |
6,846 | public function create ( ) { $ filesystem = new Filesystem ( ) ; if ( ! file_exists ( $ this -> configDir ) ) { $ filesystem -> mkdir ( $ this -> configDir , 0777 ) ; $ filesystem -> copy ( __DIR__ . '/../Resources/role_template/ServiceConfiguration.cscfg' , $ this -> configDir . '/ServiceConfiguration.cscfg' ) ; $ fil... | Create required directory structore for this azure deployment if not exists already . |
6,847 | public function createRole ( $ name , $ type = self :: ROLE_WEB , $ override = false ) { $ serviceDefinition = $ this -> getServiceDefinition ( ) ; $ serviceConfig = $ this -> getServiceConfiguration ( ) ; switch ( $ type ) { case self :: ROLE_WEB : $ serviceDefinition -> addWebRole ( $ name ) ; $ serviceConfig -> addR... | Create a new role for this Azure Deployment |
6,848 | public function configure ( array $ config = [ ] ) : void { $ config = array_intersect_key ( $ config , array_flip ( [ 'rpcHost' , 'rpcPort' , 'rpcPassword' , 'rpcBaseRoute' ] ) ) ; foreach ( $ config as $ key => $ value ) { $ this -> { $ key } = $ value ; } } | Applies configuration options . |
6,849 | public function solve ( string $ challengeUrl ) : string { $ result = $ this -> createTask ( $ challengeUrl ) ; if ( $ result [ 'errorId' ] !== 0 ) { $ this -> getLogger ( ) -> error ( "Received AntiCaptcha ErrorId: {ErrorId}: {ErrorDescription}" , [ 'ErrorId' => $ result [ 'errorId' ] , 'ErrorDescription' => $ result ... | Solve a challenge |
6,850 | protected function checkResult ( $ taskId ) { $ this -> getLogger ( ) -> debug ( "Requesting Task Status for task {TaskId}" , [ 'TaskId' => $ taskId ] ) ; $ postData = [ 'clientKey' => $ this -> apiKey , 'taskId' => $ taskId ] ; try { $ response = $ this -> getClient ( ) -> post ( static :: HOST . '/getTaskResult' , [ ... | Check if there is a result |
6,851 | public function accept ( NodeElementVisitorInterface $ visitor ) { $ visitor -> visitNodeFirst ( $ this ) ; foreach ( $ this -> elements as $ element ) { $ element -> accept ( $ visitor ) ; } $ visitor -> visitNode ( $ this ) ; } | Recursion for tree pushed down to visitor so it can deside the traversing algorithm |
6,852 | public static function source ( ) : DocumentSource { $ container = self :: staticContainer ( ) ; if ( empty ( $ container ) ) { throw new ScopeException ( sprintf ( "Unable to get '%s' source, no container scope is available" , static :: class ) ) ; } return $ container -> get ( ODMInterface :: class ) -> source ( stat... | Instance of ODM Selector associated with specific document . |
6,853 | protected function setCurlProxyOptions ( $ adapter ) { $ adapter -> setCurlOption ( CURLOPT_PROXY , $ this -> proxyConfig [ 'proxy_host' ] ) ; if ( ! empty ( $ this -> proxyConfig [ 'proxy_port' ] ) ) { $ adapter -> setCurlOption ( CURLOPT_PROXYPORT , $ this -> proxyConfig [ 'proxy_port' ] ) ; } } | Set proxy options in a Curl adapter . |
6,854 | public function proxify ( \ Zend \ Http \ Client $ client , array $ options = [ ] ) { if ( $ this -> proxyConfig ) { $ host = $ client -> getUri ( ) -> getHost ( ) ; if ( ! $ this -> isLocal ( $ host ) ) { $ proxyType = $ this -> proxyConfig [ 'proxy_type' ] ?? 'default' ; if ( $ proxyType == 'socks5' ) { $ adapter = n... | Proxify an existing client . |
6,855 | public function get ( $ url , array $ params = [ ] , $ timeout = null , array $ headers = [ ] ) { if ( $ params ) { $ query = $ this -> createQueryString ( $ params ) ; if ( strpos ( $ url , '?' ) !== false ) { $ url .= '&' . $ query ; } else { $ url .= '?' . $ query ; } } $ client = $ this -> createClient ( $ url , \ ... | Perform a GET request . |
6,856 | public function post ( $ url , $ body = null , $ type = 'application/octet-stream' , $ timeout = null , array $ headers = [ ] ) { $ client = $ this -> createClient ( $ url , \ Zend \ Http \ Request :: METHOD_POST , $ timeout ) ; $ client -> setRawBody ( $ body ) ; $ client -> setHeaders ( array_merge ( [ 'Content-Type'... | Perform a POST request . |
6,857 | public function postForm ( $ url , array $ params = [ ] , $ timeout = null ) { $ body = $ this -> createQueryString ( $ params ) ; return $ this -> post ( $ url , $ body , \ Zend \ Http \ Client :: ENC_URLENCODED , $ timeout ) ; } | Post form data . |
6,858 | public function createClient ( $ url = null , $ method = \ Zend \ Http \ Request :: METHOD_GET , $ timeout = null ) { $ client = new \ Zend \ Http \ Client ( ) ; $ client -> setMethod ( $ method ) ; if ( ! empty ( $ this -> defaults ) ) { $ client -> setOptions ( $ this -> defaults ) ; } if ( null !== $ this -> default... | Return a new HTTP client . |
6,859 | protected function send ( \ Zend \ Http \ Client $ client ) { try { $ response = $ client -> send ( ) ; } catch ( \ Zend \ Http \ Client \ Exception \ RuntimeException $ e ) { throw new Exception \ RuntimeException ( sprintf ( 'Zend HTTP Client exception: %s' , $ e ) , - 1 , $ e ) ; } return $ response ; } | Send HTTP request and return response . |
6,860 | public static function getArrayType ( string $ type ) : ? string { if ( substr ( $ type , - 2 ) !== '[]' || strlen ( $ type ) === 2 ) { return null ; } return substr ( $ type , 0 , - 2 ) ; } | Gets the type of the array if there is one |
6,861 | public static function resolveType ( $ value ) : string { if ( is_array ( $ value ) ) { if ( count ( $ value ) === 0 ) { return 'array' ; } return self :: resolveType ( $ value [ 0 ] ) . '[]' ; } return is_object ( $ value ) ? get_class ( $ value ) : gettype ( $ value ) ; } | Gets the type of the input value This is useful for getting around PHP s type shortcomings |
6,862 | public function makeRequest ( string $ relativeUrl , array $ variables = [ ] , string $ httpMethod = ClientInterface :: HTTP_GET , bool $ shouldCache = true , string $ contentType = ClientInterface :: CONTENT_TYPE_JSON ) : BookboonResponse { if ( strpos ( $ relativeUrl , '/' ) !== 0 ) { throw new UsageException ( 'Loca... | Prepares the call to the api and if enabled tries cache provider first for GET calls . |
6,863 | private function makeLeafEvaluation ( ) : Evaluation { $ result = new Evaluation ( ) ; $ result -> age = $ this -> depthLeft ; $ result -> score = $ this -> state -> evaluateScore ( $ this -> objectivePlayer ) ; return $ result ; } | Formulate the evaluation this node being a leaf node |
6,864 | private function getChildResult ( GameState $ stateAfterMove ) : TraversalResult { $ nextPlayerIsFriendly = $ stateAfterMove -> getNextPlayer ( ) -> isFriendsWith ( $ this -> objectivePlayer ) ; $ nextDecisionPoint = new static ( $ this -> objectivePlayer , $ stateAfterMove , $ this -> depthLeft - 1 , $ nextPlayerIsFri... | Recursively evaluate a child decision Apply a move and evaluate the outcome |
6,865 | private function isIdealOver ( Evaluation $ a , Evaluation $ b ) : bool { $ ideal = $ this -> type == NodeType :: MIN ( ) ? Evaluation :: getWorstComparator ( ) : Evaluation :: getBestComparator ( ) ; $ idealEvaluationResult = $ ideal ( $ a , $ b ) ; return $ idealEvaluationResult > 0 ; } | Compare two evaluations The meaning of best is decided by the ideal member variable comparator |
6,866 | public function addChainModel ( ChainModel $ chainModel ) { if ( isset ( $ this -> chainModels [ $ chainModel -> getId ( ) ] ) ) { throw new InvalidArgumentException ( sprintf ( "The chain model to '%s' is already added, please add you model to tag '%s'" , $ chainModel -> getClassName ( ) , $ chainModel -> getClassName... | Agrega un modelo de exportacion |
6,867 | protected function getChainModel ( $ id ) { if ( ! isset ( $ this -> chainModels [ $ id ] ) ) { throw new InvalidArgumentException ( sprintf ( "The chain model is not added or the id '%s' is invalid." , $ id ) ) ; } return $ this -> chainModels [ $ id ] ; } | Retorna un modelo de exportacion |
6,868 | public function getOption ( $ name ) { if ( ! isset ( $ this -> options [ $ name ] ) ) { throw new InvalidArgumentException ( sprintf ( "The option name '%s' is invalid, available are %s." , $ name , implode ( "," , array_keys ( $ this -> options ) ) ) ) ; } return $ this -> options [ $ name ] ; } | Retorna una opcion |
6,869 | public function generate ( $ idChain , $ name , array $ options = [ ] ) { $ chainModel = $ this -> resolveChainModel ( $ idChain , $ options ) ; $ modelDocument = $ chainModel -> getModel ( $ name ) ; if ( isset ( $ options [ "fileName" ] ) && ! empty ( $ options [ "fileName" ] ) ) { $ modelDocument -> setFileName ( $ ... | Genera un documento de un modulo |
6,870 | public function generateWithSource ( $ id , $ idChain , $ name , $ output , array $ options = [ ] ) { if ( ! $ this -> adapter ) { throw new RuntimeException ( sprintf ( "The adapter must be set for enable this feature." ) ) ; } $ chainModel = $ this -> getChainModel ( $ idChain ) ; $ className = $ chainModel -> getCla... | Genera un documento a partir de un id |
6,871 | public function resolveChainModel ( $ idChain , array $ options = [ ] ) { $ resolver = new OptionsResolver ( ) ; $ resolver -> setDefaults ( [ "base_path" => null , "sub_path" => null , "data" => [ ] , "fileName" => null , ] ) ; $ resolver -> setAllowedTypes ( "data" , "array" ) ; $ options = $ resolver -> resolve ( $ ... | Resuelve el modelo de exportacion y le establece los parametros |
6,872 | public function getOptions ( ) { $ types = $ this -> types ( ) ; array_walk ( $ types , function ( & $ classname ) { $ classname = $ classname :: getLabel ( ) ; } ) ; return $ types ; } | Get available types options . |
6,873 | public function getClassname ( $ type ) { $ types = $ this -> types ( ) ; if ( isset ( $ types [ $ type ] ) ) { return $ types [ $ type ] ; } return static :: DEFAULT_CLASSNAME ; } | Get classname by type . |
6,874 | protected function getPluginTypes ( $ pattern , $ plugin_path ) { $ types = [ ] ; $ project_root = ProjectX :: projectRoot ( ) ; foreach ( $ this -> getInstalledPluginNamespaces ( ) as $ name => $ namespace ) { $ plugin_dir = "$project_root/vendor/$name" ; if ( ! file_exists ( $ plugin_dir ) ) { continue ; } $ plugin_d... | Get plugin types . |
6,875 | protected function getInstalledPluginNamespaces ( ) { $ cache_item = $ this -> cache -> getItem ( 'plugins.installed' ) ; $ project_root = ProjectX :: projectRoot ( ) ; $ installed_file = "$project_root/vendor/composer/installed.json" ; if ( ! $ cache_item -> isHit ( ) && file_exists ( $ installed_file ) ) { $ installe... | Get composer installed plugin namespaces . |
6,876 | public static function handleCommand ( ) { try { global $ argv ; $ tokens = array_slice ( $ argv , 1 ) ; if ( empty ( $ tokens ) ) { throw new RuntimeException ( "Command name is required !!" ) ; } $ commandName = ( string ) $ tokens [ 0 ] ; $ commandTokens = array_slice ( $ tokens , 1 ) ; $ commandParameters = [ ] ; $... | Handles a command |
6,877 | public static function executeCommand ( $ commandName , array $ commandParameters ) { if ( isset ( self :: $ commands [ $ commandName ] ) ) { $ commandAction = self :: $ commands [ $ commandName ] ; } else { $ commandsBaseNamespace = get_property ( "cli.commands_base_namespace" ) ; if ( ! empty ( $ commandsBaseNamespac... | Execues a command |
6,878 | public static function get_templates_for_class ( $ classname ) { $ classes = ClassInfo :: ancestry ( $ classname ) ; $ classes = array_reverse ( $ classes ) ; $ remove_classes = self :: config ( ) -> classes_to_remove ; $ return = array ( ) ; array_push ( $ classes , "Catalogue" , "Page" ) ; foreach ( $ classes as $ cl... | Get a list of templates for rendering |
6,879 | public static function generate_no_image ( ) { $ no_image = "no-image.png" ; $ image = File :: find ( $ no_image ) ; if ( ! isset ( $ image ) ) { $ reflector = new ReflectionClass ( self :: class ) ; $ curr_file = dirname ( $ reflector -> getFileName ( ) ) ; $ curr_file = str_replace ( "src/helpers" , "client/dist/imag... | Copy the default no product image from this module and then add a new image to the DB . |
6,880 | private function onBeforeSend ( RequestInterface $ request , array & $ options ) { $ base_uri = null ; if ( isset ( $ options [ 'base_uri' ] ) && $ options [ 'base_uri' ] ) { if ( $ options [ 'base_uri' ] instanceof UriInterface ) { $ base_uri = $ options [ 'base_uri' ] ; } } $ cookieJar = $ this -> getCookieJar ( $ op... | Inject the cookie in the request |
6,881 | public function onReceive ( RequestInterface $ request , ResponseInterface $ response ) { $ this -> coockieJar -> extractCookies ( $ request , $ response ) ; return $ response ; } | Update the cookie jar with the cookie received from the server |
6,882 | public function getCookieJar ( array & $ options , $ base_uri = null ) { if ( $ this -> coockieJar -> count ( ) <= 0 || ! $ this -> loginMade ) { $ this -> obtainCookies ( $ options , $ base_uri ) ; } if ( isset ( $ options [ 'auth-cookie' ] ) ) { unset ( $ options [ 'auth-cookie' ] ) ; } return $ this -> coockieJar ; ... | Get cookie jar hydrates one if it is empty |
6,883 | protected function obtainCookies ( array & $ options , $ base_uri = null ) { $ client = new Client ( ) ; $ loginOptions = [ 'debug' => isset ( $ options [ 'debug' ] ) && $ options [ 'debug' ] ? true : false , 'allow_redirects' => false , 'cookies' => $ this -> coockieJar ] ; if ( ! is_null ( $ base_uri ) ) { $ loginOpt... | Hydrates a cookie jar . Do not invoke this function if you don t know what you re doing |
6,884 | public function setCacheable ( $ minutes ) { if ( $ minutes <= 0 ) { $ this -> setHeader ( 'Cache-Control' , 'private, no-cache, no-store, must-revalidate' ) ; $ this -> setHeader ( 'Expires' , '-1' ) ; $ this -> setHeader ( 'Pragma' , 'no-cache' ) ; } else { $ this -> setHeader ( 'Expires' , gmdate ( 'D, d M Y H:i:s' ... | sends header to allow the browser to cache the response a given time |
6,885 | public function parse ( ) { $ parser = $ this -> getParser ( ) ; $ parser -> parse ( $ this ) ; return $ parser -> getTokenCollector ( ) -> build ( $ this -> getRenderer ( ) ) ; } | Parse formula and theses subforumlas |
6,886 | public static function romanize ( $ string ) { foreach ( self :: $ chars as $ regex => $ replacement ) { $ string = preg_replace ( $ regex . 'u' , $ replacement , $ string ) ; } return $ string ; } | Romanizes the string that contains foreign chars |
6,887 | public function addDir ( $ dir ) { if ( ! is_dir ( $ dir ) ) { throw new LogicException ( sprintf ( 'Provided path "%s" is not a directory' , $ dir ) ) ; } array_push ( $ this -> dirs , $ dir ) ; return $ this ; } | Add a base directory |
6,888 | public function connect ( ) { list ( $ host , $ port ) = explode ( ':' , $ this -> getServer ( ) ) ; if ( $ this -> stream -> open ( $ host , $ port , $ this -> getTimeout ( ) ) === false ) { throw new Exception ( sprintf ( 'Cannot connect to server %s' , $ this -> getServer ( ) ) , Exception :: SERVER_OFFLINE ) ; } re... | Connect to the beanstalkd server |
6,889 | public function pauseTube ( $ tube , $ delay ) { $ this -> dispatch ( new Command \ PauseTube ( $ tube , $ delay ) ) ; return true ; } | The pause - tube command can delay any new job being reserved for a given time |
6,890 | public function validateResponse ( $ response ) { if ( $ response === false ) { throw new Exception ( 'Error reading data from the server.' , Exception :: SERVER_READ ) ; } if ( $ response === 'BAD_FORMAT' ) { throw new Exception ( 'The client sent a command line that was not well-formed. ' . 'This can happen if the li... | Generic validation for all responses from beanstalkd |
6,891 | protected function dispatch ( Command $ command ) { if ( $ this -> isTimedOut ( ) === true ) { $ this -> close ( ) ; $ this -> connect ( ) ; } $ message = $ command -> getCommand ( ) . "\r\n" ; if ( ( $ data = $ command -> getData ( ) ) !== false ) { $ message .= $ data . "\r\n" ; } if ( $ this -> stream -> write ( $ m... | Send a command to beanstalkd and return the result |
6,892 | public function newLog ( $ introId , $ user ) { $ introClass = $ this -> config [ 'intro_class' ] ; $ em = $ this -> doctrine -> getManager ( ) ; $ intro = $ em -> getRepository ( $ introClass ) -> find ( $ introId ) ; $ introLog = null ; if ( $ intro ) { $ introLogClass = $ this -> config [ 'intro_log_class' ] ; $ int... | Genera un nuevo log |
6,893 | public static function strModified ( $ target , Closure $ callback ) { $ modified = $ callback ( $ target ) ; return md5 ( $ target ) !== md5 ( $ modified ) ; } | Checks whether string has been modified |
6,894 | public static function serial ( $ id , $ unique = true , $ upper = true , $ length = 25 , $ portion = 5 ) { if ( $ unique === true ) { $ salt = substr ( sha1 ( mt_rand ( ) ) , 0 , 20 ) ; $ id .= $ salt ; } $ hash = md5 ( $ id ) ; for ( $ i = 0 ; $ i < 10 ; $ i ++ ) { $ hash = md5 ( $ hash ) ; } if ( $ upper === true ) ... | Generates serial number like XXXXX - XXXXX - XXXXX - XXXXX the mask can be overridden |
6,895 | public static function normalizeColumn ( $ string ) { $ parts = explode ( '_' , $ string ) ; foreach ( $ parts as & $ part ) { $ part = ucfirst ( $ part ) ; } return join ( ' ' , $ parts ) ; } | Normalizes column name |
6,896 | public static function randomString ( $ length , $ method = 'alnum' ) { $ types = array ( 'alpha' => 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' , 'alnum' => '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' , 'numeric' => '0123456789' ) ; if ( isset ( $ types [ $ method ] ) ) { $ dictionary =... | Creates a random string with fixed length |
6,897 | public static function getNeedlePositions ( $ haystack , $ needle ) { $ start = 0 ; $ result = array ( ) ; $ needleLength = strlen ( $ needle ) ; while ( ( $ pos = strpos ( $ haystack , $ needle , $ start ) ) !== false ) { $ start = $ pos + 1 ; $ startPos = $ pos ; $ endPos = $ pos + $ needleLength ; $ result [ $ start... | Returns needle positions |
6,898 | public static function sluggify ( $ string , $ romanize = true ) { $ generator = new SlugGenerator ( $ romanize ) ; return $ generator -> generate ( $ string ) ; } | Sluggifies a string |
6,899 | public static function studly ( $ input ) { $ input = mb_convert_case ( $ input , \ MB_CASE_TITLE , 'UTF-8' ) ; $ input = str_replace ( array ( '-' , '_' ) , ' ' , $ input ) ; $ input = str_replace ( ' ' , '' , $ input ) ; return $ input ; } | Converts a string to studly case |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.