idx int64 0 241k | question stringlengths 64 6.21k | target stringlengths 5 803 |
|---|---|---|
233,000 | public function getHash ( ) { $ names = array_keys ( $ this -> initializers ) ; sort ( $ names ) ; return md5 ( implode ( '|' , $ names ) ) ; } | Get an MD5 hash computed from the sorted type names of all initializers . |
233,001 | public function getLastModified ( ) { $ mtime = 0 ; foreach ( $ this -> initializers as $ initializer ) { $ mtime = max ( $ mtime , filemtime ( ( new \ ReflectionClass ( get_class ( $ initializer ) ) ) -> getFileName ( ) ) ) ; } return $ mtime ; } | Get the time of the most recent modification to an initializer . |
233,002 | public function registerInitializer ( ContainerInitializerInterface $ initializer ) { $ key = get_class ( $ initializer ) ; if ( empty ( $ this -> initializers [ $ key ] ) ) { $ this -> initializers [ $ key ] = $ initializer ; } return $ this ; } | Register a container initializer if it has not been registered yet . |
233,003 | public static function fetchQuantifier ( $ min = null , $ max = INF , bool $ lazyLoad = false ) : string { $ lazy = $ lazyLoad ? '?' : '' ; switch ( true ) { case ( $ min === 0 && $ max === 1 ) : return '?' . $ lazy ; case ( $ min === 0 && $ max === INF ) : return '*' . $ lazy ; case ( $ min === 1 && $ max === INF ) : ... | Build quantifier from parameters |
233,004 | protected function displayInformations ( ) { $ this -> climate ( ) -> underline ( ) -> out ( 'Initializing translations parser script...' ) ; $ this -> climate ( ) -> green ( ) -> out ( 'CSV file output: <white>' . $ this -> filePath ( ) . '</white>' ) ; $ this -> climate ( ) -> green ( ) -> out ( 'CSV file names: <whi... | Give feedback about what s going on . |
233,005 | protected function filePath ( ) { if ( $ this -> filePath ) { return $ this -> filePath ; } $ base = $ this -> appConfig -> get ( 'base_path' ) ; $ output = $ this -> output ( ) ; $ this -> filePath = str_replace ( '/' , DIRECTORY_SEPARATOR , $ base . $ output ) ; return $ this -> filePath ; } | Complete filepath to the CSV location . |
233,006 | public function regEx ( $ type ) { switch ( $ type ) { case 'php' : $ f = $ this -> phpFunction ( ) ; $ regex = '/->' . $ f . '\(\s*\n*\r*(["\'])(?<text>(.|\n|\r|\n\r)*?)\s*\n*\r*\1\)/i' ; break ; case 'mustache' : $ tag = $ this -> mustacheTag ( ) ; $ regex = '/({{|\[\[)\s*#\s*' . $ tag . '\s*(}}|\]\])(?<text>(.|\n|\r... | Regex to match in files . |
233,007 | public function getCachedFile ( $ cacheKey ) { list ( $ directory , $ filename ) = $ this -> getDirectoryAndFilenameFromKey ( $ cacheKey ) ; if ( file_exists ( $ directory . "/" . $ filename ) && ! is_dir ( $ directory . "/" . $ filename ) ) { return file_get_contents ( $ directory . "/" . $ filename ) ; } return null ... | Get a cached file using the cache key - either a string or an array of keys |
233,008 | public function cacheFile ( $ cacheKey , $ fileContents ) { list ( $ directory , $ filename ) = $ this -> getDirectoryAndFilenameFromKey ( $ cacheKey ) ; if ( ! file_exists ( $ directory ) ) mkdir ( $ directory , 0777 , true ) ; file_put_contents ( $ directory . "/" . $ filename , $ fileContents ) ; } | Cache a file using the file contents - overwrite if necessary . |
233,009 | private function getDirectoryAndFilenameFromKey ( $ cacheKey ) { if ( ! is_array ( $ cacheKey ) ) { $ cacheKey = array ( $ cacheKey ) ; } $ filename = array_pop ( $ cacheKey ) ; $ dir = $ this -> cacheBaseDir . "/" . join ( "/" , $ cacheKey ) ; return array ( $ dir , $ filename ) ; } | Get the filename and directory from a key |
233,010 | public function getOrdinal ( ) { $ ordinal = array_search ( $ this -> value , array_values ( static :: toArray ( ) ) ) ; return $ ordinal !== false ? $ ordinal : - 1 ; } | Returns the ordinal . |
233,011 | private function http_digest_parse ( $ txt ) { $ noetige_teile = array ( 'nonce' => 1 , 'nc' => 1 , 'cnonce' => 1 , 'qop' => 1 , 'username' => 1 , 'uri' => 1 , 'response' => 1 ) ; $ daten = array ( ) ; $ schluessel = implode ( '|' , array_keys ( $ noetige_teile ) ) ; preg_match_all ( '@(' . $ schluessel . ')=(?:([\'"])... | Funktion zum analysieren der HTTP - Auth - Header |
233,012 | public static function create ( string $ identifier , string $ type ) : QueueItemInterface { $ queueItem = new self ( ) ; $ queueItem -> setIdentifier ( $ identifier ) -> setType ( $ type ) ; return $ queueItem ; } | The create method creates a valid queue item object . |
233,013 | public static function getRandomWeightedElement ( array $ weightedValues , $ default = 1 ) { $ sum = ( int ) array_sum ( $ weightedValues ) ; $ min = 1 ; $ rand = mt_rand ( min ( $ min , $ sum ) , max ( $ min , $ sum ) ) ; $ ret = $ default ; foreach ( $ weightedValues as $ key => $ value ) { $ rand -= ( int ) $ value ... | Get random weighted element . |
233,014 | public static function toString ( $ value ) { if ( is_null ( $ value ) ) { $ ret = 'null' ; } elseif ( is_bool ( $ value ) ) { $ ret = $ value ? 'true' : 'false' ; } elseif ( is_array ( $ value ) ) { $ ret = '[' . implode ( ',' , $ value ) . ']' ; } else if ( ( ! is_object ( $ value ) && settype ( $ value , 'string' ) ... | Cast anything to string . |
233,015 | public static function contains ( $ haystack , $ needle , $ ignoreCase = false ) { if ( $ ignoreCase ) { $ needle = strtolower ( $ needle ) ; $ haystack = strtolower ( $ haystack ) ; } $ pos = strpos ( $ haystack , $ needle ) ; return ! ( $ pos === false ) ; } | Return true if haystack contains needle . |
233,016 | public function setData ( array $ data ) : self { $ this -> data = \ array_merge ( $ this -> data , $ data ) ; return $ this ; } | Set all data to entity . |
233,017 | public function setOutputStyle ( $ style ) { $ possibleStyles = array ( self :: STYLE_NESTED , self :: STYLE_EXPANDED , self :: STYLE_COMPACT , self :: STYLE_COMPRESSED ) ; if ( ! in_array ( $ style , $ possibleStyles ) ) { throw new \ Exception ( 'Invalid output style specified.' ) ; } $ this -> style = $ style ; retu... | Sets the output style between the various output styles supported by SASS . |
233,018 | protected function setDefaults ( ) { $ this -> importPaths = array ( ) ; $ this -> pluginPaths = array ( ) ; $ this -> sourceMap = self :: DEFAULT_SOURCEMAP ; $ this -> mapComment = self :: DEFAULT_MAPCOMMENT ; $ this -> lineNumbers = self :: DEFAULT_LINENUMBERS ; $ this -> precision = self :: DEFAULT_PRECISION ; $ thi... | Sets the object s properties back to their defaults . |
233,019 | public function findByEncryptedId ( $ id , $ field = 'id' ) { $ hashids = $ this -> getServiceLocator ( ) -> get ( 'neobazaar.service.hashid' ) ; $ id = $ hashids -> decrypt ( $ id ) ; $ id = is_array ( $ id ) ? reset ( $ id ) : $ id ; $ options = array ( ) ; $ qb = $ this -> _em -> createQueryBuilder ( ) ; $ qb -> sel... | Get an entity using the encrypted ID |
233,020 | public function getEncryptedId ( $ id ) { $ hashids = $ this -> getServiceLocator ( ) -> get ( 'neobazaar.service.hashid' ) ; $ hash = $ hashids -> encrypt ( $ id ) ; return $ hash ; } | Return the encrypted id using hash id service |
233,021 | public static function removeUrlSegment ( $ url , $ segment , $ replacement = '/' ) { $ preparedSegment = trim ( $ segment , '/' ) ; if ( empty ( $ preparedSegment ) ) { return $ url ; } preg_match ( '/^([^?]+?)(\?.+?)?$/' , $ url , $ matches ) ; return preg_replace ( '/(?:\/|^)' . $ preparedSegment . '(?:\/|$)/i' , $ ... | Try to remove URL segment |
233,022 | public function findMedias ( array $ types = [ ] ) { if ( null === $ this -> folder ) { throw new \ RuntimeException ( 'No folder selected.' ) ; } $ criteria = [ 'folder' => $ this -> folder ] ; if ( count ( $ types ) ) { $ criteria [ 'type' ] = $ types ; } $ medias = $ this -> repository -> findBy ( $ criteria ) ; for... | Returns the media found in the current folder . |
233,023 | public function tokenizeUrl ( $ url ) { if ( ! is_file ( $ url ) ) { throw new \ RuntimeException ( sprintf ( 'URL does not point to a valid file: "%s"' , $ url ) ) ; } $ source = @ file_get_contents ( $ url ) ; if ( $ source === false ) { throw new \ RuntimeException ( sprintf ( 'Unable to tokenize contents loaded fro... | Tokenize the resource at the given url and return the resulting token sequence . |
233,024 | protected function readLiteral ( $ input , $ delim = '"' , $ escaper = NULL ) { $ literal = '' ; $ escaped = false ; $ terminated = false ; for ( $ size = strlen ( $ input ) , $ i = 1 ; $ i < $ size ; $ i ++ ) { if ( $ input [ $ i ] == $ escaper ) { if ( $ escaped ) { $ literal .= $ escaper ; $ escaped = false ; contin... | Reads a literal from the input delimited by the given delimiter . |
233,025 | public function addGroup ( GroupInterface $ group ) : self { if ( ! $ group instanceof Production ) { throw new Exception ( 'Group type not supported.' ) ; } $ this -> groups [ ] = $ group ; return $ this ; } | Add group . |
233,026 | public function addInvitation ( Invitation $ invitation ) : self { $ invitation -> setEvent ( $ this ) ; $ this -> invitations [ ] = $ invitation ; return $ this ; } | Add invitation . |
233,027 | public static function getConnection ( $ filter = '' ) { switch ( $ filter ) { case 'host' : return self :: $ _host ; break ; case 'port' : return self :: $ _port ; break ; case 'dbname' : return self :: $ _dbname ; break ; case 'user' : return self :: $ _user ; break ; default : return self :: $ _pdo ; break ; } } | Get specific connection parameters . Unfortunately the password is used during the connection phase and is not stored therefore not returnable . |
233,028 | public function table ( $ t ) { if ( is_array ( $ t ) ) { $ tArray = $ t ; $ t = $ t_alias = array_shift ( array_keys ( $ tArray ) ) ; $ driver = get_called_class ( ) ; if ( ( $ tArray [ $ t_alias ] instanceof $ driver ) === true ) { $ this -> _placeholders = array_merge ( $ this -> _placeholders , $ tArray [ $ t_alias... | Set a table or subquery to execute the query on . |
233,029 | public function select ( $ t , $ c = array ( ) ) { if ( ! is_array ( $ c ) ) { $ c = array ( $ c ) ; } if ( is_array ( $ t ) ) { $ c = $ t ; } elseif ( is_string ( $ t ) ) { $ this -> table ( $ t ) ; } $ columns = [ ] ; foreach ( $ c as $ i => $ s ) { $ column = [ ] ; if ( ! is_array ( $ s ) ) { $ column = \ Dorsataio ... | Start a new SELECT query . |
233,030 | public function insert ( $ t , $ nvp = array ( ) ) { $ nvps = $ nvp ; if ( is_array ( $ t ) ) { $ nvps = $ t ; } elseif ( is_string ( $ t ) ) { $ this -> table ( $ t ) ; } if ( ! isset ( $ nvps [ 0 ] ) ) { $ nvps = array ( $ nvps ) ; } $ columns = [ ] ; foreach ( $ nvps as $ i => $ nvp ) { $ columns [ $ i ] = [ ] ; for... | Start a new INSERT query . |
233,031 | public function update ( $ t , $ nvp = array ( ) ) { if ( is_array ( $ t ) ) { $ nvp = $ t ; } elseif ( is_string ( $ t ) ) { $ this -> table ( $ t ) ; } $ columns = [ ] ; foreach ( array_keys ( $ nvp ) as $ s ) { $ column = \ Dorsataio \ Squibble \ Resource \ Extract :: fromColumn ( $ s ) ; $ column [ 'value' ] = $ nv... | Start a new UPDATE query . |
233,032 | public function delete ( $ t , $ conditions = array ( ) ) { if ( is_array ( $ t ) ) { $ conditions = $ t ; } elseif ( is_string ( $ t ) ) { $ this -> table ( $ t ) ; } if ( ! empty ( $ conditions ) ) { $ this -> where ( $ conditions ) ; } $ this -> _sql = $ this -> getDeleteStatement ( ) ; return $ this ; } | Start a new DELETE query . |
233,033 | public function get ( $ path , $ default = null ) { return Arr :: get ( $ this -> items , $ this -> keyFor ( $ path ) , $ default ) ; } | Get an item from the collection by path . |
233,034 | private function inRange ( $ ip , $ cidr , $ range ) { $ ipVersion = $ this -> getIpVersion ( $ ip ) ; $ binIp = $ this -> ip2bin ( $ ip ) ; $ parts = explode ( '/' , $ range ) ; $ net = array_shift ( $ parts ) ; $ range_cidr = array_shift ( $ parts ) ; $ netVersion = $ this -> getIpVersion ( $ net ) ; if ( $ ipVersion... | Checks whether the IP is in subnet range |
233,035 | private function ip2bin ( $ ip ) { if ( $ this -> getIpVersion ( $ ip ) === 4 ) { return str_pad ( base_convert ( ip2long ( $ ip ) , 10 , 2 ) , static :: IPV4_ADDRESS_LENGTH , '0' , STR_PAD_LEFT ) ; } else { $ unpack = unpack ( 'A16' , inet_pton ( $ ip ) ) ; $ binStr = array_shift ( $ unpack ) ; $ bytes = static :: IPV... | Converts IP address to bits representation |
233,036 | public function dump ( ) { $ dump = [ ] ; if ( $ this -> hasClasses ( ) ) { foreach ( $ this -> classes as $ class ) { $ dump [ $ class -> getName ( ) ] = $ class -> dump ( ) ; } } return $ dump ; } | Dump group classes . |
233,037 | public function extract ( ) { return [ 'name' => $ this -> getName ( ) , 'ordering' => $ this -> getOrdering ( ) , 'type' => $ this -> getType ( ) , 'include_pattern' => $ this -> getIncludePattern ( ) , 'exclude_pattern' => $ this -> getExcludePattern ( ) , 'classes' => $ this -> dump ( ) , ] ; } | Extract all group s data in array . |
233,038 | public static function isValid ( $ expression , $ translate = false ) { if ( $ translate ) { $ expression = self :: translate ( $ expression ) ; } return is_bool ( $ expression ) ; } | Check if expression is valid |
233,039 | public function parse ( ) { $ this -> lexer -> moveNext ( ) ; while ( true ) { if ( ! $ this -> lexer -> lookahead ) { break ; } $ this -> lexer -> moveNext ( ) ; $ thisLine = null ; switch ( $ this -> lexer -> token [ 'type' ] ) { case Lexer :: T_OPEN_PARENTHESIS : case Lexer :: T_OPEN_BRACKET : case Lexer :: T_OPEN_C... | parses our stuff |
233,040 | public static function string ( $ string , $ foreground_colour = null , $ background_colour = null ) { $ coloured_string = "" ; if ( isset ( self :: $ foreground_colours [ $ foreground_colour ] ) ) { $ coloured_string .= self :: getForegroundCode ( $ foreground_colour ) ; } if ( isset ( self :: $ background_colours [ $... | Adds colouring control codes to a string . |
233,041 | public static function getForegroundCode ( $ foregroundColour ) { if ( ! isset ( self :: $ foreground_colours [ $ foregroundColour ] ) ) { throw new \ Exception ( 'Invalid foreground colour.' ) ; } return "\033[" . self :: $ foreground_colours [ $ foregroundColour ] . 'm' ; } | Returns the code for a foreground colour . |
233,042 | public static function getBackgroundCode ( $ backgroundColour ) { if ( ! isset ( self :: $ background_colours [ $ backgroundColour ] ) ) { throw new \ Exception ( 'Invalid background colour.' ) ; } return "\033[" . self :: $ background_colours [ $ backgroundColour ] . 'm' ; } | Returns the code for a background colour . |
233,043 | public function withPredefinedRowValues ( FieldBuilderBase $ field , array $ rowValues ) : TableCellValueFieldDefiner { $ this -> fieldBuilder -> attr ( TableType :: ATTR_PREDEFINED_ROWS , array_values ( $ rowValues ) ) ; return $ this -> withRowKeyAs ( $ field ) ; } | Defines the rows as predefined set of values . |
233,044 | public function withRowKeyAsField ( IField $ field ) : TableCellValueFieldDefiner { return new TableCellValueFieldDefiner ( $ this -> fieldBuilder , $ this -> cellClassName , $ this -> columnField , $ field ) ; } | Defines the row key as the supplied field . |
233,045 | private function log ( $ line , $ log_level ) { if ( $ log_level <= $ this -> log_verbosity ) { $ line = $ this -> prepend ( $ log_level ) . $ line . "\n" ; $ this -> writeLine ( $ line ) ; } } | Write the log entry |
233,046 | private function prepend ( $ log_level ) { $ time = date ( 'Y-m-d G:i:s' ) ; switch ( $ log_level ) { case self :: FATAL : return $ time . ' - FATAL - ' ; break ; case self :: ERROR : return $ time . ' - ERROR - ' ; break ; case self :: WARN : return $ time . ' - WARN - ' ; break ; case self :: INFO : return $ time . ... | format the line prefix |
233,047 | public function all ( $ dotify = false ) { return $ dotify ? $ this -> dotify ( $ this -> data ) : $ this -> data ; } | Returns all the stored configurations . |
233,048 | public function get ( $ key , $ default = null , $ dotify = false ) { $ items = $ this -> data ; $ keys = array_filter ( explode ( '.' , $ key ) ) ; $ length = count ( $ keys ) ; for ( $ i = 0 ; $ i < $ length ; $ i ++ ) { $ index = $ keys [ ( int ) $ i ] ; $ items = & $ items [ $ index ] ; } if ( $ items === null ) { ... | Returns the value from the specified key . |
233,049 | public function load ( $ path ) { list ( $ data , $ items ) = array ( array ( ) , array ( $ path ) ) ; if ( substr ( ( string ) $ path , - 4 ) !== '.php' ) { $ directory = new \ RecursiveDirectoryIterator ( $ path ) ; $ iterator = new \ RecursiveIteratorIterator ( $ directory ) ; $ regex = new \ RegexIterator ( $ itera... | Loads an array of values from a specified file or directory . |
233,050 | protected function dotify ( array $ data , $ result = array ( ) , $ key = '' ) { foreach ( ( array ) $ data as $ name => $ value ) { if ( is_array ( $ value ) && empty ( $ value ) === false ) { $ text = ( string ) $ key . $ name . '.' ; $ item = $ this -> dotify ( $ value , $ result , $ text ) ; $ result = array_merge ... | Converts the data into dot notation values . |
233,051 | protected function rename ( $ item , $ path ) { $ name = str_replace ( $ path , '' , ( string ) $ item ) ; $ name = str_replace ( array ( '\\' , '/' ) , '.' , $ name ) ; $ regex = preg_replace ( '/^./i' , '' , $ name ) ; return basename ( strtolower ( $ regex ) , '.php' ) ; } | Renames the item into a dot notation one . |
233,052 | protected function save ( array & $ keys , & $ data , $ value ) { $ key = array_shift ( $ keys ) ; if ( ! isset ( $ data [ $ key ] ) ) { $ data [ $ key ] = array ( ) ; } if ( empty ( $ keys ) ) { return $ data [ $ key ] = $ value ; } return $ this -> save ( $ keys , $ data [ $ key ] , $ value ) ; } | Saves the specified key in the list of data . |
233,053 | protected function InitForm ( ) { $ this -> logout = $ this -> LoadElement ( ) ; $ this -> AddNextUrlField ( ) ; $ this -> AddCssIDField ( ) ; $ this -> AddCssClassField ( ) ; $ this -> AddTemplateField ( ) ; $ this -> AddSubmit ( ) ; } | Intializes the form |
233,054 | protected function SaveElement ( ) { $ this -> logout -> SetNextUrl ( $ this -> selectorNext -> Save ( $ this -> logout -> GetNextUrl ( ) ) ) ; return $ this -> logout ; } | Saves the element and returns it |
233,055 | public function generate ( $ target , $ type = 'post' ) { $ form = new \ Pegase \ Extension \ Form \ Objects \ Form ( $ target , $ this -> sm -> get ( 'pegase.security.token_csrf_container' ) , $ type ) ; return $ form ; } | generate a form |
233,056 | public static function fromNative ( ) { $ args = func_get_args ( ) ; if ( \ count ( $ args ) < 2 ) { throw new \ BadMethodCallException ( 'You must provide from 2 to 4 arguments: 1) street name, 2) street number, 3) elements, 4) format (optional)' ) ; } $ nameString = $ args [ 0 ] ; $ numberString = $ args [ 1 ] ; $ el... | Returns a new Street from native PHP string name and number . |
233,057 | public function sameValueAs ( ValueObjectInterface $ street ) { if ( false === Util :: classEquals ( $ this , $ street ) ) { return false ; } return $ this -> getName ( ) -> sameValueAs ( $ street -> getName ( ) ) && $ this -> getNumber ( ) -> sameValueAs ( $ street -> getNumber ( ) ) && $ this -> getElements ( ) -> sa... | Tells whether two Street objects are equal |
233,058 | protected function validate ( ApiServiceInterface $ service ) { $ validator = Validation :: createValidatorBuilder ( ) -> enableAnnotationMapping ( ) -> getValidator ( ) ; $ violations = $ validator -> validate ( $ service ) ; foreach ( $ violations as $ violation ) { $ errorMessage = $ violation -> getMessage ( ) ; if... | Validate a service data using Symfony validation component |
233,059 | public static function factory ( $ time = null , $ timezone = null ) { $ timezone = static :: timezone ( $ timezone ) ; if ( $ time instanceof DateTime ) { return $ time -> setTimezone ( $ timezone ) ; } if ( is_numeric ( $ time ) ) { $ time = '@' . $ time ; } $ dt = new DateTime ( $ time ) ; $ dt -> setTimezone ( $ ti... | Return a DateTime object based on the current time and timezone . |
233,060 | public static function isWithinNext ( $ time , $ span ) { $ span = static :: factory ( $ span ) ; $ time = static :: factory ( $ time ) ; $ now = static :: factory ( ) ; return ( $ time <= $ span && $ time >= $ now ) ; } | Returns true if the date passed will be within the next time frame span . |
233,061 | public static function toUnix ( $ time ) { if ( ! $ time ) { return time ( ) ; } else if ( $ time instanceof DateTime ) { return $ time -> format ( 'U' ) ; } return is_string ( $ time ) ? strtotime ( $ time ) : ( int ) $ time ; } | Return a unix timestamp . If the time is a string convert it else cast to int . |
233,062 | public static function wasLastWeek ( $ time ) { $ start = static :: factory ( 'last week 00:00:00' ) ; $ end = clone $ start ; $ end -> modify ( 'next week -1 second' ) ; $ time = static :: factory ( $ time ) ; return ( $ time >= $ start && $ time <= $ end ) ; } | Returns true if date passed was within last week . |
233,063 | public static function wasLastMonth ( $ time ) { $ start = static :: factory ( 'first day of last month 00:00:00' ) ; $ end = clone $ start ; $ end -> modify ( 'next month -1 second' ) ; $ time = static :: factory ( $ time ) ; return ( $ time >= $ start && $ time <= $ end ) ; } | Returns true if date passed was within last month . |
233,064 | public static function wasLastYear ( $ time ) { $ start = static :: factory ( 'last year January 1st 00:00:00' ) ; $ end = clone $ start ; $ end -> modify ( 'next year -1 second' ) ; $ time = static :: factory ( $ time ) ; return ( $ time >= $ start && $ time <= $ end ) ; } | Returns true if date passed was within last year . |
233,065 | public static function wasWithinLast ( $ time , $ span ) { $ span = static :: factory ( $ span ) ; $ time = static :: factory ( $ time ) ; $ now = static :: factory ( ) ; return ( $ time >= $ span && $ time <= $ now ) ; } | Returns true if the date passed was within the last time frame span . |
233,066 | public function delete ( PersistentCollectionInterface $ coll ) { $ mapping = $ coll -> getMapping ( ) ; if ( $ mapping -> isInverseSide ) { return ; } if ( $ mapping -> strategy === PropertyMetadata :: STORAGE_STRATEGY_ATOMIC_SET ) { throw new \ UnexpectedValueException ( sprintf ( '%s delete collection strategy shoul... | Deletes a PersistentCollection instance completely from a document using REMOVE . |
233,067 | public function getQueryPathAndParent ( PersistentCollectionInterface $ coll , QueryBuilder $ qb = null ) { $ collMapping = $ coll -> getMapping ( ) ; $ parent = $ coll -> getOwner ( ) ; $ paths [ ] = [ $ collMapping -> name , null ] ; while ( ( $ association = $ this -> uow -> getParentAssociation ( $ parent ) ) !== n... | Create and return a QueryBuilder and Path instance representing the provided collection s document path along with the top - level document . |
233,068 | public function randomStr ( $ length = 16 ) { $ arr = array_merge ( range ( 0 , 9 ) , range ( 'a' , 'z' ) , range ( 'A' , 'Z' ) ) ; $ str = '' ; $ arr_len = count ( $ arr ) ; for ( $ i = 0 ; $ i < $ length ; $ i ++ ) { $ rand = mt_rand ( 0 , $ arr_len - 1 ) ; $ str .= $ arr [ $ rand ] ; } return $ str ; } | generate a random string include uppercase and lowercase letters and numbers |
233,069 | public function get ( string $ id ) : DatabaseConfiguration { if ( isset ( $ this -> configurations [ $ id ] ) ) { return $ this -> configurations [ $ id ] ; } throw new \ OutOfBoundsException ( 'No database configuration known for database requested with id ' . $ id ) ; } | returns database configuration for given id |
233,070 | public function getTables ( ) { $ statement = $ this -> connection -> prepare ( "SELECT * FROM information_schema.tables WHERE table_catalog = :database AND table_schema = 'public'" ) ; $ statement -> execute ( [ ':database' => $ this -> Databaser -> database ] ) ; return $ statement -> fetchAll ( \ PDO :: FETCH_ASSOC ... | Get all tables for a database |
233,071 | public function getTableRows ( string $ tableName ) { $ statement = $ this -> connection -> prepare ( "SELECT * FROM information_schema.columns WHERE table_catalog = :database AND table_name = :table" ) ; $ statement -> execute ( [ ':database' => $ this -> Databaser -> database , ':table' => $ tableName ] ) ; return $ ... | Get all rows for all tables |
233,072 | public static function wrap ( $ callable ) { $ parts = explode ( '::' , static :: represent ( $ callable ) ) ; if ( count ( $ parts ) == 1 ) { $ reflector = new \ ReflectionFunction ( $ callable ) ; } else { if ( ! is_array ( $ callable ) ) { $ callable = array ( $ callable , $ parts [ 1 ] ) ; } $ reflector = new \ Ref... | Wraps an existing callable piece of code . |
233,073 | public static function initialize ( ) { static $ initialized = false ; static $ structures = array ( ) ; if ( defined ( 'T_CALLABLE' ) ) { return ; } if ( ! $ initialized ) { spl_autoload_register ( function ( $ class ) { $ parts = array_map ( 'strrev' , explode ( '\\' , strrev ( $ class ) , 2 ) ) ; $ short = array_shi... | Initialize the wrapper . |
233,074 | public function subscribe ( $ handler , $ priority = Event :: DEFAULT_CALLBACKS_PRIORITY ) { $ _priority = \ is_int ( $ priority ) ? $ priority : self :: DEFAULT_CALLBACKS_PRIORITY ; if ( ! ( $ _priority >= self :: DEFAULT_CALLBACKS_MAX_PRIORITY && $ _priority <= self :: DEFAULT_CALLBACKS_MIN_PRIORITY ) ) { $ _priority... | Subscribe to this event . |
233,075 | public function setPostFields ( $ value ) { if ( is_array ( $ value ) ) { return $ this -> setOption ( CURLOPT_POSTFIELDS , http_build_query ( $ value ) ) ; } else { return $ this -> setOption ( CURLOPT_POSTFIELDS , $ value ) ; } } | Set post fields |
233,076 | public function doesFileExist ( $ url ) { $ ch = curl_init ( $ url ) ; curl_setopt ( $ ch , CURLOPT_NOBODY , true ) ; curl_exec ( $ ch ) ; $ httpCode = curl_getinfo ( $ ch , CURLINFO_HTTP_CODE ) ; curl_close ( $ ch ) ; return $ httpCode == 200 ; } | Checks if a file exists |
233,077 | public function getStatus ( string $ url ) { $ resource = curl_init ( $ url ) ; curl_setopt ( $ resource , CURLOPT_NOBODY , true ) ; curl_setopt ( $ resource , CURLOPT_CONNECTTIMEOUT , 10 ) ; curl_setopt ( $ resource , CURLOPT_HEADER , true ) ; curl_setopt ( $ resource , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( ... | Get the response code of a url |
233,078 | public function run ( ) { $ resource = curl_init ( ) ; foreach ( $ this -> settings as $ option => $ setting ) { curl_setopt ( $ resource , $ option , $ setting ) ; } $ headers = [ ] ; foreach ( $ this -> headers as $ key => $ value ) { if ( ! empty ( $ value ) ) { $ headers [ ] = implode ( ' : ' , [ $ key , $ value ] ... | Actually executes the cURL request |
233,079 | public static function init ( $ config = null ) { $ defaults = [ 'driver' => 'mysql' , 'host' => 'localhost' , 'database' => 'mysql' , 'username' => 'root' , 'password' => null , 'log_queries' => true , 'charset' => 'utf8' , 'collation' => 'utf8_unicode_ci' , 'prefix' => null ] ; $ capsule = new Capsule ; if ( is_strin... | Initialize the connection to the database . |
233,080 | public static function parseDsn ( $ string = null ) { $ opts = null ; if ( ! empty ( $ string ) ) { $ dsn = new DSN ( $ string ) ; $ port = empty ( $ dsn -> getFirstPort ( ) ) ? '' : ( ':' . $ dsn -> getFirstPort ( ) ) ; $ password = empty ( $ dsn -> getPassword ( ) ) ? null : $ dsn -> getPassword ( ) ; $ opts = [ 'dri... | Take a string DSN and parse it into an array of its pieces |
233,081 | public function commit ( ) { if ( empty ( $ this -> NodeCounts ) ) { $ this -> Logger -> debug ( __FUNCTION__ . '-> No nodes to change counts on.' ) ; return ; } foreach ( $ this -> NodeCounts as $ nodeRefUrl => $ count ) { $ nodeRef = $ this -> NodeRefService -> parseFromString ( $ nodeRefUrl ) ; if ( $ count != 0 ) {... | Update all meta on nodes queued |
233,082 | public function increment ( NodeRef $ nodeRef , NodeRef $ extNodeRef , $ tag ) { $ nodeRefUrl = $ nodeRef -> getRefURL ( ) ; if ( ! isset ( $ this -> NodeCounts [ $ nodeRefUrl ] ) ) $ this -> NodeCounts [ $ nodeRefUrl ] = 0 ; $ this -> NodeCounts [ $ nodeRefUrl ] ++ ; $ this -> Logger -> debug ( __FUNCTION__ . "-> Incr... | Queue a node to have its meta incremented |
233,083 | protected function getWebpackAssets ( ) { $ assets = public_path ( 'builds/manifest.json' ) ; $ assets = file_get_contents ( $ assets ) ; $ assets = json_decode ( $ assets , true ) ; return $ assets ; } | Get the manifest of assets compiled by Webpack . |
233,084 | protected function makeMenu ( $ menu ) { $ links = [ ] ; foreach ( $ menu as $ key => $ item ) { if ( is_string ( $ item ) ) { $ item = [ $ key , $ item ] ; } list ( $ endpoint , $ label ) = $ item ; $ attributes = array_get ( $ item , 4 , [ ] ) ; $ parameters = array_get ( $ item , 2 , [ ] ) ; $ link = $ this -> route... | Make a menu from a list of links . |
233,085 | protected function isOnPage ( $ page , $ loose = true ) { $ page = $ loose ? $ page : '^' . $ page . '$' ; $ page = str_replace ( '#' , '\#' , $ page ) ; return ( bool ) preg_match ( '#' . $ page . '#' , $ this -> request -> path ( ) ) ; } | Check if a string matches the given url . |
233,086 | protected function translate ( $ string ) { $ translated = $ this -> app [ 'translator' ] -> get ( $ string ) ; return is_string ( $ translated ) ? $ translated : $ string ; } | Act on a string to translate it . |
233,087 | public function check ( $ obj ) { foreach ( $ this -> findFilterComponents as $ findFilterComponent ) { if ( $ findFilterComponent -> check ( $ obj ) ) { return true ; } } return false ; } | Pass a entity through a filter . Does it match? |
233,088 | public function cmdGetCache ( ) { $ id = $ this -> getParam ( 0 ) ; if ( empty ( $ id ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid command' ) ) ; } $ result = $ this -> cache -> get ( $ id ) ; if ( ! isset ( $ result ) ) { $ this -> errorAndExit ( $ this -> text ( 'Unexpected result' ) ) ; } $ this -> outpu... | Callback for cache - get command |
233,089 | public function cmdClearCache ( ) { $ id = $ this -> getParam ( 0 ) ; $ all = $ this -> getParam ( 'all' ) ; if ( ! isset ( $ id ) && empty ( $ all ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid command' ) ) ; } $ result = false ; if ( isset ( $ id ) ) { $ pattern = $ this -> getParam ( 'pattern' ) ; if ( iss... | Callback for cache - clear command |
233,090 | private function setRequestOptions ( $ url , $ vars , $ options = array ( ) ) { curl_setopt ( $ this -> request , CURLOPT_URL , $ url ) ; if ( ! empty ( $ vars ) ) { curl_setopt ( $ this -> request , CURLOPT_POSTFIELDS , $ vars ) ; } curl_setopt ( $ this -> request , CURLOPT_HEADER , true ) ; curl_setopt ( $ this -> re... | Sets the CURLOPT options for the current request |
233,091 | private function setRequestHeaders ( $ headers = array ( ) ) { foreach ( $ this -> headers as $ key => $ value ) { $ headers [ ] = $ key . ': ' . $ value ; } curl_setopt ( $ this -> request , CURLOPT_HTTPHEADER , $ headers ) ; } | Formats and adds custom headers to the current request |
233,092 | public function addRoutes ( array $ routes = [ ] ) { foreach ( $ routes as $ route ) { if ( $ route instanceof RouteInterface ) $ this -> routes [ ] = $ route ; } } | Add all routes which are available |
233,093 | public function dispatch ( Request $ request ) { if ( ltrim ( $ _SERVER [ 'REQUEST_URI' ] , '/' ) === '' ) { return new DispatcherResult ( 200 , $ this -> defaultHandler ) ; } $ dispatcher = $ this -> getDispatcher ( ) ; $ match = $ dispatcher -> dispatch ( $ request -> getMethod ( ) , $ _SERVER [ 'REQUEST_URI' ] ) ; $... | Once called the router should examine the current request by request method and url and find a matching route . If no route was find dispatch a http error instead . |
233,094 | static public function flatten ( array $ array , $ prefix = '' , $ keepEmptyArrayNode = TRUE , $ segmentationCharacter = self :: SEGMENTATION_CHARACTER ) { $ flatArray = array ( ) ; foreach ( $ array as $ key => $ value ) { $ key = rtrim ( $ key , $ segmentationCharacter ) ; if ( ! is_array ( $ value ) || ( count ( $ v... | Converts a multidimensional array to a flat representation . |
233,095 | public function getAttributeValue ( $ key ) { $ value = $ this -> getAttributeFromArray ( $ key ) ; if ( isset ( $ this -> enums [ $ key ] ) && is_scalar ( $ value ) ) { $ enumClass = $ this -> enums [ $ key ] ; return new $ enumClass ( $ value ) ; } return parent :: getAttributeValue ( $ key ) ; } | Gets the value of attribute taking enums typecast into consideration |
233,096 | public function setAttribute ( $ key , $ value ) { if ( isset ( $ this -> enums [ $ key ] ) && is_scalar ( $ value ) ) { $ enumClass = $ this -> enums [ $ key ] ; $ this -> attributes [ $ key ] = new $ enumClass ( $ value ) ; } else { parent :: setAttribute ( $ key , $ value ) ; } return $ this ; } | Sets the value of attribute taking enums typecast into consideration |
233,097 | protected static function getEnumValidationRule ( string $ enumClass ) : array { if ( ! is_a ( $ enumClass , Enum :: class , true ) ) { throw new \ UnexpectedValueException ( 'Class is not enum' ) ; } return array_merge ( [ 'in' ] , $ enumClass :: getConstants ( ) ) ; } | Gets validation rule for given enum class |
233,098 | public function get ( string $ name = null ) : DatabaseConnection { if ( null == $ name ) { $ name = DatabaseConfiguration :: DEFAULT_ID ; } if ( isset ( $ this -> connections [ $ name ] ) ) { return $ this -> connections [ $ name ] ; } $ this -> connections [ $ name ] = new PdoDatabaseConnection ( $ this -> configurat... | returns the connection |
233,099 | protected function init ( ) { if ( $ this -> policy != self :: POLICY_NONE ) { foreach ( $ this -> _role as $ role ) { $ this -> role [ $ role ] = [ 'id' => $ role , 'role' => $ role ] ; $ this -> permission -> addRole ( $ role ) ; } foreach ( $ this -> _resource as $ resource ) { $ this -> resource [ $ resource ] = [ ... | Init data . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.