idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
58,500 | public static function validate ( $ argument , $ types = [ ] , $ throwException = true ) { $ valid = false ; foreach ( $ types as $ type ) { if ( strcasecmp ( gettype ( $ argument ) , $ type ) == 0 ) { $ valid = true ; break ; } } if ( ! $ valid && $ throwException ) { throw new \ InvalidArgumentException ( implode ( "... | Validates argument . |
58,501 | public static function prioritize ( $ args = [ ] ) { $ value = null ; foreach ( $ args as $ arg ) { if ( ! empty ( $ arg ) ) { $ value = $ arg ; break ; } } return $ value ; } | Prioritize the first non empty element from array |
58,502 | public static function notNull ( $ argValue , $ argName = '' ) { $ valid = ( $ argValue !== null ) ; if ( ! $ valid ) { $ message = implode ( ' ' , array_filter ( [ 'Argument' , $ argName , 'must not be null' ] ) ) ; throw new \ InvalidArgumentException ( $ message ) ; } return $ valid ; } | Throws exception if argument is null |
58,503 | public function createService ( ServiceLocatorInterface $ serviceLocator ) { $ instanceManager = new InstanceManager ( $ serviceLocator ) ; $ di = new DIContainer ( null , $ instanceManager ) ; $ config = $ serviceLocator -> get ( 'Config' ) ; if ( isset ( $ config [ 'di' ] ) ) { $ di -> configure ( new DiConfig ( $ co... | Create and return abstract factory seeded by dependency injector |
58,504 | public static function isUniqueIdValid ( $ uniqueId , $ class ) { if ( ! $ uniqueId ) { throw new InvalidArgumentException ( sprintf ( __ ( 'For the service provider [%s], the container unique ID cannot be empty.' , 'fulcrum' ) , $ class ) ) ; } if ( ! is_string ( $ uniqueId ) ) { throw new InvalidArgumentException ( s... | Checks if the unique id is valid . Else it throws an error . |
58,505 | public static function isConcreteConfigValid ( $ uniqueId , array $ concreteConfig , array $ defaultStructure , $ class ) { foreach ( array_keys ( $ defaultStructure ) as $ key ) { if ( ! array_key_exists ( $ key , $ concreteConfig ) ) { throw new MissingRequiredParameterException ( sprintf ( __ ( "The required %s para... | Checks if the parameters are valid . |
58,506 | public function getUploadPath ( $ name = null ) { if ( is_null ( $ name ) ) { return '' ; } else { if ( ! isset ( $ this -> cache [ $ name ] ) ) { $ this -> cache [ $ name ] = Yii :: $ app -> pathManager -> getPath ( $ this -> namespace ) ; } } return $ this -> cache [ $ name ] -> getFullPath ( $ name ) ; } | Get absolute final destination path |
58,507 | protected function _createRow ( $ input ) { foreach ( $ input as $ key => $ value ) { $ temp = str_replace ( '"' , '""' , $ value ) ; $ temp = preg_replace ( "=(\r\n|\r|\n)=" , "\n" , $ temp ) ; $ input [ $ key ] = $ this -> delimiter . $ temp . $ this -> delimiter ; } $ output = implode ( $ this -> separator , $ input... | Create one row in the CSV file . |
58,508 | public function rules ( $ key = null , $ operation = null ) { $ ruleName = $ operation ? "{$operation}Rules" : 'defaultRules' ; $ ruleName = method_exists ( $ this , $ ruleName ) ? $ ruleName : 'defaultRules' ; $ rules = $ this -> { $ ruleName } ( ) ; if ( is_null ( $ key ) ) { return $ this -> rules ; } return is_arra... | Return the rules for validation . |
58,509 | public function setRules ( $ rules = [ ] , $ operation = null ) { $ rulesProperty = $ operation ? $ operation . 'Rules' : 'rules' ; $ this -> { $ rulesProperty } = $ rules ; return $ this ; } | Set the rules . |
58,510 | public function render ( $ group = null ) { $ this -> config ( 'content.url' , Router :: url ( $ this -> config ( 'content.url' ) ) ) ; $ content = $ this -> formatTemplate ( 'content' , $ this -> config ( 'content' ) ) ; if ( $ group ) { $ this -> config ( array_shift ( $ this -> _config [ 'childConfig' ] ) ) ; $ menu... | If the current menu item holds a submenu we recursively build again a new menu group . |
58,511 | public static function generate ( $ hashLength = self :: MAX_HASH_LENGTH , $ hashSeed = self :: All ) { if ( ! isset ( static :: $ _hashSeeds , static :: $ _hashSeeds [ $ hashSeed ] ) || ! is_array ( static :: $ _hashSeeds [ $ hashSeed ] ) ) { return md5 ( time ( ) . mt_rand ( ) . time ( ) ) ; } for ( $ _i = 0 , $ _has... | Generates a unique hash code |
58,512 | public static function hash ( $ hashTarget = null , $ hashType = self :: SHA1 , $ hashLength = self :: MAX_HASH_LENGTH , $ rawOutput = false ) { $ _value = ( null === $ hashTarget ) ? static :: generate ( $ hashLength ) : $ hashTarget ; switch ( $ hashType ) { case static :: MD5 : $ _hash = md5 ( $ _value , $ rawOutput... | Generic hashing method . Will hash any string or generate a random hash and hash that! |
58,513 | public function compile ( GetResponseEvent $ event ) { if ( ! $ this -> debug ) { return ; } if ( HttpKernelInterface :: MASTER_REQUEST !== $ event -> getRequestType ( ) ) { return ; } $ this -> assetWatcher -> compile ( ) ; } | Run asset watcher |
58,514 | public static function create ( $ name , $ alias , $ url ) : self { $ self = new static ( ) ; $ self -> name = $ name ; $ self -> alias = $ alias ; $ self -> url = $ url ; $ self -> created_by = Yii :: $ app -> user -> identity -> id ; $ self -> updated_by = Yii :: $ app -> user -> identity -> id ; return $ self ; } | Create domain . |
58,515 | public function edit ( $ name , $ alias , $ url ) : void { $ this -> name = $ name ; $ this -> alias = $ alias ; $ this -> url = $ url ; $ this -> updated_by = Yii :: $ app -> user -> identity -> id ; } | Update domain . |
58,516 | protected function convertPositiveTo ( $ input ) { $ extraLen = strlen ( $ input ) - 5 ; if ( $ extraLen < 0 ) { return str_pad ( $ input , 4 , '0' , STR_PAD_LEFT ) ; } if ( $ extraLen < 26 ) { return chr ( static :: ORD_START + $ extraLen ) . $ input ; } $ extraLen -= 25 ; $ prefix = '' ; $ carets = '' ; do { $ carets... | Convert a positive value into its RFC2550 representation . |
58,517 | protected function convertNegativeTo ( $ input ) { $ res = $ this -> convertPositiveTo ( substr ( $ input , 1 ) ) ; $ res = strtr ( $ res , static :: POSITIVE_CHARS , static :: NEGATIVE_CHARS ) ; if ( strlen ( $ res ) < 5 ) { $ res = '/' . $ res ; } elseif ( $ res [ 0 ] !== '!' ) { $ res = '*' . $ res ; } return $ res ... | Converts a negative value into its RFC2550 representation . |
58,518 | public function convertFromPositive ( $ input ) { $ matches = [ ] ; if ( ! preg_match ( ' /^0*(?<carets>\\^*)(?<alpha>[A-Z]*)(?<year>\d+)$/' , $ input , $ matches ) ) { return null ; } if ( $ matches [ 'alpha' ] === '' ) { return $ matches [ 'year' ] ; } if ( $ matches [ 'carets' ] === '' ) { $ expectedL... | Convert a positive representation . |
58,519 | public function convertFromNegative ( $ input ) { if ( strpos ( '/*' , $ input [ 0 ] ) !== false ) { $ input = substr ( $ input , 1 ) ; } $ input = strtr ( $ input , static :: NEGATIVE_CHARS , static :: POSITIVE_CHARS ) ; $ res = $ this -> convertFromPositive ( $ input ) ; if ( preg_match ( '/^0+$/' , $ res ) ) { retur... | Convert a negative representation . |
58,520 | public static function setClassAttributes ( $ className , AttributeSet $ attributes ) { if ( self :: attributesSetFor ( $ className ) ) { throw new Exception \ RuntimeException ( srptinf ( "Attributes already set for class %s" , $ className ) ) ; } self :: $ classAttributes [ $ className ] = $ attributes ; } | Register attributes for a class . This must be done before creating an instance of Attributes for that class . Registration can be done only once . |
58,521 | public static function isClassAttribute ( $ className , $ attrName ) { if ( ! self :: attributesSetFor ( $ className ) ) { throw new Exception \ RuntimeException ( sprintf ( "Attributes not set for class %s" , $ className ) ) ; } return self :: $ classAttributes [ $ className ] -> exists ( $ attrName ) ; } | Check if an attribute is valid for a class . |
58,522 | public static function getAttributesFor ( $ className ) { if ( ! self :: attributesSetFor ( $ className ) ) { $ className :: getAttributeSet ( ) ; } return self :: $ classAttributes [ $ className ] ; } | Get the registered attributes for a class . |
58,523 | public function init ( $ parameters ) { if ( empty ( $ parameters [ "log_path" ] ) ) { throw new \ Exception ( "Log path is not specified!" ) ; } $ this -> log_path = $ parameters [ "log_path" ] ; if ( ! file_exists ( $ this -> log_path ) || ! is_writable ( $ this -> log_path ) ) { throw new \ Exception ( sprintf ( "Th... | Initializes the debug profiler with parameters . |
58,524 | public function logMessageToFile ( $ message , $ file_name ) { $ file = $ this -> log_path . $ file_name ; if ( ( ! file_exists ( $ file ) && is_writable ( $ this -> log_path ) ) || is_writable ( $ file ) ) { return error_log ( $ message . "\r\n" , 3 , $ file ) ; } else { throw new \ Exception ( sprintf ( "The log file... | Logs a message to a specified log file . |
58,525 | public function clearLogFile ( $ file_name ) { $ file = $ this -> log_path . $ file_name ; if ( ( ! file_exists ( $ file ) && is_writable ( $ this -> log_path ) ) || is_writable ( $ file ) ) { return @ unlink ( $ file ) ; } return false ; } | Clears the specified log file . |
58,526 | public function clearLogFiles ( ) { $ dir = $ this -> log_path ; $ files = scandir ( $ dir ) ; foreach ( $ files as $ file ) { if ( $ file == "." || $ file == ".." || is_dir ( $ dir . $ file ) ) { continue ; } $ pi = pathinfo ( $ dir . $ file ) ; if ( empty ( $ pi [ "extension" ] ) || strtolower ( $ pi [ "extension" ] ... | Clears all log files . |
58,527 | private function mustHaveTheKeyInThe ( array $ data ) : void { $ mapping = $ this ; assert ( $ mapping instanceof ExposesDataKey ) ; if ( ! isset ( $ data [ $ mapping -> key ( ) ] ) ) { throw MissingTheKey :: inTheInput ( $ data , $ mapping , $ mapping -> key ( ) ) ; } } | Asserts that our key is present in the input array . |
58,528 | protected function getOptions ( Style $ style ) : array { $ options = [ ] ; $ options [ ] = $ style -> isBold ( ) ? 'bold' : null ; $ options [ ] = $ style -> isUnderscore ( ) ? 'underscore' : null ; return array_filter ( $ options ) ; } | Devuelve un array con opciones a partir de un estilo |
58,529 | public static function ruleRegex ( $ regex ) { $ args = func_get_args ( ) ; $ regex = join ( ':' , $ args ) ; if ( ! preg_match ( '/^([\/#~]).+\1[msugex]*$/' , $ regex ) ) { $ regex = '/' . stripslashes ( $ regex ) . '/' ; } return function ( $ input ) use ( $ regex ) { return preg_match ( $ regex , $ input ) ; } ; } | Check regex against input |
58,530 | public static function ruleRegexInverse ( $ regex ) { $ args = func_get_args ( ) ; $ regex = join ( ':' , $ args ) ; if ( ! preg_match ( '/^([\/#~]).+\1[msugex]*$/' , $ regex ) ) { $ regex = '/' . stripslashes ( $ regex ) . '/' ; } return function ( $ input ) use ( $ regex ) { return ! preg_match ( $ regex , $ input ) ... | Check regex against input and returns reveresed result |
58,531 | public static function ruleDate ( ) { return function ( $ input ) { $ date = null ; try { $ date = date_parse ( $ input ) ; if ( $ date [ 'warning_count' ] === 0 && $ date [ 'error_count' ] === 0 ) { return strlen ( $ date [ 'hour' ] ) === 0 ; } else { return false ; } } catch ( \ Exception $ e ) { return false ; } } ;... | Check whether input is a date string |
58,532 | public static function ruleDateTime ( ) { return function ( $ input ) { $ date = null ; try { $ date = date_parse ( $ input ) ; return $ date [ 'warning_count' ] === 0 && $ date [ 'error_count' ] === 0 ; } catch ( \ Exception $ e ) { return false ; } } ; } | Check whether input is a datetime |
58,533 | public function after ( ) { if ( $ this -> _handle_ajax == true ) { if ( $ this -> request -> is_ajax ( ) ) { $ return = array ( ) ; if ( RD :: has_messages ( ) == false ) { $ return [ 'status' ] = 'success' ; $ return [ 'response' ] = [ '' ] ; } else if ( RD :: get_current ( RD :: ERROR ) != null ) { $ return [ 'statu... | Handle Request Data persistence or output based on the request type . |
58,534 | public function load ( $ source , Configuration $ config = null ) : Configuration { if ( null === $ config ) { $ config = new Configuration ( ) ; } $ loader = $ this -> getLoader ( $ source , $ config ) ; if ( ! $ loader -> supports ( $ source ) ) { throw new \ InvalidArgumentException ( 'Unsupported configuration.' ) ... | Load a configuration . |
58,535 | public function getConfigParam ( $ name ) { $ result = null ; $ config = $ this -> getConfiguration ( ) ; $ parts = explode ( '.' , $ name ) ; foreach ( $ parts as $ key ) { if ( isset ( $ config [ $ key ] ) ) { $ result = $ config = $ config [ $ key ] ; } else { $ result = null ; break ; } } return $ result ; } | Get configuration parameter |
58,536 | public function getComponentConfig ( $ componentName ) { $ result = null ; $ config = $ this -> getConfiguration ( ) ; if ( isset ( $ config [ self :: COMPONENT_CONFIG_BLOCK ] [ $ componentName ] ) ) { $ result = $ config [ self :: COMPONENT_CONFIG_BLOCK ] [ $ componentName ] ; } return $ result ; } | Get configuration for component by name |
58,537 | public function runController ( $ handler , array $ params = [ ] ) { return SystemHelpers :: call ( $ this -> prepareCallback ( $ handler ) , function ( $ paramName ) use ( $ params ) { if ( ( $ component = $ this -> getComponent ( $ paramName ) ) !== null ) { return $ component ; } if ( isset ( $ _GET [ $ paramName ] ... | Run by handler name |
58,538 | protected function forceComponentLoading ( ) { $ config = $ this -> getConfiguration ( ) ; foreach ( $ config [ self :: COMPONENT_CONFIG_BLOCK ] as $ key => $ params ) { if ( isset ( $ params [ 'class' ] ) && isset ( $ params [ 'force' ] ) ) { $ component = $ this -> getComponent ( $ key ) ; if ( $ component instanceof... | Force component loading |
58,539 | public function getComponent ( $ name ) { if ( ! isset ( $ this -> componentCache [ $ name ] ) && ( $ this -> componentCache [ $ name ] = $ this -> createComponent ( $ name ) ) !== null ) { $ this -> componentCache [ $ name ] -> init ( ) ; } return $ this -> componentCache [ $ name ] ; } | Get component by name |
58,540 | public function attachPlugin ( $ name , Plugin $ plugin ) { $ plugin -> register ( $ this ) ; $ this -> plugins [ $ name ] = $ plugin ; return $ this ; } | Attach plugin to application |
58,541 | abstract function __construct ( $ result , $ buffered = true ) ; | Construct a new result - set . |
58,542 | private function convertArrayKeys ( array $ data , $ case ) { foreach ( $ data as $ property => $ value ) { $ originalProperty = $ property ; switch ( $ case ) { case StringCases :: STUDLY_CAPS : $ property = $ this -> toStudlyCaps ( $ property ) ; break ; case StringCases :: CAMEL_CASE : $ property = $ this -> toCamel... | convert the keys of an array |
58,543 | public function pageGeneratedIn ( $ langStringPageGeneratedIn = '%s' ) { $ str = str_replace ( '%s' , round ( $ this -> getmicrotime ( ) - $ this -> PageTimestamp , 4 ) , $ langStringPageGeneratedIn ) ; return $ str ; } | If called with Page Generated in %s seconds it returns Page Generated in x . xxxx seconds |
58,544 | public function handleRequest ( $ requestedUrl ) { $ controllersToScan = self :: $ config [ "scanneableControllers" ] ; $ request = HttpRequestBuilder :: buildFromRequestUrl ( $ requestedUrl ) ; if ( $ this -> getMode ( ) != self :: $ MODE_TESTING ) { Session :: start ( ) ; if ( ! is_null ( $ request -> getLang ( ) ) )... | Handle the requested url dispatching to routed controllers . |
58,545 | public function shutdown ( ) { if ( ( $ error = error_get_last ( ) ) ) { ob_clean ( ) ; $ msg = $ error [ "message" ] . " in file: " . $ error [ "file" ] . " on line: " . $ error [ "line" ] ; $ log = new Logger ( 'kernel' ) ; $ file = self :: get ( "dir" , "log" ) . "/log-" . date ( "Ymd" ) . ".log" ; $ log -> pushHand... | Function for show errors based on kernel mode . |
58,546 | public static function getRoute ( $ pattern ) { $ route = null ; if ( isset ( self :: $ routes [ $ pattern ] ) ) { $ route = self :: $ routes [ $ pattern ] ; } return $ route ; } | Get a route . |
58,547 | protected function createMemcachedDriver ( string $ name , Prop $ config ) { $ memcached = new \ Memcached ( $ config -> getOr ( "persistent_id" , null ) ) ; if ( $ config -> isArray ( "options" ) ) { $ memcached -> setOptions ( $ config -> get ( "options" ) ) ; } if ( $ config -> getIs ( "username" ) && method_exists ... | Create an instance of the Memcached cache driver |
58,548 | protected function createRedisDriver ( string $ name , Prop $ config ) { if ( ! class_exists ( "Predis\\Client" ) ) { throw new \ RuntimeException ( "Redis client library is not loaded" ) ; } $ parameters = $ config -> toArray ( ) ; $ options = $ config -> isArray ( "options" ) ? $ config -> get ( "options" ) : [ ] ; u... | Create an instance of the Redis cache driver |
58,549 | protected function createDatabaseDriver ( string $ name , Prop $ config ) { return new DatabaseStore ( App :: Database ( ) -> getConnection ( $ config -> getOr ( "connection" , null ) ) , $ name , $ config -> getOr ( "table" , "cache" ) , $ config -> getOr ( "life" , 0 ) ) ; } | Create an instance of the database cache driver |
58,550 | protected function createApcDriver ( string $ name , Prop $ config ) { if ( ! function_exists ( "apcu_store" ) ) { throw new \ RuntimeException ( "APCu client library is not loaded" ) ; } $ cli = function_exists ( "php_sapi_name" ) && strpos ( php_sapi_name ( ) , "cli" ) !== false ; $ enable = in_array ( strtolower ( i... | Create an instance of the APC cache driver |
58,551 | protected function createFileDriver ( string $ name , Prop $ config ) { return new FileStore ( Filesystem :: getInstance ( ) , $ name , $ config -> getOr ( "directory" , "cache" ) , $ config -> getOr ( "life" , 0 ) ) ; } | Create an instance of the file cache driver |
58,552 | public static function ListAll ( ) { $ data = [ ] ; $ folders = glob ( Application :: $ root . 'resources/translator/*' ) ; foreach ( $ folders as $ key => $ value ) { $ folder = \ Strings :: splite ( $ value , 'resources/translator/' ) ; $ folder = $ folder [ 1 ] ; $ data [ ] = '>' . $ folder ; foreach ( glob ( Applic... | Listing all schemas . |
58,553 | public static function generator ( $ algo = 'crc32b' , $ length = 32 ) { $ host = Route :: HTTP_HOST ( ) ; $ timestamp = Date :: getTimestamp ( ) ; $ uniqid = uniqid ( bin2hex ( random_bytes ( $ length ) ) , true ) ; $ out = self :: get ( $ algo , $ host . $ timestamp . $ uniqid ) ; return $ out ; } | Random hash generator . |
58,554 | public function fromSub ( $ query , $ as ) { $ bindings = [ ] ; if ( $ query instanceof Closure ) { $ callback = $ query ; $ callback ( $ query = $ this -> newQuery ( ) ) ; } if ( $ query instanceof self ) { $ bindings = $ query -> getBindings ( ) ; $ query = $ query -> toSql ( ) ; } else if ( ! is_string ( $ query ) )... | Add a select query for from expression to the query . |
58,555 | public function forPage ( $ page , $ perPage = 15 ) { if ( $ page < 1 ) { $ page = 1 ; } return $ this -> limit ( $ perPage , ( $ page - 1 ) * $ perPage ) ; } | Set the limit and offset for a given page . |
58,556 | public function updateOrInsert ( array $ attributes , array $ values = [ ] ) { if ( ! $ this -> where ( $ attributes ) -> exists ( ) ) { return $ this -> insert ( array_merge ( $ attributes , $ values ) ) ; } return ( bool ) $ this -> limit ( 1 ) -> update ( $ values ) ; } | Insert or update a record matching the attributes and fill it with values . |
58,557 | public static function set_cookie ( $ name , $ value , $ expiry = 90 , $ path = null , $ domain = null , $ secure = false , $ httpOnly = false ) { Deprecation :: notice ( '0.2' , 'This method is no longer required. Please use Cookie::set' ) ; Cookie :: set ( $ name , $ value , $ expiry , $ path , $ domain , $ secure , ... | Set cookie to use the same cookie domain as Session |
58,558 | public static function parse_record_fields ( $ content , $ data = [ ] , $ record = null , $ ignore = [ ] , $ html = true ) { $ content = new SSViewer_FromString ( $ content ) ; if ( ! $ record ) { $ record = ArrayData :: create ( $ data ) ; } else { $ record = clone $ record ; $ record = $ record -> customise ( $ data ... | Replace fields in content with record fields |
58,559 | public static function save_from_map ( DataObject $ record , $ relation , $ regField = '' , $ write = true ) { $ map = $ record -> toMap ( ) ; $ rel = $ record -> getComponent ( $ relation ) ; $ changed = false ; if ( ! $ regField ) { $ regField = $ relation ; } foreach ( $ map as $ field => $ val ) { if ( preg_match (... | than it should be ) |
58,560 | public function getTransactor ( $ name ) { if ( ! array_key_exists ( $ name , $ this -> transactors ) ) { throw TransactorException :: transactorNotRegistered ( $ name ) ; } return $ this -> transactors [ $ name ] ; } | Gets a single transactor by name |
58,561 | protected function callSelector ( $ key ) { foreach ( $ this -> selectors as $ selector => $ callback ) { $ regex = '/' . $ selector . '/i' ; if ( preg_match ( $ regex , $ key , $ matches ) ) { return call_user_func_array ( $ callback , array ( $ this , $ key , $ matches ) ) ; } } throw new Exception \ Index ( 'Unknown... | Calls a selector or throws an exception if it doesn t know what it is . |
58,562 | public function spliceCallback ( Collection $ collection , $ key , array $ matches ) { $ start = $ matches [ 'start' ] ; $ end = $ matches [ 'end' ] ; if ( $ end == 'END' ) { $ end = count ( $ this -> contents ) - 1 ; } if ( $ start < 0 ) { $ start = ( count ( $ this -> contents ) ) - abs ( $ start ) ; } if ( $ start >... | Splices a collection given by a range . You can also use START and END as keywords . |
58,563 | public function pluckCallback ( Collection $ collection , $ key , array $ matches ) { $ indexes = explode ( ',' , $ key ) ; $ result = array ( ) ; foreach ( $ indexes as $ idx ) { $ idx = trim ( $ idx ) ; if ( $ idx != '' ) { if ( array_key_exists ( $ idx , $ this -> contents ) ) { $ result [ $ idx ] = $ this -> conten... | Implements the plucking behaviour . |
58,564 | public function offsetGet ( $ offset ) { if ( is_int ( $ offset ) ) { return $ this -> contents [ $ offset ] ; } elseif ( $ offset == ':last' ) { return $ this -> contents [ count ( $ this -> contents ) - 1 ] ; } else { return $ this -> callSelector ( $ offset ) ; } } | This function is the gateway to the short syntax magic . |
58,565 | public function sortByMember ( $ member , $ direction = Collection :: SORT_ASC , $ flags = SORT_REGULAR ) { $ arr_to_sort = array ( ) ; foreach ( $ this -> contents as $ key => $ item ) { if ( is_array ( $ item ) ) { if ( ! array_key_exists ( $ member , $ item ) ) { throw new Exception \ Index ( 'Unknown Array Index "'... | Sorting by a member of the collection contents . Works on keyed arrays object members and the result of functions on an object . |
58,566 | public function cycleForward ( $ advance = 1 ) { for ( $ i = 0 ; $ i < $ advance ; $ i ++ ) { if ( $ this -> cyclePosition == $ this -> count ( ) - 1 ) { $ this -> cyclePosition = 0 ; } else { $ this -> cyclePosition ++ ; } } return $ this -> cycleValue ( ) ; } | Cycles the collection forward . What this means is that the Collection will move forward a given number of positions . If it reaches the end of the collection it will wrap back to the beginning . |
58,567 | public function hasManyThroughMany ( $ related , $ through , $ firstKey = null , $ secondKey = null , $ localKey = null , $ throughKey = null ) { $ through = new $ through ; $ firstKey = $ firstKey ? : $ this -> getForeignKey ( ) ; $ secondKey = $ secondKey ? : $ through -> getForeignKey ( ) ; $ localKey = $ localKey ?... | get relationships through another table |
58,568 | public function computeDelta ( ) { if ( ! $ this -> hasDelta ( ) ) { return false ; } $ thisPeriod = $ this -> nthPreviousPeriod ( ) ; $ mostRecentPeriod = $ this -> nthPreviousPeriod ( 1 ) ; $ current = $ this -> computeValue ( $ thisPeriod ) ; $ previous = $ this -> computeValue ( $ mostRecentPeriod ) ; return $ curr... | Calculates the delta between the current value and the previous value . |
58,569 | public function values ( $ start = - 6 , $ end = 0 ) { $ start = ( int ) $ start ; $ end = ( int ) $ end ; if ( $ start < 0 ) { $ granularity = $ this -> granularity ( ) ; if ( $ granularity == STATISTIC_GRANULARITY_DAY ) { $ nPrevious = strtotime ( $ start . ' days' ) ; $ start = mktime ( 0 , 0 , 0 , date ( 'm' , $ nP... | Looks up all stored values between two timestamps . If more points are available than requested then the points will be summed up according to equally spaced intervals . |
58,570 | public function needsToBeCaptured ( ) { if ( ! $ this -> shouldBeCaptured ( ) ) { return false ; } $ mostRecentPeriod = $ this -> nthPreviousPeriod ( 1 ) ; $ latestStartDate = date ( 'Y-m-d' , $ mostRecentPeriod [ 'start' ] ) ; return Statistic :: totalRecords ( [ 'metric' => $ this -> key ( ) , 'day' => $ latestStartD... | Checks if the metric needs a value captured for the newest completed period . |
58,571 | public function savePeriod ( $ n = 1 ) { if ( ! $ this -> shouldBeCaptured ( ) || $ n < 1 ) { return false ; } $ period = $ this -> nthPreviousPeriod ( $ n ) ; $ value = $ this -> computeValue ( $ period ) ; $ d = date ( 'Y-m-d' , $ period [ 'start' ] ) ; $ stat = new Statistic ( [ $ this -> key ( ) , $ d ] ) ; if ( ! ... | Saves the Nth previous period . Creates the statistic entry if it does not exist otherwise overwrites the previous value . |
58,572 | public function toArray ( ) { $ name = $ this -> name ( ) ; $ value = $ this -> computeValue ( ) ; $ delta = $ this -> computeDelta ( ) ; return [ 'name' => $ name , 'key' => $ this -> key ( ) , 'granularity' => $ this -> granularity ( ) , 'prefix' => $ this -> prefix ( ) , 'suffix' => $ this -> suffix ( ) , 'hasChart'... | Bundles up some useful properties of the statistic for convenience . |
58,573 | public function nthPreviousPeriod ( $ n = 0 ) { $ n = max ( 0 , $ n ) ; $ interval = $ this -> interval ( $ this -> granularity ( ) ) ; $ start = $ this -> startOfDay ( strtotime ( 'this ' . $ interval ) ) ; $ i = $ n ; while ( $ i > 0 ) { $ start = $ this -> startOfDay ( strtotime ( '-1 ' . $ interval , $ start ) ) ; ... | Returns the start and end timestamps for the nth - previous period since the current period . 0 will return the current period . |
58,574 | public function handle ( TableInterface $ table , Request $ request = null ) { foreach ( $ this -> extensions as $ extension ) { $ extension -> handle ( $ table , $ request ) ; } $ this -> type -> handle ( $ table , $ request ) ; } | Handle a request for a table |
58,575 | public function getuser ( ) { if ( empty ( $ this -> user ) ) { return NULL ; } bimport ( 'users.general' ) ; $ bu = BUsers :: getInstance ( ) ; $ user = $ bu -> itemGet ( $ this -> user ) ; return $ user ; } | Get user by social user . |
58,576 | public function getManyTranslations ( File $ file , QueryBuilder $ builder ) : LengthAwarePaginator { $ query = $ file -> translations ( ) -> newQuery ( ) -> getQuery ( ) ; $ builder -> applyFilters ( $ query ) ; $ builder -> applySorts ( $ query ) ; $ count = clone $ query -> getQuery ( ) ; $ results = $ query -> limi... | Get all translations for specified file . |
58,577 | public static function createFromString ( $ string ) { if ( mb_strpos ( $ string , ':' ) !== false ) { list ( $ username , $ password ) = explode ( ':' , $ string , 2 ) ; } else { $ username = $ string ; $ password = $ password ; } return new self ( $ username , $ password ) ; } | Instanciate a new User object from a string |
58,578 | public function initResourceByPath ( $ path ) { $ parsed = parse_url ( $ path ) ; if ( $ parsed === false ) { return false ; } $ this -> currentPath = $ path ; if ( isset ( $ parsed [ 'host' ] ) ) { $ this -> containerName = $ parsed [ 'host' ] ; } if ( isset ( $ parsed [ 'path' ] ) ) { $ this -> resourceName = $ this ... | Take the container and the resource name from the |
58,579 | public static function fromXml ( \ DOMElement $ xml ) { $ static = new static ( ) ; $ title = $ xml -> getElementsByTagName ( 'title' ) ; $ static -> title = StringLiteral :: fromXml ( $ title ) ; $ author = $ xml -> getElementsByTagName ( 'author' ) ; $ static -> author = StringLiteral :: fromXml ( $ author ) ; $ year... | Builds a LibraryItemMetadata object from XML . |
58,580 | protected function registerClientScript ( ) { $ view = $ this -> getView ( ) ; $ options = Json :: encode ( $ this -> jsOptions ) ; Asset :: register ( $ view ) ; $ view -> registerJs ( 'jQuery.communication(' . $ options . ');' ) ; } | Register widget client scripts . |
58,581 | function withServices ( array $ services ) { foreach ( $ services as $ method => $ type ) { $ this -> bind ( $ method , $ type ) ; } return $ this ; } | Bind many methods at once . |
58,582 | function withScoped ( array $ services ) { foreach ( $ services as $ method => $ type ) { $ this -> bind ( $ method , $ type , self :: SCOPED ) ; } return $ this ; } | Bind many scoped methods at once . |
58,583 | protected function getHeadLinkHelper ( ) { if ( $ this -> headLinkHelper ) { return $ this -> headLinkHelper ; } if ( method_exists ( $ this -> view , 'plugin' ) ) { $ this -> headLinkHelper = $ this -> view -> plugin ( 'headLink' ) ; } if ( ! $ this -> headLinkHelper instanceof HeadLink ) { $ this -> headLinkHelper = ... | Retrieve the HeadLink helper |
58,584 | protected function getUrlHelper ( ) { if ( $ this -> urlHelper ) { return $ this -> urlHelper ; } if ( method_exists ( $ this -> view , 'plugin' ) ) { $ this -> urlHelper = $ this -> view -> plugin ( 'url' ) ; } if ( ! $ this -> urlHelper instanceof Url ) { $ this -> urlHelper = new Url ( ) ; } return $ this -> urlHelp... | Retrieve the Url helper |
58,585 | protected function getMessengerHelper ( ) { if ( $ this -> messengerHelper ) { return $ this -> messengerHelper ; } if ( method_exists ( $ this -> view , 'plugin' ) ) { $ this -> messengerHelper = $ this -> view -> plugin ( 'messenger' ) ; } if ( ! $ this -> messengerHelper instanceof Messenger ) { $ this -> messengerH... | Retrieve the Messenger helper |
58,586 | protected function getTranslateHelper ( ) { if ( $ this -> translateHelper ) { return $ this -> translateHelper ; } if ( method_exists ( $ this -> view , 'plugin' ) ) { $ this -> translateHelper = $ this -> view -> plugin ( 'translate' ) ; } if ( ! $ this -> translateHelper instanceof Translate ) { $ this -> translateH... | Retrieve the Translate helper |
58,587 | public function apply ( ) { if ( method_exists ( $ this -> view , 'plugin' ) ) { $ global = false ; $ roots = ( array ) $ this -> roots ; $ headLink = $ this -> getHeadLinkHelper ( ) ; if ( in_array ( null , $ roots ) ) { $ global = true ; } $ roots = array_filter ( $ roots ) ; if ( $ global ) { $ roots [ ] = null ; } ... | Apply custom css |
58,588 | public function get ( $ slug , $ parameters = [ ] ) { $ code = $ this -> request ( 'GET' , $ this -> url ( "{$this->general_config['api_version']}/$slug" ) , $ parameters ) ; return $ this -> response ( $ code ) ; } | Do a GET request to the Twitter API . |
58,589 | public function post ( $ slug , $ parameters = [ ] ) { $ code = $ this -> request ( 'POST' , $ this -> url ( "{$this->general_config['api_version']}/$slug" ) , $ parameters ) ; return $ this -> response ( $ code ) ; } | Do a POST request to the Twitter API . |
58,590 | public function request ( $ method , $ url , $ params = [ ] , $ useauth = true , $ multipart = false , $ headers = [ ] ) { foreach ( $ params as $ param => $ val ) { switch ( $ param ) { case 'user_id' : if ( ! is_numeric ( $ val ) ) { throw new \ Exception ( "user_id must be numeric $val" ) ; } break ; case 'count' : ... | Owerwrite the parent s request function to clean up some parameters before sending . |
58,591 | public function getRequestToken ( $ oauth_callback = null ) { $ parameters = [ ] ; if ( ! empty ( $ oauth_callback ) ) { $ parameters [ 'oauth_callback' ] = $ oauth_callback ; } $ code = $ this -> request ( 'POST' , $ this -> url ( 'oauth/request_token' , '' ) , $ parameters ) ; if ( isset ( $ this -> response [ 'code'... | Get a request_token from Twitter . |
58,592 | public function getAccessToken ( $ oauth_verifier = false ) { $ parameters = [ ] ; if ( ! empty ( $ oauth_verifier ) ) { $ parameters [ 'oauth_verifier' ] = $ oauth_verifier ; } $ code = $ this -> request ( 'POST' , $ this -> url ( 'oauth/access_token' , '' ) , $ parameters ) ; if ( isset ( $ this -> response [ 'code' ... | Get an access token for a logged in user . |
58,593 | public function getAuthorizeUrl ( $ token , $ sign_in_with_twitter = true , $ force_login = false ) { if ( is_array ( $ token ) ) { $ token = $ token [ 'oauth_token' ] ; } if ( $ force_login ) { return "https://api.twitter.com/oauth/authenticate?oauth_token={$token}&force_login=true" ; } elseif ( empty ( $ sign_in_with... | Get the authorize URL . |
58,594 | public function block ( $ twitter_id , $ parameters = [ ] ) { if ( ! is_numeric ( $ twitter_id ) ) { return false ; } $ slug = 'blocks/create' ; $ default_parameters = [ 'user_id' => $ twitter_id , 'include_entities' => false , 'skip_status' => false , ] ; $ parameters = array_merge ( $ default_parameters , $ parameter... | Block a given user . |
58,595 | public function search ( string $ query , array $ arguments = null ) { $ args = [ 'q' => $ query ] ; if ( is_array ( $ arguments ) ) { $ args = array_merge ( $ arguments , $ args ) ; } return new SearchIterator ( $ this , 'search/tweets' , $ args ) ; } | Get all results from tweets for the search API returns for the given query . |
58,596 | public function getUser ( string $ query , array $ extra_args = null ) { if ( is_numeric ( $ query ) ) { $ response = $ this -> getUserByID ( $ query , $ extra_args ) ; if ( ! isset ( $ response [ 'errors' ] ) ) { return $ response ; } } return $ this -> getUserByUsername ( $ query , $ extra_args ) ; } | Get info about a given user . Search can be performed based on ID screen name ... |
58,597 | private function response ( $ code ) { switch ( $ code ) { case 200 : case 304 : return $ this -> success ( ) ; case 403 : return $ this -> forbidden ( ) ; case 404 : return $ this -> requestDoesNotExist ( ) ; case 429 : return $ this -> rateLimit ( ) ; case 400 : default : return $ this -> generalError ( ) ; } } | Parse the response depending on the provided code |
58,598 | private function success ( ) { if ( ! isset ( $ this -> response [ 'response' ] ) or ! is_string ( $ this -> response [ 'response' ] ) ) { throw new \ Exception ( 'There is no response! PANIC!!' ) ; } $ json_output = $ this -> general_config [ 'json_decode' ] == 'array' ? true : false ; return json_decode ( $ this -> r... | Process a successful response and return the parsed output |
58,599 | private function rateLimit ( ) { return [ 'code' => $ this -> response [ 'code' ] , 'errors' => $ this -> response [ 'response' ] , 'tts' => isset ( $ this -> response [ 'headers' ] [ 'x-rate-limit-reset' ] ) ? ( $ this -> response [ 'headers' ] [ 'x-rate-limit-reset' ] - time ( ) ) : false , ] ; } | Return the error response when a rate limit has been reached on a given endpoint . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.