idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
41,800 | protected function returnException ( Exception $ e ) { $ key = snake_case ( class_basename ( $ e ) ) ; $ message = $ this -> translate ( $ key , $ e -> getMessage ( ) ) ; return new ExceptionReply ( $ message , [ ] , $ e ) ; } | Return any caught exceptions in a ExceptionDispatch DTO |
41,801 | protected function translate ( $ key , $ message ) { $ key = 'centaur.' . $ key ; if ( Lang :: has ( $ key ) ) { $ message = trans ( $ key ) ; } return $ message ; } | Helper method for facilitating string translation |
41,802 | public static function pluralIdentifyingRootField ( array $ config ) { $ inputArgs = [ ] ; $ argName = self :: getArrayValue ( $ config , 'argName' ) ; $ inputArgs [ $ argName ] = [ 'type' => Type :: nonNull ( Type :: listOf ( Type :: nonNull ( self :: getArrayValue ( $ config , 'inputType' ) ) ) ) ] ; return [ 'descri... | Returns configuration for Plural identifying root field |
41,803 | public static function createConnectionType ( array $ config ) { if ( ! array_key_exists ( 'nodeType' , $ config ) ) { throw new \ InvalidArgumentException ( 'Connection config needs to have at least a node definition' ) ; } $ nodeType = $ config [ 'nodeType' ] ; $ name = array_key_exists ( 'name' , $ config ) ? $ conf... | Returns a GraphQLObjectType for a connection with the given name and whose nodes are of the specified type . |
41,804 | public static function createEdgeType ( array $ config ) { if ( ! array_key_exists ( 'nodeType' , $ config ) ) { throw new \ InvalidArgumentException ( 'Edge config needs to have at least a node definition' ) ; } $ nodeType = $ config [ 'nodeType' ] ; $ name = array_key_exists ( 'name' , $ config ) ? $ config [ 'name' ... | Returns a GraphQLObjectType for an edge with the given name and whose nodes are of the specified type . |
41,805 | public static function pageInfoType ( ) { if ( self :: $ pageInfoType === null ) { self :: $ pageInfoType = new ObjectType ( [ 'name' => 'PageInfo' , 'description' => 'Information about pagination in a connection.' , 'fields' => [ 'hasNextPage' => [ 'type' => Type :: nonNull ( Type :: boolean ( ) ) , 'description' => '... | The common page info type used by all connections . |
41,806 | public static function nodeDefinitions ( callable $ idFetcher , callable $ typeResolver = null ) { $ nodeInterface = new InterfaceType ( [ 'name' => 'Node' , 'description' => 'An object with an ID' , 'fields' => [ 'id' => [ 'type' => Type :: nonNull ( Type :: id ( ) ) , 'description' => 'The id of the object' , ] ] , '... | Given a function to map from an ID to an underlying object and a function to map from an underlying object to the concrete GraphQLObjectType it corresponds to constructs a Node interface that objects can implement and a field config for a node root field . |
41,807 | public static function cursorToOffset ( $ cursor ) { $ offset = substr ( base64_decode ( $ cursor ) , strlen ( self :: PREFIX ) ) ; if ( is_numeric ( $ offset ) ) { return intval ( $ offset ) ; } else { return null ; } } | Rederives the offset from the cursor string . |
41,808 | public static function mutationWithClientMutationId ( array $ config ) { $ name = self :: getArrayValue ( $ config , 'name' ) ; $ inputFields = self :: getArrayValue ( $ config , 'inputFields' ) ; $ outputFields = self :: getArrayValue ( $ config , 'outputFields' ) ; $ mutateAndGetPayload = self :: getArrayValue ( $ co... | Returns a GraphQLFieldConfig for the mutation described by the provided MutationConfig . |
41,809 | public function create ( $ type , $ set , $ sku , $ productData , $ storeView = null ) { return $ this -> __createAction ( 'catalog_product.create' , func_get_args ( ) ) ; } | Allows you to create a new product and return ID of the created product . |
41,810 | public function setSpecialPrice ( $ productId , $ specialPrice , $ fromDate , $ toDate , $ storeView = null , $ productIdentifierType = null ) { return $ this -> __createAction ( 'catalog_product.setSpecialPrice' , func_get_args ( ) ) ; } | Allows you to set the product special price . |
41,811 | public function update ( $ productId , $ productData , $ storeView = null , $ identifierType = null ) { return $ this -> __createAction ( 'catalog_product.update' , func_get_args ( ) ) ; } | Allows you to update the required product . Note that you should specify only those parameters which you want to be updated . |
41,812 | public function addComment ( $ shipmentIncrementId , $ comment = null , $ email = null , $ includeInEmail = null ) { return $ this -> __createAction ( 'order_shipment.addComment' , func_get_args ( ) ) ; } | Allows you to add a new comment to the order shipment . |
41,813 | public function create ( $ orderIncrementId , $ itemsQty = null , $ comment = null , $ email = null , $ includeComment = null ) { return $ this -> __createAction ( 'order_shipment.create' , func_get_args ( ) ) ; } | Allows you to create a new shipment for an order . |
41,814 | public function add ( $ productId , $ resource , $ resourceType , $ store = null , $ identifierType = null ) { return $ this -> __createAction ( 'product_downloadable_link.add' , func_get_args ( ) ) ; } | Allows you to add a new link to a downloadable product . |
41,815 | public function attributeAdd ( $ attributeId , $ attributeSetId , $ attributeGroupId = null , $ sortOrder = null ) { return $ this -> __createAction ( 'product_attribute_set.attributeAdd' , func_get_args ( ) ) ; } | Allows you to add an existing attribute to an attribute set . |
41,816 | public function addComment ( $ creditmemoIncrementId , $ comment = null , $ notifyCustomer = null , $ includeComment = null ) { return $ this -> __createAction ( 'order_creditmemo.addComment' , func_get_args ( ) ) ; } | Allows you to add a new comment to an existing credit memo . Email notification can be sent to the user email . |
41,817 | public function create ( $ orderIncrementId , $ creditmemoData = null , $ comment = null , $ notifyCustomer = null , $ includeComment = null , $ refundToStoreCreditAmount = null ) { return $ this -> __createAction ( 'order_creditmemo.create' , func_get_args ( ) ) ; } | Allows you to create a new credit memo for the invoiced order . Comments can be added and an email notification can be sent to the user email . |
41,818 | public function addComment ( $ invoiceIncrementId , $ comment = null , $ email = null , $ includeComment = null ) { return $ this -> __createAction ( 'order_invoice.addComment' , func_get_args ( ) ) ; } | Allows you to add a new comment to the order invoice . |
41,819 | public function assignProduct ( $ categoryId , $ productId , $ position = null , $ identifierType = null ) { return $ this -> __createAction ( 'catalog_category.assignProduct' , func_get_args ( ) ) ; } | Assign a product to the required category . |
41,820 | public function update ( $ type , $ productId , $ linkedProductId , $ data , $ identifierType = null ) { return $ this -> __createAction ( 'catalog_product_link.update' , func_get_args ( ) ) ; } | Allows you to update the product link . |
41,821 | protected function addCell ( $ text , $ wrap = [ '' , '' ] ) { if ( $ this -> currentRow === null ) { $ this -> row ( ) ; } $ i = count ( $ this -> currentRow ) ; $ this -> columnWidths [ $ i ] = max ( strlen ( $ text ) , Cli :: val ( $ i , $ this -> columnWidths , 0 ) ) ; $ this -> currentRow [ $ i ] = [ $ text , $ wr... | Add a cell to the table . |
41,822 | public function row ( ) { $ this -> rows [ ] = [ ] ; $ this -> currentRow = & $ this -> rows [ count ( $ this -> rows ) - 1 ] ; return $ this ; } | Start a new row . |
41,823 | public function write ( ) { $ columnWidths = array_sum ( $ this -> columnWidths ) ; $ totalWidth = $ this -> indent + $ columnWidths + $ this -> padding * ( count ( $ this -> columnWidths ) - 1 ) ; $ lastWidth = end ( $ this -> columnWidths ) + $ this -> maxWidth - $ totalWidth ; $ lastWidth = max ( $ lastWidth , 10 ) ... | Writes the final table . |
41,824 | public static function breakLines ( $ text , $ width , $ addSpaces = true ) { $ rawLines = explode ( "\n" , $ text ) ; $ lines = [ ] ; foreach ( $ rawLines as $ line ) { $ sublines = static :: breakString ( $ line , $ width , $ addSpaces ) ; $ lines = array_merge ( $ lines , $ sublines ) ; } return $ lines ; } | Breaks a cell into several lines according to a given width . |
41,825 | protected static function breakString ( $ line , $ width , $ addSpaces = true ) { $ words = explode ( ' ' , $ line ) ; $ result = [ ] ; $ line = '' ; foreach ( $ words as $ word ) { $ candidate = trim ( $ line . ' ' . $ word ) ; if ( strlen ( $ candidate ) > $ width ) { if ( $ line === '' ) { if ( $ addSpaces ) { $ res... | Breaks a line of text according to a given width . |
41,826 | public function hasCommand ( $ name = '' ) { if ( $ name ) { return array_key_exists ( $ name , $ this -> commandSchemas ) ; } else { foreach ( $ this -> commandSchemas as $ pattern => $ opts ) { if ( strpos ( $ pattern , '*' ) === false ) { return true ; } } return false ; } } | Determines whether or not the schema has a command . |
41,827 | public function hasOptions ( $ command = '' ) { if ( $ command ) { $ def = $ this -> getSchema ( $ command ) ; return $ this -> hasOptionsDef ( $ def ) ; } else { foreach ( $ this -> commandSchemas as $ pattern => $ def ) { if ( $ this -> hasOptionsDef ( $ def ) ) { return true ; } } } return false ; } | Determines whether a command has options . |
41,828 | protected function hasOptionsDef ( $ commandDef ) { return count ( $ commandDef ) > 1 || ( count ( $ commandDef ) > 0 && ! isset ( $ commandDef [ Cli :: META ] ) ) ; } | Determines whether or not a command definition has options . |
41,829 | public function hasArgs ( $ command = '' ) { $ args = null ; if ( $ command ) { $ def = $ this -> getSchema ( $ command ) ; if ( isset ( $ def [ Cli :: META ] [ Cli :: ARGS ] ) ) { $ args = $ def [ Cli :: META ] [ Cli :: ARGS ] ; } } else { foreach ( $ this -> commandSchemas as $ pattern => $ def ) { if ( isset ( $ def... | Determines whether or not a command has args . |
41,830 | public function parse ( $ argv = null , $ exit = true ) { $ formatOutputBak = $ this -> formatOutput ; if ( ! $ exit ) { $ this -> formatOutput = false ; } if ( ! $ exit ) { ob_start ( ) ; } $ args = $ this -> parseRaw ( $ argv ) ; $ hasCommand = $ this -> hasCommand ( ) ; if ( $ hasCommand && ! $ args -> getCommand ( ... | Parses and validates a set of command line arguments the schema . |
41,831 | public function getSchema ( $ command = '' ) { $ result = [ ] ; foreach ( $ this -> commandSchemas as $ pattern => $ opts ) { if ( fnmatch ( $ pattern , $ command ) ) { $ result = array_replace_recursive ( $ result , $ opts ) ; } } return $ result ; } | Gets the full cli schema . |
41,832 | public function arg ( $ name , $ description , $ required = false ) { $ this -> currentSchema [ Cli :: META ] [ Cli :: ARGS ] [ $ name ] = [ 'description' => $ description , 'required' => $ required ] ; return $ this ; } | Define an arg on the current command . |
41,833 | public function command ( $ pattern ) { if ( ! isset ( $ this -> commandSchemas [ $ pattern ] ) ) { $ this -> commandSchemas [ $ pattern ] = [ Cli :: META => [ ] ] ; } $ this -> currentSchema = & $ this -> commandSchemas [ $ pattern ] ; return $ this ; } | Selects the current command schema name . |
41,834 | protected function isStrictBoolean ( $ value , & $ boolValue = null ) { if ( $ value === true || $ value === false ) { $ boolValue = $ value ; return true ; } elseif ( in_array ( $ value , [ '0' , 'false' , 'off' , 'no' ] ) ) { $ boolValue = false ; return true ; } elseif ( in_array ( $ value , [ '1' , 'true' , 'on' , ... | Determine weather or not a value can be represented as a boolean . |
41,835 | public function schema ( array $ schema ) { $ parsed = static :: parseSchema ( $ schema ) ; $ this -> currentSchema = array_replace ( $ this -> currentSchema , $ parsed ) ; } | Set the schema for a command . |
41,836 | public static function guessFormatOutput ( $ stream = STDOUT ) { if ( defined ( 'PHP_WINDOWS_VERSION_MAJOR' ) ) { return false ; } elseif ( function_exists ( 'posix_isatty' ) ) { try { return @ posix_isatty ( $ stream ) ; } catch ( \ Throwable $ ex ) { return false ; } } else { return true ; } } | Guess whether or not to format the output with colors . |
41,837 | protected function validateType ( & $ value , $ type , $ name = '' , $ def = null ) { switch ( $ type ) { case 'boolean' : if ( is_bool ( $ value ) ) { $ valid = true ; } elseif ( $ value === 0 ) { $ value = false ; $ valid = true ; } elseif ( in_array ( $ value , [ null , '' , '0' , 'false' , 'no' , 'disabled' ] ) ) {... | Validate the type of a value and coerce it into the proper type . |
41,838 | protected function writeCommands ( ) { echo static :: bold ( "COMMANDS" ) . PHP_EOL ; $ table = new Table ( ) ; foreach ( $ this -> commandSchemas as $ pattern => $ schema ) { if ( static :: isCommand ( $ pattern ) ) { $ table -> row ( ) -> cell ( $ pattern ) -> cell ( Cli :: val ( 'description' , Cli :: val ( Cli :: M... | Writes a lis of all of the commands . |
41,839 | protected function writeSchemaHelp ( $ schema ) { $ meta = Cli :: val ( Cli :: META , $ schema , [ ] ) ; $ description = Cli :: val ( 'description' , $ meta ) ; if ( $ description ) { echo implode ( "\n" , Cli :: breakLines ( $ description , 80 , false ) ) . PHP_EOL . PHP_EOL ; } unset ( $ schema [ Cli :: META ] ) ; $ ... | Writes the help for a given schema . |
41,840 | protected function writeUsage ( Args $ args ) { if ( $ filename = $ args -> getMeta ( 'filename' ) ) { $ schema = $ this -> getSchema ( $ args -> getCommand ( ) ) ; unset ( $ schema [ Cli :: META ] ) ; echo static :: bold ( "usage: " ) . $ filename ; if ( $ this -> hasCommand ( ) ) { if ( $ args -> getCommand ( ) && is... | Writes the basic usage information of the command . |
41,841 | public function beginDebug ( string $ message , array $ context = [ ] ) { return $ this -> begin ( LogLevel :: DEBUG , $ message , $ context ) ; } | Output a debug message that designates the beginning of a task . |
41,842 | private function compareLevel ( string $ a , string $ b ) : int { $ i = array_search ( $ a , static :: $ levels ) ; if ( $ i === false ) { throw new InvalidArgumentException ( "Log level is invalid: $a" , 500 ) ; } return $ i <=> array_search ( $ b , static :: $ levels ) ; } | Compare two log levels . |
41,843 | private function outputTaskStack ( ) { foreach ( $ this -> taskStack as $ indent => & $ task ) { list ( $ taskLevel , $ taskMessage , $ taskContext , $ taskOutput ) = $ task ; if ( ! $ taskOutput ) { $ this -> logInternal ( $ taskLevel , $ taskMessage , [ self :: FIELD_INDENT => $ indent ] + $ taskContext ) ; $ task [ ... | Output the task stack . |
41,844 | private function logInternal ( string $ level , string $ message , array $ context = [ ] ) { $ context = $ context + [ self :: FIELD_INDENT => $ this -> currentIndent ( ) , self :: FIELD_TIME => microtime ( true ) ] ; $ this -> logger -> log ( $ level , $ message , $ context ) ; } | Internal log implementation with less error checking . |
41,845 | public function beginInfo ( string $ message , array $ context = [ ] ) { return $ this -> begin ( LogLevel :: INFO , $ message , $ context ) ; } | Output an info message that designates the beginning of a task . |
41,846 | public function beginNotice ( string $ message , array $ context = [ ] ) { return $ this -> begin ( LogLevel :: NOTICE , $ message , $ context ) ; } | Output a notice message that designates the beginning of a task . |
41,847 | public function beginWarning ( string $ message , array $ context = [ ] ) { return $ this -> begin ( LogLevel :: WARNING , $ message , $ context ) ; } | Output a warning message that designates the beginning of a task . |
41,848 | public function beginError ( string $ message , array $ context = [ ] ) { return $ this -> begin ( LogLevel :: ERROR , $ message , $ context ) ; } | Output an error message that designates the beginning of a task . |
41,849 | public function beginCritical ( string $ message , array $ context = [ ] ) { return $ this -> begin ( LogLevel :: CRITICAL , $ message , $ context ) ; } | Output a critical message that designates the beginning of a task . |
41,850 | public function beginAlert ( string $ message , array $ context = [ ] ) { return $ this -> begin ( LogLevel :: ALERT , $ message , $ context ) ; } | Output an alert message that designates the beginning of a task . |
41,851 | public function beginEmergency ( string $ message , array $ context = [ ] ) { return $ this -> begin ( LogLevel :: EMERGENCY , $ message , $ context ) ; } | Output an emergency message that designates the beginning of a task . |
41,852 | public function endError ( string $ message , array $ context = [ ] ) { return $ this -> end ( $ message , [ self :: FIELD_LEVEL => LogLevel :: ERROR ] + $ context ) ; } | Output a message that represents a task being completed in an error . |
41,853 | public function addArg ( $ value , $ index = null ) { if ( $ index !== null ) { $ this -> args [ $ index ] = $ value ; } else { $ this -> args [ ] = $ value ; } return $ this ; } | Add an argument to the args array . |
41,854 | public function getArg ( $ index , $ default = null ) { if ( array_key_exists ( $ index , $ this -> args ) ) { return $ this -> args [ $ index ] ; } elseif ( is_int ( $ index ) ) { $ values = array_values ( $ this -> args ) ; if ( array_key_exists ( $ index , $ values ) ) { return $ values [ $ index ] ; } } return $ de... | Get an argument at a given index . |
41,855 | public function setTimeFormat ( $ format ) { if ( is_string ( $ format ) ) { $ this -> timeFormatter = function ( $ t ) use ( $ format ) { return strftime ( $ format , $ t ) ; } ; } else { $ this -> timeFormatter = $ format ; } return $ this ; } | Set the time formatter . |
41,856 | private function replaceContext ( string $ format , array $ context ) : string { $ msg = preg_replace_callback ( '`({[^\s{}]+})`' , function ( $ m ) use ( $ context ) { $ field = trim ( $ m [ 1 ] , '{}' ) ; if ( array_key_exists ( $ field , $ context ) ) { return $ context [ $ field ] ; } else { return $ m [ 1 ] ; } } ... | Replace a message format with context information . |
41,857 | public function setEol ( string $ eol ) { if ( strpos ( $ eol , "\n" ) === false ) { throw new \ InvalidArgumentException ( 'The EOL must include the "\n" character."' , 500 ) ; } $ this -> eol = $ eol ; return $ this ; } | Set the end of line string . |
41,858 | protected function normalize ( $ path , $ timestamp , $ content = null ) { $ data = [ 'path' => $ path , 'timestamp' => ( int ) $ timestamp , 'dirname' => Util :: dirname ( $ path ) , 'type' => 'file' , ] ; if ( is_string ( $ content ) ) { $ data [ 'contents' ] = $ content ; } return $ data ; } | Builds the normalized output array . |
41,859 | protected function normalizeBlobProperties ( $ path , BlobProperties $ properties ) { if ( substr ( $ path , - 1 ) === '/' ) { return [ 'type' => 'dir' , 'path' => $ this -> removePathPrefix ( rtrim ( $ path , '/' ) ) ] ; } $ path = $ this -> removePathPrefix ( $ path ) ; return [ 'path' => $ path , 'timestamp' => ( in... | Builds the normalized output array from a Blob object . |
41,860 | protected function getOptionsFromConfig ( Config $ config ) { $ options = new CreateBlobOptions ( ) ; foreach ( static :: $ metaOptions as $ option ) { if ( ! $ config -> has ( $ option ) ) { continue ; } call_user_func ( [ $ options , "set$option" ] , $ config -> get ( $ option ) ) ; } if ( $ mimetype = $ config -> ge... | Retrieve options from a Config instance . |
41,861 | public function endSuccess ( $ str , $ force = false ) { return $ this -> end ( $ this -> formatString ( $ str , [ "\033[1;32m" , "\033[0m" ] ) , $ force ) ; } | Output a message that represents a task being completed in success . |
41,862 | protected function messageStr ( $ str , $ eol = true ) { return $ this -> fullMessageStr ( time ( ) , $ str , null , $ eol ) ; } | Create a message string . |
41,863 | public function write ( $ str ) { if ( feof ( $ this -> outputHandle ) ) { trigger_error ( 'Called LogFormatter::write() but file handle was closed.' , E_USER_WARNING ) ; return ; } fwrite ( $ this -> outputHandle , $ str ) ; } | Write a string to the CLI . |
41,864 | public function scopeOfUser ( Builder $ builder , Model $ user ) : Builder { return $ builder -> where ( 'user_type' , $ user -> getMorphClass ( ) ) -> where ( 'user_id' , $ user -> getKey ( ) ) ; } | Get form responses of the given user . |
41,865 | protected function buildStrategy ( $ strategy ) { if ( is_string ( $ strategy ) && array_key_exists ( $ strategy , $ this -> strategies ) ) { return new $ this -> strategies [ $ strategy ] ; } if ( is_callable ( $ strategy ) ) { return $ strategy ; } if ( is_int ( $ strategy ) ) { return new ConstantStrategy ( $ strate... | Builds a callable strategy . |
41,866 | protected function getDefaultDecider ( ) { return function ( $ retry , $ maxAttempts , $ result = null , $ exception = null ) { if ( $ retry >= $ maxAttempts && ! is_null ( $ exception ) ) { throw $ exception ; } return $ retry < $ maxAttempts && ! is_null ( $ exception ) ; } ; } | Gets a default decider that simply check exceptions and maxattempts |
41,867 | protected function computeJwt ( ) { $ payload = [ 'iss' => $ this -> getConfig ( 'client_id' ) , 'aud' => rtrim ( $ this -> getConfig ( 'base_uri' ) , '/' ) , 'exp' => time ( ) + 60 * 60 , 'iat' => time ( ) , 'sub' => '' , ] ; if ( isset ( $ this -> config [ 'jwt_payload' ] ) && is_array ( $ this -> config [ 'jwt_paylo... | Compute JWT signing with provided private key . |
41,868 | protected function returnHandlers ( ) { $ handler = HandlerStack :: create ( ) ; $ handler -> push ( Middleware :: mapRequest ( function ( RequestInterface $ request ) { if ( $ this -> getConfig ( 'auth' ) == 'oauth2' ) { $ token = $ this -> getAccessToken ( ) ; if ( $ token !== null ) { $ request = $ request -> withHe... | Set the middleware handlers for all requests using Oauth2 . |
41,869 | public function retry_modify_request ( callable $ decider , callable $ requestModifier , callable $ delay = null ) { return function ( callable $ handler ) use ( $ decider , $ requestModifier , $ delay ) { return new RetryModifyRequestMiddleware ( $ decider , $ requestModifier , $ handler , $ delay ) ; } ; } | Retry Call after updating access token . |
41,870 | public function getAccessToken ( ) { if ( $ this -> accessToken && $ this -> accessToken -> isExpired ( ) ) { $ this -> accessToken = null ; } if ( null === $ this -> accessToken ) { $ this -> accessToken = $ this -> acquireAccessToken ( ) ; if ( $ this -> accessToken ) { $ this -> refreshToken = $ this -> accessToken ... | Get the access token . |
41,871 | private function addGroup ( $ group ) { if ( $ group != null ) { if ( $ this -> groups == null ) $ this -> groups = array ( ) ; $ this -> groups [ ] = $ group ; } } | Adds a Group instance as a sub - group of this group . |
41,872 | private function addEntry ( $ entry ) { if ( $ entry != null ) { if ( $ this -> entries == null ) $ this -> entries = array ( ) ; $ this -> entries [ ] = $ entry ; } } | Adds an Entry instance to this group . |
41,873 | public static function loadFromXML ( ProtectedXMLReader $ reader ) { if ( $ reader == null ) return null ; $ group = new Group ( ) ; $ d = $ reader -> depth ( ) ; while ( $ reader -> read ( $ d ) ) { if ( $ reader -> isElement ( Database :: XML_GROUP ) ) $ group -> addGroup ( Group :: loadFromXML ( $ reader ) ) ; elsei... | Creates a new Group instance from a ProtectedXMLReader instance reading a KeePass 2 . x database and located at a Group element node . |
41,874 | public static function create ( $ key , $ iv ) { if ( strlen ( $ key ) != self :: KEY_LEN || strlen ( $ iv ) != self :: IV_LEN ) return null ; return new Salsa20Stream ( $ key , $ iv ) ; } | Creates a new Salsa20Stream instance . |
41,875 | public static function createFromDatabase ( Database $ db , $ dbFileHash , $ keyFileHash ) { return new KphpDB ( self :: DBTYPE_KDBX , $ db , $ dbFileHash , $ keyFileHash ) ; } | Creates a new KphpDB instance that wraps a Database instance . |
41,876 | public function toJSon ( $ filter , & $ error ) { $ array = array ( self :: KEY_VERSION => self :: VERSION_CURRENT , self :: KEY_DBTYPE => $ this -> _dbType , self :: KEY_DBFILEHASH => $ this -> _dbFileHash , self :: KEY_KEYFILEHASH => $ this -> _keyFileHash , self :: KEY_HEADERHASH => base64_encode ( $ this -> _header... | Serializes this instance to a JSon string . |
41,877 | public function toKdbx ( iKey $ key , $ filter , & $ error ) { $ kdbx = KdbxFile :: createForEncrypting ( self :: ROUNDS , $ error ) ; if ( $ kdbx == null ) return null ; $ this -> _headerHash = $ kdbx -> getHeaderHash ( ) ; $ json = $ this -> toJSon ( $ filter , $ error ) ; if ( empty ( $ json ) ) return null ; return... | Serializes this instance to a JSon string and encrypts it in a kdbx file . |
41,878 | public function readTextInside ( $ asProtectedString = false ) { if ( $ this -> _state != self :: GO_ON || $ this -> r -> isEmptyElement ) return null ; $ isProtected = $ this -> r -> hasAttributes && $ this -> r -> getAttribute ( self :: XML_ATTR_PROTECTED ) == self :: XML_ATTR_TRUE ; if ( ! @ $ this -> r -> read ( ) ... | Reads the text content of the current Element node . |
41,879 | private function addGroup ( $ group ) { if ( $ group != null ) { if ( $ this -> _groups == null ) $ this -> _groups = array ( ) ; $ this -> _groups [ ] = $ group ; } } | Adds a Group instance to this Database . |
41,880 | private function parseXML ( ProtectedXMLReader $ reader ) { $ d = $ reader -> depth ( ) ; while ( $ reader -> read ( $ d ) ) { if ( $ reader -> isElement ( self :: XML_META ) ) { $ metaD = $ reader -> depth ( ) ; while ( $ reader -> read ( $ metaD ) ) { if ( $ reader -> isElement ( self :: XML_HEADERHASH ) ) $ this -> ... | Loads the content of a Database from a ProtectedXMLReader instance reading a KeePass 2 . x database and located at a KeePass file element node . |
41,881 | public static function loadFromXML ( $ xml , iRandomStream $ randomStream , & $ error ) { $ reader = new ProtectedXMLReader ( $ randomStream ) ; if ( ! $ reader -> XML ( $ xml ) || ! $ reader -> read ( - 1 ) ) { $ error = "Database XML load: cannot parse the XML string." ; $ reader -> close ( ) ; return null ; } if ( !... | Creates a new Database instance from an XML string with the format of a KeePass 2 . x database . |
41,882 | public static function extractHalfPassword ( $ pwd ) { $ l = strlen ( $ pwd ) ; if ( $ l < 4 ) return $ pwd ; else return substr ( $ pwd , 0 , intval ( floor ( $ l / 2 ) ) ) ; } | Extracts a subpart of the input string if it long enough . |
41,883 | public static function addPassword ( CompositeKey $ mkey , $ pwd ) { $ mkey -> addKey ( self :: keyFromPassword ( $ pwd ) ) ; return true ; } | Adds a password to a master key . |
41,884 | public static function addKeyFile ( CompositeKey $ mkey , $ file ) { if ( empty ( $ file ) ) return true ; $ k = new KeyFromFile ( file_get_contents ( $ file ) ) ; if ( ! $ k -> isParsed ) return false ; $ mkey -> addKey ( $ k ) ; return true ; } | Adds a file key to a master key . |
41,885 | public function setMethod ( $ method ) { parent :: setMethod ( $ method ) ; $ method = strtolower ( $ method ) ; if ( $ method == "aes-256-ecb" ) { $ this -> _type = MCRYPT_RIJNDAEL_128 ; $ this -> _mode = "ecb" ; } elseif ( $ method == "aes-256-cbc" ) { $ this -> _type = MCRYPT_RIJNDAEL_128 ; $ this -> _mode = "cbc" ;... | Sets the cipher method to use . |
41,886 | private function load ( ) { if ( strlen ( $ this -> _method ) == 0 || strlen ( $ this -> _key ) == 0 ) return null ; $ m = mcrypt_module_open ( $ this -> _type , '' , $ this -> _mode , '' ) ; if ( $ m === false ) return null ; $ ivsize = mcrypt_enc_get_iv_size ( $ m ) ; if ( strlen ( $ this -> _iv ) != $ ivsize ) { if ... | Opens a mcrypt module . |
41,887 | public function toBinary ( $ hashAlgo ) { $ s = self :: SIGNATURE1 . self :: SIGNATURE2 . self :: VERSION . self :: fieldToString ( 2 , $ this -> cipher ) . self :: fieldToString ( 3 , $ this -> compression == self :: COMPRESSION_GZIP ? self :: INT_1 : self :: INT_0 ) . self :: fieldToString ( 4 , $ this -> masterSeed ... | Gets the binary format of this Header instance and computes its hash . |
41,888 | private static function fieldToString ( $ id , $ value ) { $ l = strlen ( $ value ) ; return chr ( $ id ) . ( $ l == 0 ? "\x00\x00" : ( pack ( "v" , $ l ) . $ value ) ) ; } | Gets the binary format of the given header field . |
41,889 | public function check ( ) { if ( $ this -> cipher === null ) return false ; if ( $ this -> compression === 0 ) return false ; if ( $ this -> masterSeed === null ) return false ; if ( $ this -> transformSeed === null ) return false ; if ( $ this -> rounds === null ) return false ; if ( $ this -> encryptionIV === null ) ... | Checks whether all fields are set in this instance . |
41,890 | public static function load ( Reader $ reader , $ hashAlgo , & $ error ) { $ dreader = new DigestReader ( $ reader , $ hashAlgo ) ; $ sig1 = $ dreader -> read ( 4 ) ; $ sig2 = $ dreader -> read ( 4 ) ; if ( $ sig1 != self :: SIGNATURE1 || $ sig2 != self :: SIGNATURE2 ) { $ error = "Kdbx header: signature not correct." ... | Parses the content of a Reader as a KdbxHeader in binary format . |
41,891 | public function prepareEncrypting ( & $ error ) { $ header = $ this -> getHeader ( ) ; $ header -> masterSeed = random_bytes ( self :: SEED_LEN ) ; $ header -> transformSeed = random_bytes ( self :: SEED_LEN ) ; $ header -> encryptionIV = random_bytes ( 16 ) ; $ header -> randomStreamKey = random_bytes ( self :: SEED_L... | Prepares the encryption of this instance by generating new random strings for the header serializing the header and computing its hash . Non - random header fields must be set before calling this method . |
41,892 | private static function transformKey ( iKey $ key , KdbxHeader $ header ) { $ keyHash = $ key -> getHash ( ) ; $ cipher = Cipher :: Create ( 'aes-256-ecb' , $ header -> transformSeed , "" , Cipher :: PADDING_NONE ) ; if ( $ cipher == null ) return null ; $ rounds = array_values ( unpack ( "v4" , $ header -> rounds ) ) ... | Computes the AES encryption key of a Kdbx file from its keys and header . |
41,893 | public function getHash ( ) { $ h = hash_init ( $ this -> _hashAlgo ) ; foreach ( $ this -> _keys as & $ v ) hash_update ( $ h , $ v ) ; $ r = hash_final ( $ h , true ) ; unset ( $ h ) ; return $ r ; } | Computes the hash of all the keys of this CompositeKey . |
41,894 | function getStringField ( $ key ) { return isset ( $ this -> stringFields [ $ key ] ) ? $ this -> stringFields [ $ key ] -> getPlainString ( ) : "" ; } | Gets the string value of this Entry string field corresponding to the given key or an empty string of no field with that key exists . |
41,895 | private function addHistoryEntry ( $ entry ) { if ( $ entry != null ) { if ( $ this -> history == null ) $ this -> history = array ( ) ; $ this -> history [ ] = $ entry ; } } | Adds an Entry instance to the history of this entry . |
41,896 | private function readString ( ProtectedXMLReader $ reader ) { $ d = $ reader -> depth ( ) ; $ key = null ; $ value = null ; while ( $ reader -> read ( $ d ) ) { if ( $ reader -> isElement ( Database :: XML_STRING_KEY ) ) $ key = $ reader -> readTextInside ( ) ; elseif ( $ reader -> isElement ( Database :: XML_STRING_VA... | Parses a string XML element node . |
41,897 | public static function loadFromXML ( ProtectedXMLReader $ reader ) { if ( $ reader == null ) return null ; $ entry = new Entry ( ) ; $ d = $ reader -> depth ( ) ; while ( $ reader -> read ( $ d ) ) { if ( $ reader -> isElement ( Database :: XML_UUID ) ) $ entry -> uuid = $ reader -> readTextInside ( ) ; elseif ( $ read... | Creates a new Entry instance from a ProtectedXMLReader instance reading a KeePass 2 . x database and located at an Entry element node . |
41,898 | public function getChoiceFields ( ) { $ choices = parent :: getChoiceFields ( ) ; $ resort = false ; foreach ( [ 'extendedField' , 'extendedFieldSecure' ] as $ key ) { if ( isset ( $ choices [ $ key ] ) ) { foreach ( $ choices [ $ key ] as $ fieldAlias => $ field ) { $ choices [ 'lead' ] [ $ fieldAlias ] = $ field ; un... | Get a list of field choices for filters . |
41,899 | public function correctExtendedFieldColumns ( LeadListQueryBuilderGeneratedEvent $ event ) { $ q = $ event -> getQueryBuilder ( ) ; $ parts = $ q -> getQueryParts ( ) ; $ changedParts = [ ] ; $ aliases = [ ] ; if ( isset ( $ parts [ 'join' ] [ 'l' ] ) && ! empty ( $ this -> aliases ) ) { foreach ( $ parts [ 'join' ] [ ... | After addExtendedFieldFilters and the query is fully built we must correct extended fields to use the correct table aliases instead of l . . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.