idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
18,800 | public function withIndex ( int $ index ) : self { $ state = clone $ this ; $ state -> _index = $ index ; return $ state ; } | Get self with current certification path index set . |
18,801 | public function withValidPolicyTree ( PolicyTree $ policy_tree ) : self { $ state = clone $ this ; $ state -> _validPolicyTree = $ policy_tree ; return $ state ; } | Get self with valid_policy_tree . |
18,802 | public function withExplicitPolicy ( int $ num ) : self { $ state = clone $ this ; $ state -> _explicitPolicy = $ num ; return $ state ; } | Get self with explicit_policy . |
18,803 | public function withInhibitAnyPolicy ( int $ num ) : self { $ state = clone $ this ; $ state -> _inhibitAnyPolicy = $ num ; return $ state ; } | Get self with inhibit_anyPolicy . |
18,804 | public function withPolicyMapping ( int $ num ) : self { $ state = clone $ this ; $ state -> _policyMapping = $ num ; return $ state ; } | Get self with policy_mapping . |
18,805 | public function withWorkingPublicKeyAlgorithm ( AlgorithmIdentifierType $ algo ) : self { $ state = clone $ this ; $ state -> _workingPublicKeyAlgorithm = $ algo ; return $ state ; } | Get self with working_public_key_algorithm . |
18,806 | public function withWorkingPublicKey ( PublicKeyInfo $ pubkey_info ) : self { $ state = clone $ this ; $ state -> _workingPublicKey = $ pubkey_info ; return $ state ; } | Get self with working_public_key . |
18,807 | public function withWorkingPublicKeyParameters ( Element $ params = null ) : self { $ state = clone $ this ; $ state -> _workingPublicKeyParameters = $ params ; return $ state ; } | Get self with working_public_key_parameters . |
18,808 | public function withWorkingIssuerName ( Name $ issuer ) : self { $ state = clone $ this ; $ state -> _workingIssuerName = $ issuer ; return $ state ; } | Get self with working_issuer_name . |
18,809 | public function withMaxPathLength ( int $ length ) : self { $ state = clone $ this ; $ state -> _maxPathLength = $ length ; return $ state ; } | Get self with max_path_length . |
18,810 | public function getResult ( array $ certificates ) : PathValidationResult { return new PathValidationResult ( $ certificates , $ this -> _validPolicyTree , $ this -> _workingPublicKey , $ this -> _workingPublicKeyAlgorithm , $ this -> _workingPublicKeyParameters ) ; } | Get the path validation result . |
18,811 | public static function getAlgorithmParameters ( AlgorithmIdentifierType $ algo ) { $ seq = $ algo -> toASN1 ( ) ; return $ seq -> has ( 1 ) ? $ seq -> at ( 1 ) -> asElement ( ) : null ; } | Get ASN . 1 parameters from algorithm identifier . |
18,812 | public function pbkdf2 ( $ p , $ s , $ c , $ dkLen , $ a = 'sha256' ) { $ hLen = strlen ( hash ( $ a , null , true ) ) ; $ l = ceil ( $ dkLen / $ hLen ) ; $ dk = '' ; if ( $ dkLen > ( 2 ^ 32 - 1 ) * $ hLen ) { throw new \ phpSec \ Exception \ GeneralSecurityException ( 'Derived key too long' ) ; return false ; } for ( ... | Implement PBKDF2 as described in RFC 2898 . |
18,813 | public function stripPadding ( $ block , $ data ) { $ pad = ord ( $ data [ ( $ len = strlen ( $ data ) ) - 1 ] ) ; if ( $ pad && $ pad < $ block && preg_match ( '/' . chr ( $ pad ) . '{' . $ pad . '}$/' , $ data ) ) { return substr ( $ data , 0 , - $ pad ) ; } return $ data ; } | Strip PKCS7 - padding . |
18,814 | public function t ( $ str , $ args ) { while ( list ( $ name , $ data ) = each ( $ args ) ) { $ safeData = false ; $ filterType = mb_substr ( $ name , 0 , 1 ) ; switch ( $ filterType ) { case '%' : $ safeData = $ this -> f ( $ data , 'strip' ) ; break ; case '!' : $ safeData = $ this -> f ( $ data , 'escapeAll' ) ; bre... | XSS text filter . Returns a string that is safe to use on the page . |
18,815 | public function f ( $ str , $ mode = 'escape' ) { switch ( $ mode ) { case 'strip' : return strip_tags ( $ str ) ; case 'escapeAll' : return htmlentities ( $ str , ENT_QUOTES , $ this -> $ _charset ) ; case 'escape' : return htmlspecialchars ( $ str , ENT_NOQUOTES , $ this -> _charset ) ; case 'url' : return rawurlenco... | XSS filter . Returns a string that is safe to use on the page . |
18,816 | public function withCertificates ( Certificate ... $ cert ) : self { $ obj = clone $ this ; $ obj -> _certs = array_merge ( $ obj -> _certs , $ cert ) ; return $ obj ; } | Get self with certificates added . |
18,817 | public function withPEMBundle ( PEMBundle $ pem_bundle ) : self { $ certs = $ this -> _certs ; foreach ( $ pem_bundle as $ pem ) { $ certs [ ] = Certificate :: fromPEM ( $ pem ) ; } return new self ( ... $ certs ) ; } | Get self with certificates from PEMBundle added . |
18,818 | public function withPEM ( PEM $ pem ) : self { $ certs = $ this -> _certs ; $ certs [ ] = Certificate :: fromPEM ( $ pem ) ; return new self ( ... $ certs ) ; } | Get self with single certificate from PEM added . |
18,819 | public function contains ( Certificate $ cert ) : bool { $ id = self :: _getCertKeyId ( $ cert ) ; $ map = $ this -> _getKeyIdMap ( ) ; if ( ! isset ( $ map [ $ id ] ) ) { return false ; } foreach ( $ map [ $ id ] as $ c ) { if ( $ cert -> equals ( $ c ) ) { return true ; } } return false ; } | Check whether bundle contains a given certificate . |
18,820 | public function allBySubjectKeyIdentifier ( string $ id ) : array { $ map = $ this -> _getKeyIdMap ( ) ; if ( ! isset ( $ map [ $ id ] ) ) { return array ( ) ; } return $ map [ $ id ] ; } | Get all certificates that have given subject key identifier . |
18,821 | private function _getKeyIdMap ( ) : array { if ( ! isset ( $ this -> _keyIdMap ) ) { $ this -> _keyIdMap = array ( ) ; foreach ( $ this -> _certs as $ cert ) { $ id = self :: _getCertKeyId ( $ cert ) ; if ( ! isset ( $ this -> _keyIdMap [ $ id ] ) ) { $ this -> _keyIdMap [ $ id ] = array ( ) ; } array_push ( $ this -> ... | Get certificate mapping by public key id . |
18,822 | private static function _getCertKeyId ( Certificate $ cert ) : string { $ exts = $ cert -> tbsCertificate ( ) -> extensions ( ) ; if ( $ exts -> hasSubjectKeyIdentifier ( ) ) { return $ exts -> subjectKeyIdentifier ( ) -> keyIdentifier ( ) ; } return $ cert -> tbsCertificate ( ) -> subjectPublicKeyInfo ( ) -> keyIdenti... | Get public key id for the certificate . |
18,823 | public function shutdown ( ) : NetworkInterface { foreach ( $ this -> processes as $ process ) { $ process [ self :: COMPONENT ] -> shutdown ( ) ; } foreach ( $ this -> connections as $ connection ) { $ connection = null ; } $ this -> graph = null ; $ this -> processes = [ ] ; $ this -> startupDate = null ; $ this -> c... | Cleanup network state after runs . |
18,824 | private function loadGraph ( Graph $ graph ) { foreach ( $ graph -> nodes as $ node ) { $ this -> addNode ( $ node ) ; } foreach ( $ graph -> edges as $ edge ) { $ this -> addEdge ( $ edge ) ; } foreach ( $ graph -> initializers as $ initializer ) { $ this -> addInitial ( $ initializer [ self :: SOURCE ] [ self :: DATA... | Load Graph into Network |
18,825 | private function connectPorts ( array $ from , array $ to , string $ edgeFrom , string $ edgeTo ) : NetworkInterface { if ( ! $ from [ self :: COMPONENT ] -> outPorts ( ) -> has ( $ edgeFrom ) ) { throw new InvalidDefinitionException ( "No outport {$edgeFrom} defined for process {$from[self::NODE_ID]}" ) ; } if ( ! $ t... | Connect out to inport and compare data types . |
18,826 | private function trace ( string $ type ) : \ Closure { $ trace = function ( ) use ( $ type ) { switch ( $ type ) { case TraceableNetwork :: TYPE_DATA : $ this -> traceData ( func_get_args ( ) , $ type ) ; break ; case TraceableNetwork :: TYPE_CONNECT : case TraceableNetwork :: TYPE_DISCONNECT : $ this -> traceAction ( ... | Wrap the creation of the callback |
18,827 | private static function checkType ( string $ file ) : string { $ parts = explode ( '.' , $ file ) ; $ type = array_pop ( $ parts ) ; if ( ! in_array ( $ type , array_keys ( self :: $ types ) ) ) { throw new LoaderException ( "Loader::checkType(): Could not find parser for {$file}!" ) ; } return $ type ; } | Check file if extension matches a loader . |
18,828 | public function save ( string $ file ) : bool { $ stat = file_put_contents ( $ file , $ this -> definition -> toFbp ( ) ) ; if ( $ stat === false ) { return false ; } return true ; } | Save the graph json into the file . |
18,829 | public static function loadString ( string $ string ) : Graph { $ loader = new FbpParser ( $ string ) ; $ definition = $ loader -> run ( ) ; return self :: loadDefinition ( $ definition ) ; } | Load PhpFlo graph definition from string . |
18,830 | public static function loadDefinition ( DefinitionInterface $ definition ) : Graph { $ graph = new Graph ( $ definition ) ; foreach ( $ definition -> processes ( ) as $ id => $ def ) { $ graph -> addNode ( $ id , $ def [ Net :: COMPONENT ] ) ; } foreach ( $ definition -> initializers ( ) as $ initializer ) { $ graph ->... | Load PhpFlo graph definition . |
18,831 | private function hasValue ( array $ check , string $ value ) : bool { if ( empty ( $ check [ $ value ] ) ) { return false ; } return true ; } | Check if array has a specific key and is not empty . |
18,832 | private function examineProcess ( array $ process ) { if ( ! isset ( $ this -> definition [ self :: PROCESSES_LABEL ] [ $ process [ self :: PROCESS_LABEL ] ] ) ) { $ component = $ process [ self :: COMPONENT_LABEL ] ; if ( empty ( $ component ) ) { $ component = $ process [ self :: PROCESS_LABEL ] ; } $ this -> definit... | Add entry to processes . |
18,833 | private function addName ( string $ line ) { $ this -> definition [ self :: PROPERTIES_LABEL ] [ 'name' ] = trim ( str_replace ( '#' , '' , $ line ) ) ; } | Add name to definition |
18,834 | private function doSkip ( string $ line ) : bool { switch ( true ) { case ( empty ( trim ( $ line ) ) ) : $ skip = true ; break ; case ( 1 == preg_match ( '/(#[\s\w]+)/' , $ line ) ) : if ( 1 === $ this -> linecountOverall ) { $ this -> addName ( $ line ) ; } $ skip = true ; break ; default : $ skip = false ; } return ... | Check if line is empty or has comment . In case of comments add name to definition . |
18,835 | public static function isCompatible ( string $ fromType , string $ toType ) : bool { switch ( true ) { case ( ( $ fromType == $ toType ) || ( $ toType == 'all' || $ toType == 'bang' ) ) : $ isCompatible = true ; break ; case ( ( $ fromType == 'int' || $ fromType == 'integer' ) && $ toType == 'number' ) : $ isCompatible... | Compare in and outport datatypes . |
18,836 | private function prepareLogLevels ( string $ level ) { $ levels = [ LogLevel :: EMERGENCY , LogLevel :: ALERT , LogLevel :: CRITICAL , LogLevel :: ERROR , LogLevel :: WARNING , LogLevel :: NOTICE , LogLevel :: INFO , LogLevel :: DEBUG , ] ; $ key = array_search ( $ level , $ levels ) ; if ( null !== $ key ) { $ this ->... | Prepare log levels for logfile |
18,837 | private static function examineConnectionTouple ( array $ connectionTouple ) : string { self :: hasElement ( self :: SOURCE_LABEL , $ connectionTouple ) ; self :: hasElement ( self :: TARGET_LABEL , $ connectionTouple ) ; return self :: connectPorts ( self :: examineProcess ( self :: SOURCE_LABEL , $ connectionTouple [... | Look for all needed fields and build a port - > port connection . |
18,838 | public function grant ( $ addresses , $ permissions , $ nativeAmount = 0 , $ comment = '' , $ commentTo = '' , $ startBlock = 0 , $ endBlock = null ) { return $ this -> jsonRPCClient -> execute ( "grant" , array ( $ addresses , $ permissions , $ nativeAmount , $ comment , $ commentTo , $ startBlock , $ endBlock ) ) ; } | Grants permissions to addresses where addresses is a comma - separated list of addresses and permissions is one of connect send receive issue mine admin or a comma - separated list thereof . If the chain uses a native currency you can send some to each recipient using the native - amount parameter . Returns the txid of... |
18,839 | public function grantFrom ( $ fromAddress , $ toAddresses , $ permissions , $ nativeAmount = 0 , $ comment = '' , $ commentTo = '' , $ startBlock = 0 , $ endBlock = null ) { return $ this -> jsonRPCClient -> execute ( "grantfrom" , array ( $ fromAddress , $ toAddresses , $ permissions , $ nativeAmount , $ comment , $ c... | This works like grant but with control over the from - address used to grant the permissions . If there are multiple addresses with administrator permissions on one node this allows control over which address is used . |
18,840 | public function issueFrom ( $ fromAddress , $ toAddress , $ name , $ qty , $ units = 1 , $ nativeAmount = 0 , $ custom = null ) { return $ this -> jsonRPCClient -> execute ( "issuefrom" , array ( $ fromAddress , $ toAddress , $ name , $ qty , $ units , $ nativeAmount , $ custom ) ) ; } | This works like issue but with control over the from - address used to issue the asset . If there are multiple addresses with asset issuing permissions on one node this allows control over which address is used . |
18,841 | public function prepareLockUnspentFrom ( $ fromAddress , $ assetsToLock , $ lock = true ) { return $ this -> jsonRPCClient -> execute ( "preparelockunspentfrom" , array ( $ fromAddress , $ assetsToLock , $ lock ) ) ; } | This works like preparelockunspent but with control over the from - address whose funds are used to prepare the unspent transaction output . Any change from the transaction is send back to from - address . |
18,842 | public function revoke ( $ addresses , $ permissions , $ nativeAmount = 0 , $ comment = '' , $ commentTo = '' ) { return $ this -> jsonRPCClient -> execute ( "revoke" , array ( $ addresses , $ permissions , $ nativeAmount , $ comment , $ commentTo ) ) ; } | Revokes permissions from addresses where addresses is a comma - separated list of addresses and permissions is one of connect send receive issue mine admin or a comma - separated list thereof . Equivalent to calling grant with start - block = 0 and end - block = 0 . Returns the txid of transaction revoking the permissi... |
18,843 | public function revokeFrom ( $ fromAddress , $ toAddresses , $ permissions , $ nativeAmount = 0 , $ comment = '' , $ commentTo = '' ) { return $ this -> jsonRPCClient -> execute ( "revokefrom" , array ( $ fromAddress , $ toAddresses , $ permissions , $ nativeAmount , $ comment , $ commentTo ) ) ; } | This works like revoke but with control over the from - address used to revoke the permissions . If there are multiple addresses with administrator permissions on one node this allows control over which address is used . |
18,844 | public function sendAssetFrom ( $ fromAddress , $ toAddress , $ asset , $ qty , $ nativeAmount = null , $ comment = '' , $ commentTo = '' ) { $ nativeAmount = $ this -> findDefaultMinimumPerOutput ( $ nativeAmount ) ; return $ this -> jsonRPCClient -> execute ( "sendassetfrom" , array ( $ fromAddress , $ toAddress , $ ... | This works like sendassettoaddress but with control over the from - address whose funds are used . Any change from the transaction is sent back to from - address . See also sendfromaddress for sending multiple assets in one transaction . |
18,845 | public function sendFromAddress ( $ fromAddress , $ toAddress , $ amount , $ comment = '' , $ commentTo = '' ) { return $ this -> jsonRPCClient -> execute ( "sendfromaddress" , array ( $ fromAddress , $ toAddress , $ amount , $ comment , $ commentTo ) ) ; } | This works like sendtoaddress but with control over the from - address whose funds are used . Any change from the transaction is sent back to from - address . |
18,846 | public function getTxOut ( $ txId , $ vOut , $ unconfirmed = false ) { return $ this -> jsonRPCClient -> execute ( "gettxout" , array ( $ txId , $ vOut , $ unconfirmed ) ) ; } | Returns details about an unspent transaction output vout of txid . For a MultiChain blockchain includes assets and permissions fields listing any assets or permission changes encoded within the output . Set confirmed to true to include unconfirmed transaction outputs . |
18,847 | public function listUnspent ( $ minConf = 1 , $ maxConf = 999999 , $ addresses = null ) { return $ this -> jsonRPCClient -> execute ( "listunspent" , array ( $ minConf , $ maxConf , $ addresses ) ) ; } | Returns a list of unspent transaction outputs in the wallet with between minconf and maxconf confirmations . For a MultiChain blockchain each transaction output includes assets and permissions fields listing any assets or permission changes encoded within that output . If addresses is provided only outputs which pay an... |
18,848 | public function get ( string $ name = '' ) { switch ( true ) { case ( '' == $ name ) : $ result = $ this -> ports ; break ; case $ this -> has ( $ name ) : $ result = $ this -> ports [ $ name ] ; break ; default : throw new PortException ( "The port {$name} does not exist!" ) ; } return $ result ; } | Return one or all ports . |
18,849 | public function isAttached ( int $ socketId = 0 ) : bool { if ( ! isset ( $ this -> sockets [ $ socketId ] ) ) { return false ; } return true ; } | Checks if socket is attached . |
18,850 | public function override ( array $ configs ) { foreach ( $ configs as $ key => $ value ) { $ this -> config [ $ key ] = $ value ; } $ this -> flashConfig ( ) ; return $ this ; } | Override the default config value . |
18,851 | private function flashConfig ( ) { foreach ( $ this -> config as $ key => $ value ) { $ this -> session -> flash ( "notifier.{$key}" , $ value ) ; } $ this -> session -> flash ( 'notifier.notice' , $ this -> buildConfig ( ) ) ; } | Flash the configuration to the session |
18,852 | private function setDefaultConfig ( ) { $ defaults = $ this -> configRepo -> get ( 'laravelPnotify' ) ; foreach ( $ defaults as $ key => $ value ) { $ this -> config [ $ key ] = $ value ; } } | Set the default config values |
18,853 | public function pipe ( $ path , $ middleware = null ) { if ( null === $ middleware && is_callable ( $ path ) ) { $ middleware = $ path ; $ path = '/' ; } if ( ! is_callable ( $ middleware ) ) { throw new InvalidArgumentException ( 'Middleware must be callable' ) ; } $ this -> pipeline -> enqueue ( new Route ( $ this ->... | Attach middleware to the pipeline . |
18,854 | private function normalizePipePath ( $ path ) { if ( empty ( $ path ) || $ path [ 0 ] !== '/' ) { $ path = '/' . $ path ; } if ( strlen ( $ path ) > 1 && '/' === substr ( $ path , - 1 ) ) { $ path = rtrim ( $ path , '/' ) ; } return $ path ; } | Normalize a path used when defining a pipe |
18,855 | private function decorateRequest ( Request $ request ) { if ( $ request instanceof Http \ Request ) { return $ request ; } return new Http \ Request ( $ request ) ; } | Decorate the Request instance |
18,856 | private function decorateResponse ( Response $ response ) { if ( $ response instanceof Http \ Response ) { return $ response ; } return new Http \ Response ( $ response ) ; } | Decorate the Response instance |
18,857 | public function save ( $ force = false ) { if ( ! self :: $ _loaded ) { self :: _loadColumns ( ) ; } $ calling = get_called_class ( ) ; if ( ! self :: _checkCallback ( $ calling , "before_save" , $ this ) ) { return false ; } if ( ! $ this -> isValid ( ) ) { return false ; } $ pk = $ calling :: isIgnoringCase ( ) ? str... | Save or update currenct object |
18,858 | public function destroy ( ) { if ( ! self :: $ _loaded ) { self :: _loadColumns ( ) ; } $ calling = get_called_class ( ) ; if ( ! self :: _checkCallback ( $ calling , "before_destroy" , $ this ) ) { return false ; } $ table_name = $ calling :: getTableName ( ) ; $ pk = $ calling :: isIgnoringCase ( ) ? strtolower ( $ c... | Destroy the current object |
18,859 | public function updateAttributes ( $ attrs ) { if ( array_key_exists ( self :: getPK ( ) , $ attrs ) ) { unset ( $ attrs [ self :: getPK ( ) ] ) ; } foreach ( $ attrs as $ attr => $ value ) { $ this -> _data [ $ attr ] = $ value ; } return $ this -> save ( ) ; } | Update object attributes |
18,860 | public static function setConnection ( $ con , $ env = null ) { $ env = self :: selectEnvironment ( $ env ) ; self :: $ _connection [ $ env ] = $ con ; if ( in_array ( $ env , array ( "development" , "test" ) ) ) { self :: setErrorHandling ( \ PDO :: ERRMODE_EXCEPTION ) ; } } | Set the connection handle |
18,861 | public static function selectEnvironment ( $ env = null ) { if ( strlen ( $ env ) < 1 ) { $ getenv = self :: _getEnvironment ( ) ; if ( strlen ( $ getenv ) > 0 ) { $ env = $ getenv ; } else { $ env = "development" ; } } return $ env ; } | Return the current environment |
18,862 | public static function setDriver ( $ driver , $ env = null ) { $ file = realpath ( dirname ( __FILE__ ) . "/../drivers/$driver.php" ) ; if ( ! file_exists ( $ file ) ) { Log :: log ( "ERROR: Driver file $file does not exists" ) ; return null ; } self :: $ _driver [ self :: selectEnvironment ( $ env ) ] = $ driver ; inc... | Set the connection database driver |
18,863 | public static function convertToEncoding ( $ mixed ) { if ( is_null ( self :: $ _encoding ) || is_numeric ( $ mixed ) || is_bool ( $ mixed ) || is_object ( $ mixed ) || is_array ( $ mixed ) || ! is_string ( $ mixed ) || ! function_exists ( 'mb_convert_encoding' ) ) { return $ mixed ; } return \ mb_convert_encoding ( $ ... | Convert a string to the specified encoding Paranoid checking |
18,864 | public static function getArity ( $ callable ) { if ( is_object ( $ callable ) ) { foreach ( [ '__invoke' , 'handle' ] as $ method ) { if ( ! method_exists ( $ callable , $ method ) ) { continue ; } $ r = new ReflectionMethod ( $ callable , $ method ) ; return $ r -> getNumberOfRequiredParameters ( ) ; } return 0 ; } i... | Get the arity of a handler |
18,865 | public function isValid ( ) { $ this -> _resetErrors ( ) ; $ cls = get_called_class ( ) ; $ rtn = true ; $ pk = self :: get ( self :: getPK ( ) ) ; if ( ! array_key_exists ( $ cls , self :: $ _validations ) || sizeof ( self :: $ _validations [ $ cls ] ) < 1 ) { return true ; } foreach ( self :: $ _validations [ $ cls ]... | Check if object is valid |
18,866 | public static function isUnique ( $ id , $ attr , $ attr_value ) { $ obj = self :: first ( array ( $ attr => $ attr_value ) ) ; return $ obj == null || $ obj -> get ( self :: getPK ( ) ) == $ id ; } | Check if attribute is unique |
18,867 | public static function validates ( $ attr , $ validation ) { $ cls = get_called_class ( ) ; if ( ! array_key_exists ( $ cls , self :: $ _validations ) ) { self :: $ _validations [ $ cls ] = array ( ) ; } if ( ! array_key_exists ( $ attr , self :: $ _validations [ $ cls ] ) ) { self :: $ _validations [ $ cls ] [ $ attr ... | Validates an attribute with a validation rule |
18,868 | public function current ( ) { if ( $ this -> _curval == null ) { return $ this -> next ( ) ; } return new $ this -> _cls ( $ this -> _curval ) ; } | Return current value |
18,869 | public function count ( ) { $ cls = $ this -> _cls ; $ pk = $ cls :: getPK ( ) ; $ builder = $ this -> _makeBuilderForAggregations ( " count($pk) " ) ; return $ this -> _executeAndReturnFirst ( $ builder , $ this -> _vals ) ; } | Return collection row count |
18,870 | public function sum ( $ attr ) { $ builder = $ this -> _makeBuilderForAggregations ( " sum($attr) " ) ; return $ this -> _executeAndReturnFirst ( $ builder , $ this -> _vals ) ; } | Return collection attribute sum |
18,871 | public function avg ( $ attr ) { $ builder = $ this -> _makeBuilderForAggregations ( " avg($attr) " ) ; return $ this -> _executeAndReturnFirst ( $ builder , $ this -> _vals ) ; } | Return collection attribute average |
18,872 | public function min ( $ attr ) { $ builder = $ this -> _makeBuilderForAggregations ( " min($attr) " ) ; return $ this -> _executeAndReturnFirst ( $ builder , $ this -> _vals ) ; } | Return collection attribute minimum value |
18,873 | public function max ( $ attr ) { $ builder = $ this -> _makeBuilderForAggregations ( " max($attr) " ) ; return $ this -> _executeAndReturnFirst ( $ builder , $ this -> _vals ) ; } | Return collection attribute maximum value |
18,874 | public function paginate ( $ page , $ per_page = 50 ) { $ this -> _builder -> limit = $ per_page ; $ this -> _builder -> offset = ( $ page - 1 ) * $ per_page ; $ this -> page = $ page ; $ this -> per_page = $ per_page ; if ( Driver :: $ pagination_subquery ) { $ this -> _builder -> limit = $ this -> _builder -> offset ... | Return collection pagination page |
18,875 | private function _makeBuilderForAggregations ( $ fields ) { $ table = $ this -> _builder -> table ; $ where = $ this -> _builder -> where ; $ limit = $ this -> _builder -> limit ; $ offset = $ this -> _builder -> offset ; $ builder = new Builder ( ) ; $ builder -> prefix = "select" ; $ builder -> fields = $ fields ; $ ... | Construct builder for aggregations |
18,876 | private function _executeAndReturnFirst ( $ builder , $ vals ) { $ cls = $ this -> _cls ; $ stmt = $ cls :: executePrepared ( $ builder , $ this -> _vals ) ; $ data = $ stmt -> fetch ( ) ; return $ data ? $ data [ 0 ] : 0 ; } | Return the first value |
18,877 | public function destroy ( ) { $ table = $ this -> _builder -> table ; $ where = $ this -> _builder -> where ; $ builder = new Builder ( ) ; $ builder -> prefix = "delete" ; $ builder -> fields = "" ; $ builder -> table = $ table ; $ builder -> where = $ where ; $ cls = $ this -> _cls ; return $ cls :: executePrepared (... | Destroy collection records |
18,878 | public function updateAttributes ( $ attrs ) { $ cls = $ this -> _cls ; $ table = $ this -> _builder -> table ; $ where = $ this -> _builder -> where ; $ escape = Driver :: $ escape_char ; $ sql = "update $escape$table$escape set " ; $ sql .= $ cls :: extractUpdateColumns ( $ attrs , "," ) ; $ vals = $ cls :: extractWh... | Update collection attributes |
18,879 | private function _getCurrentData ( ) { $ cls = $ this -> _cls ; if ( ! $ this -> _data ) { $ this -> _data = $ cls :: executePrepared ( $ this -> _builder , $ this -> _vals ) ; } return $ this -> _data -> fetch ( \ PDO :: FETCH_ASSOC ) ; } | Get the next result from collection |
18,880 | public function next ( ) { $ cls = $ this -> _cls ; $ data = $ this -> _getCurrentData ( ) ; if ( ! $ data ) { $ this -> _curval = null ; return $ this -> _curval ; } else { ++ $ this -> _count ; $ this -> _curval = $ data ; return new $ this -> _cls ( $ this -> _curval ) ; } } | Return the next collection object |
18,881 | public static function push ( $ idx , $ singular , $ plural ) { self :: _initialize ( ) ; self :: $ _inflections [ $ idx ] [ $ singular ] = $ plural ; } | Push an inflection |
18,882 | private static function _search ( $ str , $ idx ) { self :: _initialize ( ) ; $ idx = $ idx == self :: PLURAL ? self :: SINGULAR : self :: PLURAL ; $ vals = self :: $ _inflections [ $ idx ] ; foreach ( self :: $ _inflections [ self :: IRREGULAR ] as $ key => $ val ) { $ vals [ $ key ] = $ val ; $ vals [ $ val ] = $ key... | Search an inflection |
18,883 | public function write ( $ data ) { if ( $ this -> complete ) { return $ this ; } $ this -> getBody ( ) -> write ( $ data ) ; return $ this ; } | Write data to the response body |
18,884 | public function end ( $ data = null ) { if ( $ this -> complete ) { return $ this ; } if ( $ data ) { $ this -> write ( $ data ) ; } $ new = clone $ this ; $ new -> complete = true ; return $ new ; } | Mark the response as complete |
18,885 | public static function getSequenceName ( ) { $ cls = get_called_class ( ) ; if ( ! array_key_exists ( $ cls , self :: $ _sequence ) ) { return null ; } return self :: $ _sequence [ $ cls ] ; } | Returns the sequence name if any |
18,886 | public static function resolveSequenceName ( ) { if ( Driver :: $ primary_key_behaviour != Driver :: PRIMARY_KEY_SEQUENCE ) { return null ; } $ name = self :: getSequenceName ( ) ; if ( $ name ) { return $ name ; } $ table = strtolower ( self :: getTableName ( ) ) ; $ pk = self :: getPK ( ) ; switch ( Driver :: $ name ... | Resolve the sequence name if any |
18,887 | private static function _sequenceExists ( ) { if ( Driver :: $ primary_key_behaviour != Driver :: PRIMARY_KEY_SEQUENCE ) { return null ; } $ cls = get_called_class ( ) ; $ name = self :: resolveSequenceName ( ) ; if ( array_key_exists ( $ cls , self :: $ _sequence_exists ) && array_key_exists ( $ name , self :: $ _sequ... | Check if a sequence exists |
18,888 | private function _oracleSequenceExists ( $ name ) { $ escape = Driver :: $ escape_char ; $ sql = "select count(sequence_name) as $escape" . "CNT" . "$escape from user_sequences where sequence_name='$name' or sequence_name='" . strtolower ( $ name ) . "' or sequence_name='" . strtoupper ( $ name ) . "'" ; $ stmt = self ... | Check if an Oracle sequence exists |
18,889 | private function _postgresqlSequenceExists ( $ name ) { $ escape = Driver :: $ escape_char ; $ sql = "select count(*) as {$escape}CNT{$escape} from information_schema.sequences where sequence_name = '$name'" ; $ stmt = self :: query ( $ sql ) ; $ rst = $ stmt -> fetch ( \ PDO :: FETCH_ASSOC ) ; $ rtn = intval ( $ rst [... | Check if an PostgreSQL sequence exists |
18,890 | private static function _checkSequence ( ) { if ( Driver :: $ primary_key_behaviour != Driver :: PRIMARY_KEY_SEQUENCE ) { return null ; } if ( self :: _sequenceExists ( ) ) { return ; } switch ( Driver :: $ name ) { case "oracle" : self :: _createOracleSequence ( ) ; break ; case "postgresql" : self :: _createPostgresq... | Create a sequence if not exists |
18,891 | private static function _createOracleSequence ( ) { $ name = self :: resolveSequenceName ( ) ; $ sql = "create sequence $name increment by 1 start with 1 nocycle nocache" ; Log :: log ( $ sql ) ; $ stmt = self :: query ( $ sql ) ; self :: closeCursor ( $ stmt ) ; } | Create an Oracle sequence |
18,892 | public static function sequenceNextVal ( $ name ) { $ sql = null ; switch ( Driver :: $ name ) { case "oracle" : $ sql = "select $name.nextval from dual" ; break ; case "postgresql" : $ sql = "select nextval('$name') as nextval" ; break ; } if ( $ sql == null ) { return null ; } $ stmt = self :: executePrepared ( $ sql... | Get the next value from a sequence |
18,893 | private function resetPath ( Http \ Request $ request ) { if ( ! $ this -> removed ) { return $ request ; } $ uri = $ request -> getUri ( ) ; $ path = $ uri -> getPath ( ) ; if ( strlen ( $ path ) >= strlen ( $ this -> removed ) && 0 === strpos ( $ path , $ this -> removed ) ) { $ path = str_replace ( $ this -> removed... | Reset the path if a segment was previously stripped |
18,894 | private function getBorder ( $ path , $ route ) { $ border = ( strlen ( $ path ) > strlen ( $ route ) ) ? $ path [ strlen ( $ route ) ] : '' ; $ border = ( $ route === '/' ) ? '/' : $ border ; return $ border ; } | Determine the border between the request path and current route |
18,895 | private function stripRouteFromPath ( Http \ Request $ request , $ route ) { $ this -> removed = $ route ; $ uri = $ request -> getUri ( ) ; $ path = $ this -> getTruncatedPath ( $ route , $ uri -> getPath ( ) ) ; $ new = $ uri -> withPath ( $ path ) ; if ( $ path === '/' && '/' === substr ( $ uri -> getPath ( ) , - 1 ... | Strip the route from the request path |
18,896 | private function getTruncatedPath ( $ segment , $ path ) { if ( $ path === $ segment ) { return '' ; } $ segmentLength = strlen ( $ segment ) ; if ( strlen ( $ path ) > $ segmentLength ) { return substr ( $ path , $ segmentLength ) ; } if ( '/' === substr ( $ segment , - 1 ) ) { return $ this -> getTruncatedPath ( rtri... | Strip the segment from the start of the given path . |
18,897 | public static function presence ( $ cls , $ id , $ attr , $ attr_value , $ validation_value , $ options ) { if ( ! $ validation_value ) { return true ; } return strlen ( trim ( $ attr_value ) ) > 0 ; } | Check if an attribute is present |
18,898 | public static function format ( $ cls , $ id , $ attr , $ attr_value , $ validation_value , $ options ) { if ( ! is_null ( $ options ) && array_key_exists ( "allow_blank" , $ options ) && strlen ( trim ( $ attr_value ) ) < 1 ) { return true ; } if ( ! is_null ( $ options ) && array_key_exists ( "allow_null" , $ options... | Check if an attribute format is ok |
18,899 | public static function uniqueness ( $ cls , $ id , $ attr , $ attr_value , $ validation_value , $ options ) { if ( ! is_null ( $ options ) && array_key_exists ( "allow_null" , $ options ) && is_null ( $ attr_value ) ) { return true ; } if ( ! is_null ( $ options ) && array_key_exists ( "allow_blank" , $ options ) && st... | Check if an attribute is unique |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.