idx int64 0 241k | question stringlengths 64 6.21k | target stringlengths 5 803 |
|---|---|---|
232,000 | public function setDirectory ( $ directory ) { if ( false === is_string ( $ directory ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ directory ) ) , E_USER_ERROR ) ; } $ this -> directory = new Directory ( $ directory ) ; if ( false =... | Sets the directory to write to |
232,001 | public function setExtension ( $ extension ) { if ( false === is_string ( $ extension ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ extension ) ) , E_USER_ERROR ) ; } $ extension = ( $ extension [ 0 ] === '.' ) ? $ extension : '.' . ... | Set file extension |
232,002 | public function setMode ( $ mode ) { if ( false === is_string ( $ mode ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ mode ) ) , E_USER_ERROR ) ; } $ this -> mode = $ mode ; return $ this ; } | Sets the log rotate mode |
232,003 | public function setSuffix ( $ suffix ) { if ( false === is_string ( $ suffix ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ suffix ) ) , E_USER_ERROR ) ; } $ this -> suffix = $ suffix ; return $ this ; } | Sets the suffix |
232,004 | private function generateFileName ( ) { return $ this -> directory -> entity ( ) -> getPath ( ) . date ( $ this -> getMode ( ) ) . $ this -> getSuffix ( ) . $ this -> getExtension ( ) ; } | Generates a filename with current rotation mode |
232,005 | public static function getDay ( $ day , $ langCode , $ style = self :: STYLE_LONG ) { $ langCode = static :: checkLanguageCode ( $ langCode ) ; return self :: $ i18n [ $ langCode ] [ 'day' ] [ $ style ] [ $ day ] ; } | Get translated day of the week . |
232,006 | public static function getMonth ( $ month , $ langCode , $ style = self :: STYLE_LONG ) { $ langCode = static :: checkLanguageCode ( $ langCode ) ; return self :: $ i18n [ $ langCode ] [ 'month' ] [ $ style ] [ $ month ] ; } | Get translated month . |
232,007 | public function toSQL ( Parameters $ params , bool $ inner_clause ) { $ expr = $ this -> getOperand ( ) ; $ direction = $ this -> getDirection ( ) ; return $ params -> getDriver ( ) -> toSQL ( $ params , $ expr , false ) . " " . $ direction ; } | Write a order direction clause as SQL query syntax |
232,008 | public function log ( ) { $ content = call_user_func_array ( array ( $ this -> ladybug , 'dump' ) , func_get_args ( ) ) ; $ trace = debug_backtrace ( ) ; $ this -> data [ 'vars' ] [ ] = array ( 'file' => isset ( $ trace [ 0 ] [ 'file' ] ) ? $ trace [ 0 ] [ 'file' ] : '' , 'line' => isset ( $ trace [ 0 ] [ 'line' ] ) ? ... | Log an info . |
232,009 | public function load ( ) { static :: $ loaded = true ; $ container = $ this -> getContainer ( ) ; if ( $ container ) { $ config = $ container -> get ( 'config' ) ; $ events = $ config [ 'plugin-manager' ] ; foreach ( $ events as $ event => $ plugins ) { foreach ( $ plugins as $ type => $ plugin ) { $ this -> attach ( $... | load events with their plugins |
232,010 | protected function buildCacheKey ( array $ assets , array $ options ) { $ cachekey = $ this -> Request -> getServerName ( ) ; $ cachekey .= "(asset(" . implode ( '|' , $ assets ) . ")(" . implode ( '|' , $ options ) . "))" ; return $ cachekey ; } | Builds a unique cache key based on the asset array and options |
232,011 | public static function permanentRedirect ( $ url , $ externalRedirect = false ) { $ response = new static ( ) ; $ response -> redirect ( $ url , $ externalRedirect , self :: HTTP_PERMANENT_REDIRECT ) ; return $ response ; } | Convenience function to create a 301 response |
232,012 | public static function temporaryRedirect ( $ url , $ externalRedirect = false ) { $ response = new static ( ) ; $ response -> redirect ( $ url , $ externalRedirect , self :: HTTP_TEMPORARY_REDIRECT ) ; return $ response ; } | Convenience function to create a 302 response |
232,013 | public function expire ( $ name , $ path = '/' , $ domain = null ) { if ( null === $ path ) { $ path = '/' ; } if ( empty ( $ domain ) ) { $ domains = array_keys ( $ this -> cookieJar ) ; } else { $ domains = array ( $ domain ) ; } foreach ( $ domains as $ domain ) { unset ( $ this -> cookieJar [ $ domain ] [ $ path ] ... | Removes a cookie by name . |
232,014 | public function all ( ) { $ this -> flushExpiredCookies ( ) ; $ flattenedCookies = array ( ) ; foreach ( $ this -> cookieJar as $ path ) { foreach ( $ path as $ cookies ) { foreach ( $ cookies as $ cookie ) { $ flattenedCookies [ ] = $ cookie ; } } } return $ flattenedCookies ; } | Returns not yet expired cookies . |
232,015 | public function allValues ( $ uri , $ returnsRawValue = false ) { $ this -> flushExpiredCookies ( ) ; $ parts = array_replace ( array ( 'path' => '/' ) , parse_url ( $ uri ) ) ; $ cookies = array ( ) ; foreach ( $ this -> cookieJar as $ domain => $ pathCookies ) { if ( $ domain ) { $ domain = '.' . ltrim ( $ domain , '... | Returns not yet expired cookie values for the given URI . |
232,016 | public function getActiveAddress ( ) { if ( null === $ this -> getAddresses ( ) ) { return null ; } if ( 1 === count ( $ this -> getAddresses ( ) ) ) { foreach ( $ this -> getAddresses ( ) as $ address ) { return $ address ; } } if ( null === $ this -> response [ 'active_address' ] ) { return null ; } return $ this -> ... | Return the surname . |
232,017 | public function serialize ( ) { $ it = new SerializedTokenIterator ( [ ] ) ; $ this -> preSerialize ( $ it ) ; foreach ( $ this -> tokens as $ token ) { $ token -> serialize ( $ it ) ; } $ this -> postSerialize ( $ it ) ; return json_encode ( $ it -> getArrayCopy ( ) ) ; } | Serializes a token container into an encoded string that consumes a minimal amount of storage memory . |
232,018 | public function unserialize ( $ serialized ) { $ this -> tokens = [ ] ; $ tokenFactory = $ this -> getTokenFactory ( ) ; $ it = new SerializedTokenIterator ( json_decode ( $ serialized , true ) ) ; $ this -> preUnserialize ( $ it ) ; while ( $ it -> valid ( ) ) { $ this -> tokens [ ] = $ tokenFactory -> createToken ( $... | Reads a serialized token container and reconstitus all token objects . |
232,019 | public function offsetGet ( $ offset ) { if ( empty ( $ this -> tokens [ $ offset ] ) ) { throw new \ OutOfBoundsException ( 'No token found at offset ' . $ offset ) ; } return $ this -> tokens [ $ offset ] ; } | Get the token at the given position . |
232,020 | public function clearCache ( ) { $ dbInstace = $ this -> getDbInstance ( ) ; $ sql = ' DELETE FROM `cache`; VACUUM; ' ; $ stmt = $ dbInstace -> prepare ( $ sql ) ; if ( $ stmt -> execute ( ) ) { return ; } else { $ error = $ stmt -> errorInfo ( ) ; $ errorMsg = $ error [ 2 ] ; throw new \ R... | Clears all cache |
232,021 | public function startMeasure ( string $ name ) : void { if ( App :: $ Debug ) { App :: $ Debug -> startMeasure ( $ name ) ; } } | Start timeline measure |
232,022 | public function stopMeasure ( string $ name ) : void { if ( App :: $ Debug ) { App :: $ Debug -> stopMeasure ( $ name ) ; } } | Stop timeline measure |
232,023 | protected function load ( ) { $ data = array ( ) ; foreach ( $ this -> loaders as $ loader ) { try { $ data = array_merge ( $ data , $ loader -> load ( ) ) ; if ( $ loader -> stopPropagation ( ) ) { break ; } } catch ( LoaderException $ e ) { $ this -> getLogger ( ) -> error ( $ e -> getMessage ( ) ) ; } } return $ dat... | Loads and aggregates information from each registered loader . |
232,024 | public static function merge ( ) : array { $ arguments = [ ] ; foreach ( func_get_args ( ) as $ key => $ val ) { if ( ! Any :: isArray ( $ val ) ) { $ val = [ ] ; } $ arguments [ $ key ] = $ val ; } return call_user_func_array ( 'array_merge' , $ arguments ) ; } | Alternative function for array_merge - safe for use with any - type params . |
232,025 | public static function pluck ( ? string $ key = null , ? array $ array = null ) : array { if ( ! Any :: isArray ( $ array ) || ! Any :: isStr ( $ key ) ) { return [ ] ; } $ output = [ ] ; foreach ( $ array as $ item ) { $ object = $ item [ $ key ] ; if ( ! self :: in ( $ object , $ output ) ) { $ output [ ] = $ object ... | Extract from multi - array elements by key to single - level array |
232,026 | public static function exportVar ( $ var , $ indent = null , $ guessTypes = false ) { switch ( gettype ( $ var ) ) { case 'string' : if ( true === $ guessTypes ) { if ( $ var === '0' || $ var === '' ) { return 'false' ; } elseif ( $ var === '1' ) { return 'true' ; } } return '\'' . $ var . '\'' ; case 'array' : $ index... | Alternative var_export function for php > = 5 . 4 syntax |
232,027 | public function getApiRequest ( $ apiUrl , $ deferred ) { return new Request ( [ 'url' => $ apiUrl , 'resolveCallback' => function ( Response $ response ) use ( $ deferred ) { $ data = ( string ) $ response -> getBody ( ) ; $ headers = $ response -> getHeaders ( ) ; $ code = $ response -> getStatusCode ( ) ; $ shortUrl... | Create the API Request |
232,028 | public function fetch ( $ protected_resource_url , $ parameters = array ( ) , $ http_method = self :: HTTP_METHOD_GET , array $ http_headers = array ( ) , $ form_content_type = self :: HTTP_FORM_CONTENT_TYPE_MULTIPART ) { if ( $ this -> access_token ) { switch ( $ this -> access_token_type ) { case self :: ACCESS_TOKEN... | Fetch a protected resource |
232,029 | protected function configureRepository ( Config $ config ) : OptionRepository { $ repositories = [ ] ; foreach ( $ config -> getAll ( ) as $ class => $ optionsArray ) { $ prefix = array_key_exists ( OptionRepository :: PREFIX , $ optionsArray ) ? $ optionsArray [ OptionRepository :: PREFIX ] : '' ; $ options = $ this -... | Configure a single repository from a Config file . |
232,030 | protected function configureOptions ( array $ optionsArray ) : OptionCollection { $ options = new OptionCollection \ ArrayOptionCollection ( ) ; foreach ( $ optionsArray as $ key => $ option ) { if ( $ key === OptionRepository :: PREFIX ) { continue ; } if ( $ option instanceof Option ) { $ options -> add ( $ option ) ... | Build a collection of options from an array of Config values . |
232,031 | protected function isPrefixable ( $ objectOrClassName ) : bool { if ( is_string ( $ objectOrClassName ) ) { return in_array ( Prefixable :: class , class_implements ( $ objectOrClassName ) , true ) ; } if ( is_object ( $ objectOrClassName ) ) { return $ objectOrClassName instanceof Prefixable ; } return false ; } | Check whether a FQCN or an object implements the Prefixable interface . |
232,032 | public static function get ( $ key ) { $ config = json_decode ( file_get_contents ( PATH . '/app/config.json' ) , true ) ; if ( ! array_key_exists ( $ key , $ config ) ) { throw new ConfigItemNotSetException ( $ key ) ; } return $ config [ $ key ] ; } | Get Config item by key . |
232,033 | public function setSources ( array $ sources ) { $ parameters = $ this -> configuration -> getParameters ( ) ; $ parameters [ 'sources' ] = $ sources ; $ this -> configuration -> setParameters ( $ parameters ) ; } | Define the task new sources . |
232,034 | static private function getDriver ( ) { if ( self :: $ _driver != null ) return self :: $ _driver ; $ driver = Utils :: spare ( Config :: get ( 'session.driver' ) , 'default' ) ; switch ( strtolower ( $ driver ) ) { case 'cookie' : self :: $ _driver = new \ Lollipop \ Session \ Cookie ( ) ; break ; case 'default' : def... | Get session driver |
232,035 | public function addGroup ( $ group ) { if ( $ this -> groups === null ) { $ this -> setGroups ( $ this -> groupRepository -> getAllByRevision ( $ this ) ) ; } $ this -> groups [ ] = $ group ; return $ this ; } | Add a group . |
232,036 | public function getGroups ( ) { if ( $ this -> groups === null ) { $ this -> setGroups ( $ this -> groupRepository -> getAllByRevision ( $ this ) ) ; } return $ this -> groups ; } | Get Groups . |
232,037 | public function setQueueItemData ( array $ data ) { if ( isset ( $ data [ 'queue_id' ] ) ) { $ this -> setQueueId ( $ data [ 'queue_id' ] ) ; } if ( isset ( $ data [ 'processed' ] ) ) { $ this -> setProcessed ( $ data [ 'processed' ] ) ; } if ( isset ( $ data [ 'queued_date' ] ) ) { $ this -> setQueuedDate ( $ data [ '... | Set the queue item s data . |
232,038 | public static function create ( $ value , $ units ) { list ( $ distUnit , $ timeUnit ) = static :: explUnits ( $ units ) ; $ dist = Distance :: m ( 0 ) ; $ time = Time :: sec ( 0 ) ; $ dist -> { $ distUnit } = $ value ; $ time -> { $ timeUnit } = 1 ; $ velocity = new Velocity ( $ dist , $ time ) ; $ velocity -> format ... | Creates a new velocity from a value and velocity unit . |
232,039 | public function units ( $ units , $ string = false ) { list ( $ distUnit , $ timeUnit ) = static :: explUnits ( $ units ) ; $ distVal = $ this -> dist -> unit ( $ distUnit ) ; $ timeVal = $ this -> time -> { $ timeUnit } ; $ distVal = number_format ( $ distVal , 99 , '.' , '' ) ; $ timeVal = number_format ( $ timeVal ,... | Gets the value of this instance at the specified units . |
232,040 | public function format ( $ format ) { $ pattern = '/(%(?:\d+\$)?[+-]?(?:[ 0]|\'.{1})?-?\d*(?:\.\d+)?[bcdeEufFgGosxX])([ ]*)(.*)/' ; if ( preg_match_all ( $ pattern , $ format , $ m ) ) { $ sprintf = $ m [ 1 ] [ 0 ] ; $ space = $ m [ 2 ] [ 0 ] ; $ units = $ m [ 3 ] [ 0 ] ; $ velocity = $ this -> units ( $ units ) ; if (... | Formats this instance as a string with the provided format . |
232,041 | public function add ( Velocity $ b ) { $ dist = $ this -> dist -> add ( $ b -> dist ) ; $ velocity = new Velocity ( $ dist , $ this -> time ) ; $ velocity -> format = $ this -> format ; return $ velocity ; } | Adds another velocity to this instance and returns a new instance with the sum . |
232,042 | public function sub ( Velocity $ b ) { $ dist = $ this -> dist -> sub ( $ b -> dist ) ; $ velocity = new Velocity ( $ dist , $ this -> time ) ; $ velocity -> format = $ this -> format ; return $ velocity ; } | Subtracts another velocity from this instance and returns a new instance with the difference . |
232,043 | public function time ( Distance $ dist ) { return Time :: sec ( ( $ dist -> m / $ this -> dist -> m ) * $ this -> time -> sec ) ; } | Calculates the time required to travel the provided distance at the velocity of this instance . |
232,044 | private static function removeTrailingZeros ( $ num ) { if ( strstr ( $ num , '.' ) ) { $ num = rtrim ( $ num , '0' ) ; $ last = substr ( $ num , strlen ( $ num ) - 1 , 1 ) == '.' ; $ num = $ last ? substr ( $ num , 0 , strlen ( $ num ) - 1 ) : $ num ; return $ num ; } else { return $ num ; } } | Removes trailing zeros for a numeric value expressed as a string . |
232,045 | public function set ( string $ key , string $ value ) : ConfigInterface { $ this -> settings [ $ key ] = $ value ; return $ this ; } | Set an ini directive to be used when calling . |
232,046 | public function call ( callable $ callable , ... $ params ) { foreach ( $ this -> settings as $ key => $ value ) { $ this -> ini -> set ( $ key , $ value ) ; } $ result = null ; $ exception = null ; try { $ result = $ callable ( ... $ params ) ; } catch ( \ Throwable $ e ) { $ exception = $ e ; } $ this -> ini -> clean... | Run some code using the previous provided ini settings . |
232,047 | public function withPath ( $ path = __DIR__ ) { $ before = get_declared_classes ( ) ; $ iterator = new \ RecursiveIteratorIterator ( new \ RecursiveDirectoryIterator ( $ path ) ) ; foreach ( $ iterator as $ item ) { if ( ! $ item -> isDir ( ) && substr ( $ item -> getPathname ( ) , - 4 ) == '.php' ) { require_once $ it... | Add commands from path recursively |
232,048 | public function withStyles ( array $ styles ) { foreach ( $ styles as $ name => $ args ) { $ this -> formatter ( ) -> setStyle ( $ name , new OutputFormatterStyle ( ... $ args ) ) ; } return $ this ; } | Change output formatting styles |
232,049 | public function indexAction ( ) { $ instance = $ this -> getCurrentInstance ( ) ; if ( $ instance ) { $ worker = $ this -> getWorker ( ) ; if ( $ worker ) { return $ this -> render ( $ this -> getTemplatePath ( ) . 'index.html.twig' , array ( 'instance' => $ worker -> getInstance ( ) , 'infos' => $ worker -> getInfos (... | Render choose action or dashboard action |
232,050 | public function clientAction ( ) { $ worker = $ this -> getWorker ( ) ; if ( ! $ worker ) { return new RedirectResponse ( $ this -> generateUrl ( 'ringo_php_redmon' ) ) ; } return $ this -> render ( $ this -> getTemplatePath ( ) . 'client.html.twig' , array ( 'instance' => $ worker -> getInstance ( ) , 'clients' => $ w... | Render client list for the current instance |
232,051 | public function configurationAction ( ) { $ worker = $ this -> getWorker ( ) ; if ( ! $ worker ) { return new RedirectResponse ( $ this -> generateUrl ( 'ringo_php_redmon' ) ) ; } return $ this -> render ( $ this -> getTemplatePath ( ) . 'configuration.html.twig' , array ( 'instance' => $ worker -> getInstance ( ) , 'c... | Render configuration list for the current instance |
232,052 | public function selectAction ( $ id ) { $ instance = $ this -> getManager ( ) -> find ( $ id ) ; if ( $ instance ) { $ this -> getRequest ( ) -> getSession ( ) -> set ( 'instance' , $ instance ) ; if ( $ this -> getWorker ( ) ) { $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'success' , 'Instance ' . $ instan... | Select action Change the current instance |
232,053 | public static function dir ( ) { $ JSTORE_DIR = str_replace ( DIRECTORY_SEPARATOR , '/' , __DIR__ ) ; $ JSTORE_DOCS_ROOT = str_replace ( DIRECTORY_SEPARATOR , '/' , isset ( $ _SERVER [ 'DOCUMENT_ROOT' ] ) ? realpath ( $ _SERVER [ 'DOCUMENT_ROOT' ] ) : dirname ( __DIR__ ) ) ; return trim ( str_replace ( $ JSTORE_DOCS_RO... | Used to get the directory where this class file is located |
232,054 | public function ArrayToObj ( $ array , $ root = False ) { $ obj = ! $ root ? new jstoreRootObject ( $ this ) : new jstoreObject ( $ this ) ; foreach ( $ array as $ arraykey => $ arrayval ) { if ( is_array ( $ arrayval ) ) { $ obj -> $ arraykey = $ this -> ArrayToObj ( $ arrayval ) ; } else { $ obj -> $ arraykey = $ arr... | Same as JsonToObj except it takes in an array rather than a JSON For both methods this is where the work actually happens |
232,055 | public function getHeadSHA1 ( ) { $ headFile = "{$this->dir}/HEAD" ; if ( ! is_readable ( $ headFile ) ) { return false ; } $ head = file_get_contents ( $ headFile ) ; if ( preg_match ( "/ref: (.*)/" , $ head , $ m ) ) { $ head = rtrim ( $ m [ 1 ] ) ; } else { $ head = rtrim ( $ head ) ; } if ( self :: isSHA1 ( $ head ... | Return the SHA1 for the current HEAD of the Git repository . |
232,056 | public function getList ( ) { $ data = [ ] ; foreach ( $ this -> providers as $ provider ) { $ data = array_merge_recursive ( $ data , $ provider -> getImages ( ) ) ; } return $ data ; } | Returns list of images to merge |
232,057 | public function compile ( ) { $ prefix = $ this -> getNewPrefix ( ) ; $ data = $ this -> getList ( ) ; $ sizes = [ ] ; foreach ( $ this -> providers as $ provider ) { if ( $ provider instanceof SizeProviderInterface ) { $ sizes = array_merge ( $ sizes , $ provider -> getSizes ( ) ) ; } } $ num = 0 ; $ scss = [ ] ; fore... | Compiles all sprites |
232,058 | protected function getNewPrefix ( ) { $ find = new Finder ( ) ; $ fs = new Filesystem ( ) ; $ fs -> remove ( $ find -> in ( $ this -> imgDir ) -> directories ( ) , $ this -> stylePath ) ; $ prefix = substr ( sha1 ( microtime ( true ) . 'sprites' ) , 1 , 10 ) ; $ fs -> mkdir ( $ this -> imgDir . '/' . $ prefix ) ; retur... | Creates new prefix for sprites |
232,059 | protected function insertIntoTree ( & $ node , $ existingNode = null ) { $ treeOriginTagDef = $ node -> getNodeRef ( ) -> getElement ( ) -> getSchema ( ) -> getTreeOriginTagDef ( ) ; if ( empty ( $ treeOriginTagDef ) ) throw new NodeException ( 'Cannot insert a node in tree order mode without a tree origin tag definiti... | This only supports inserting nodes at the end of the tree or at the end of a list of children to a parent which inherently means the 2nd criteria to the tree beyond parent is creation date |
232,060 | public function buildCache ( ) { if ( ! empty ( $ this -> viewDirectories ) || ! empty ( $ this -> configDirectories ) || ! empty ( $ this -> resourceDirectories ) ) { return ; } foreach ( $ this -> orderReference as $ namespace ) { $ bundle = & $ this -> bundleReference [ $ namespace ] ; $ this -> viewDirectories [ ] ... | Build directory cache so we only do it once |
232,061 | protected function sprintf ( string $ format , ... $ args ) { return $ this -> output -> write ( sprintf ( $ format , ... $ args ) , false ) ; } | Identical to write function but provides ability to format message . Does not add new line . |
232,062 | function Save ( ) { $ this -> contentRights -> Save ( ) ; if ( ! $ this -> rights ) { $ this -> rights = new BackendContainerRights ( ) ; } $ this -> rights -> SetEdit ( $ this -> Value ( 'Edit' ) ) ; $ this -> rights -> SetRemove ( $ this -> Value ( 'Remove' ) ) ; $ this -> rights -> SetContentRights ( $ this -> conte... | Saves the container rights |
232,063 | public function unregister ( $ k ) { if ( array_key_exists ( $ k , $ this -> _items ) ) { $ item = $ this -> _items [ $ k ] ; unset ( $ this -> _items [ $ k ] ) ; return $ item ; } else return FALSE ; } | Delete an item from cache |
232,064 | public function get ( $ k ) { if ( array_key_exists ( $ k , $ this -> _items ) ) return $ this -> _items [ $ k ] ; else return FALSE ; } | Fetch an item from cache |
232,065 | protected function counter2 ( ) { if ( $ this -> nodb ) { return ; } $ this -> query ( "select count(*) from information_schema.tables " . "where (table_schema = '$this->masterdb') " . "and (table_name = 'counter2')" ) ; list ( $ ok ) = $ this -> fetchrow ( 'num' ) ; if ( $ ok ) { if ( $ this -> isBot ) { $ sql = "inse... | counter2 count files accessed per day WARNING this may be overriden is a child class |
232,066 | public function makeUp ( $ file ) { if ( Any :: isArray ( $ file ) ) { $ success = true ; foreach ( $ file as $ single ) { $ exec = $ this -> makeUp ( $ single ) ; if ( ! $ exec ) { $ success = false ; } } return $ success ; } if ( ! File :: exist ( $ this -> dir . '/' . $ file ) ) { return false ; } if ( Normalize :: ... | Run migration up |
232,067 | public function makeDown ( $ file ) { if ( Any :: isArray ( $ file ) ) { $ success = true ; foreach ( $ file as $ item ) { $ exec = $ this -> makeDown ( $ file ) ; if ( ! $ exec ) { $ success = false ; } return $ success ; } } if ( ! File :: exist ( $ this -> dir . '/' . $ file ) ) { return false ; } File :: inc ( $ th... | Make migration down |
232,068 | public function onKernelRequest ( GetResponseEvent $ event ) { $ headers = $ event -> getRequest ( ) -> headers ; if ( ! $ headers -> has ( self :: HEADER_NAME ) ) { return ; } $ this -> requestId -> set ( $ headers -> get ( self :: HEADER_NAME , null , true ) , true ) ; } | If present reads the request ID from the appropriate header and sets it on a RequestId instance . |
232,069 | public function onKernelResponse ( FilterResponseEvent $ event ) { $ event -> getResponse ( ) -> headers -> set ( self :: HEADER_NAME , $ this -> requestId -> get ( ) ) ; } | If enabled sets the request ID on the appropriate response header . |
232,070 | public function current ( ) { $ sKey = key ( $ this -> values ) ; return ( true === isset ( $ this -> values [ $ sKey ] ) ) ? $ this -> values [ $ sKey ] : null ; } | returns current value |
232,071 | public function scNext ( ) { $ mValue = $ this -> next ( ) ; return ( false === $ mValue and false === $ this -> valid ( ) ) ? self :: NOT_SET_FLAG : $ mValue ; } | Like next but return Not_Set_Flag if there are no next value instead of false |
232,072 | public function scPrev ( ) { $ mValue = $ this -> prev ( ) ; return ( false === $ mValue and false === $ this -> valid ( ) ) ? self :: NOT_SET_FLAG : $ mValue ; } | rewind the pointer for one position |
232,073 | public function valid ( ) { $ bIsValid = false ; if ( null !== $ this -> values ) { $ sKey = $ this -> key ( ) ; $ bIsValid = isset ( $ sKey ) ; } return $ bIsValid ; } | check if the the current value is set |
232,074 | public function get ( $ mOffset , $ mDefault = null ) { return ( true === isset ( $ this -> values [ $ mOffset ] ) ) ? $ this -> values [ $ mOffset ] : $ mDefault ; } | Return the value with the given offset if is not set return the default |
232,075 | public function offsetSet ( $ mOffset , $ mValue ) { if ( false === is_string ( $ mOffset ) and false === is_integer ( $ mOffset ) ) { throw new \ InvalidArgumentException ( 'Invalid offset given: ' . gettype ( $ mOffset ) ) ; } $ this -> values [ $ mOffset ] = $ mValue ; return $ this ; } | set the value by the given offset |
232,076 | public function seek ( $ iOffset ) { $ this -> rewind ( ) ; $ iPosition = 0 ; while ( $ iPosition < $ iOffset and true === $ this -> valid ( ) ) { $ this -> next ( ) ; $ iPosition ++ ; } if ( false === $ this -> valid ( ) ) { throw new \ OutOfBoundsException ( 'Invalid seek position: ' . $ iOffset ) ; } return $ this -... | seek the pointer to the offset position |
232,077 | public function seekToKey ( $ mKey , $ bStrictMode = true ) { $ this -> rewind ( ) ; if ( $ bStrictMode === true ) { while ( true === $ this -> valid ( ) and $ mKey !== $ this -> key ( ) ) { $ this -> next ( ) ; } } else { while ( true === $ this -> valid ( ) and $ mKey != $ this -> key ( ) ) { $ this -> next ( ) ; } }... | Try to seek to given offset |
232,078 | public function filter ( \ Closure $ cClosure ) { $ sClassName = get_class ( $ this ) ; $ aFilteredValues = array ( ) ; foreach ( $ this -> values as $ sKey => $ mValue ) { if ( true === $ cClosure ( $ mValue , $ sKey ) ) { $ aFilteredValues [ $ sKey ] = $ mValue ; } } return new $ sClassName ( $ aFilteredValues ) ; } | Filters the current values and return a new collection |
232,079 | public function forAll ( \ Closure $ cClosure ) { foreach ( $ this -> values as $ mKey => $ mValue ) { $ this -> offsetSet ( $ mKey , $ cClosure ( $ mValue , $ mKey ) ) ; } return $ this ; } | Use a function on all values of the collection and set the result as new values for the key |
232,080 | public function sliceByKey ( $ mStartKey , $ bStrict = true , $ iLength = PHP_INT_MAX ) { $ aSlice = array ( ) ; try { $ this -> seekToKey ( $ mStartKey , $ bStrict ) ; if ( $ iLength > 0 ) { $ aSlice [ $ this -> key ( ) ] = $ this -> current ( ) ; $ iLength -- ; $ this -> next ( ) ; } while ( $ iLength > 0 and true ==... | Slice elements and create a new instance |
232,081 | public static function XmlToType ( \ SimpleXMLElement $ xmlElement ) { $ type = null ; $ value = null ; if ( false !== ( $ type = XmlAttributeHelper :: GetAttributeValue ( $ xmlElement , 'type' ) ) ) { $ type = ( string ) $ type ; } else if ( isset ( $ xmlElement -> type ) ) { $ type = ( string ) $ xmlElement -> type ;... | Extracts typed data from defined XML element . |
232,082 | public static function WriteTypedXmlValue ( \ XMLWriter $ w , $ value , string $ name , bool $ short = true , bool $ separateElements = false ) { if ( ! ( $ value instanceof Type ) ) { $ value = new Type ( $ value ) ; } $ v = null ; $ t = null ; switch ( $ value -> getType ( ) ) { case Type :: PHP_ARRAY : $ v = \ seria... | Writes all data of the defined Value to the XmlWriter . |
232,083 | public static function IsNativeType ( $ value ) : bool { return ( \ is_bool ( $ value ) || \ is_int ( $ value ) || \ is_string ( $ value ) || \ is_double ( $ value ) || \ is_float ( $ value ) || \ is_array ( $ value ) ) ; } | Returns if the type of defined value is a native PHP type . |
232,084 | public static function GetTypeName ( $ value ) : string { if ( \ is_null ( $ value ) ) { return Type :: PHP_NULL ; } if ( \ is_object ( $ value ) ) { return \ get_class ( $ value ) ; } if ( \ is_string ( $ value ) ) { return Type :: PHP_STRING ; } if ( \ is_int ( $ value ) ) { return Type :: PHP_INTEGER ; } if ( \ is_b... | Returns the type name of the defined value . |
232,085 | protected function clearCachedAccessToken ( ) { $ storage = $ this -> service -> getStorage ( ) ; $ storage -> clearToken ( $ this -> getServiceName ( ) ) ; return $ this ; } | clear Cached Access token |
232,086 | public function getMetadataByResourceName ( $ resourceName ) { $ this -> getAllMetadata ( ) ; if ( ! isset ( $ this -> resourceClassMap [ $ resourceName ] ) ) { throw Exception :: resourceNotFound ( $ resourceName ) ; } return $ this -> loadedMetadata [ $ this -> resourceClassMap [ $ resourceName ] ] ; } | Returns ResourceMetadata for the specified resource . |
232,087 | public function getAllMetadata ( ) { $ resourceClasses = $ this -> driver -> getAllClassNames ( ) ; foreach ( $ resourceClasses as $ class ) { $ this -> getMetadataFor ( $ class ) ; } return $ this -> loadedMetadata ; } | Returns the entire collection of ResourceMetadata objects for all mapped resources . Entities not marked as resources are not included . |
232,088 | protected function loadMetadata ( $ className ) { $ resource = new ResourceMetadata ( $ className ) ; $ this -> driver -> loadMetadataForClass ( $ className , $ resource ) ; $ this -> loadedMetadata [ $ className ] = $ resource ; $ this -> resourceClassMap [ $ resource -> getName ( ) ] = $ className ; } | Loads the ResourceMetadata for the specified class . |
232,089 | public function getMalusToFightNumber ( Tables $ tables , $ shieldRestriction ) : int { return $ this -> getRestrictionWithShield ( $ tables , $ shieldRestriction ) + $ tables -> getMissingWeaponSkillTable ( ) -> getFightNumberMalusForSkillRank ( 0 ) ; } | Only for using shield as a weapon! |
232,090 | public function pluck ( $ key , $ unique = false ) { $ results = [ ] ; foreach ( $ this as $ item ) { $ value = is_object ( $ item ) ? $ item -> $ key : $ item [ $ key ] ; if ( $ unique ) { $ results [ $ value ] = $ value ; } else { $ results [ ] = $ value ; } } $ collection = new static ( $ results ) ; return $ collec... | get a collection of values from property |
232,091 | public function getByPropertyValues ( $ property , $ values , $ strict = false ) { $ results = [ ] ; foreach ( $ this as $ item ) { foreach ( $ values as $ value ) { if ( $ strict ) { if ( $ item -> $ property === $ value ) { $ results [ ] = $ item ; } } else { if ( $ item -> $ property == $ value ) { $ results [ ] = $... | get the models which match the property values loose matching not strict |
232,092 | public function getKeyedByProperty ( $ property ) { $ results = [ ] ; foreach ( $ this as $ item ) { $ results [ $ item -> $ property ] = $ item ; } return new static ( $ results ) ; } | key the iterator by the specified property |
232,093 | public function sort ( callable $ callback = null ) { $ items = $ this -> getArrayCopy ( ) ; $ callback ? uasort ( $ items , $ callback ) : asort ( $ items ) ; return new static ( $ items ) ; } | how to reset array keys here? as when jsonencoded the keys must be reset not sure you would always want to reset as may need to maintain sometimes? |
232,094 | public function offsetAppend ( $ index , $ value ) { $ items = [ ] ; if ( $ this -> offsetExists ( $ index ) ) { $ items = $ this -> offsetGet ( $ index ) ; if ( ! is_array ( $ items ) ) { $ itemsType = gettype ( $ items ) ; throw new \ Exception ( "Offset '$index' is '$itemsType' and must be array to append." ) ; } } ... | adds a value to an offset array if there is an array |
232,095 | public function getRoleDescription ( ) { static $ list = null ; if ( $ list === null ) { $ list = static :: getRoles ( ) ; } return ( isset ( $ list [ $ this -> role ] ) ) ? $ list [ $ this -> role ] : $ this -> role ; } | Role sting representation |
232,096 | public function getStatusDescription ( ) { static $ list = null ; if ( $ list === null ) { $ list = static :: getStatuses ( ) ; } return ( isset ( $ list [ $ this -> status ] ) ) ? $ list [ $ this -> status ] : $ this -> status ; } | Status sting representation |
232,097 | public static function findByEmail ( $ email , $ checkStatus = true ) { return static :: findOne ( $ checkStatus ? [ 'email' => $ email , 'status' => self :: STATUS_ACTIVE ] : [ 'email' => $ email ] ) ; } | Finds user by email |
232,098 | public static function findByUsernameOrEmail ( $ username , $ checkStatus = true ) { $ query = static :: find ( ) ; $ query -> where ( [ 'or' , [ 'username' => $ username ] , [ 'email' => $ username ] ] ) ; if ( $ checkStatus ) { $ query -> andWhere ( [ 'status' => self :: STATUS_ACTIVE ] ) ; } return $ query -> limit ... | Finds user by username or email |
232,099 | public static function updateLastVisit ( $ event ) { if ( $ event -> isValid ) { $ user = $ event -> identity ; $ user -> last_visit_at = time ( ) ; $ user -> updateAttributes ( [ 'last_visit_at' ] ) ; return true ; } return false ; } | Update last visit time event handler |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.