idx int64 0 241k | question stringlengths 64 6.21k | target stringlengths 5 803 |
|---|---|---|
8,100 | private function findActiveParameter ( Node \ DelimitedList \ ArgumentExpressionList $ argumentExpressionList , Position $ position , PhpDocument $ doc ) : int { $ args = $ argumentExpressionList -> children ; $ i = 0 ; $ found = null ; foreach ( $ args as $ arg ) { if ( $ arg instanceof Node ) { $ start = $ arg -> get... | Given a position and arguments finds the active argument at the position |
8,101 | public function getReferenceNodesByFqn ( string $ fqn ) { return isset ( $ this -> referenceNodes ) && isset ( $ this -> referenceNodes [ $ fqn ] ) ? $ this -> referenceNodes [ $ fqn ] : null ; } | Get all references of a fully qualified name |
8,102 | public function updateContent ( string $ content ) { if ( isset ( $ this -> definitions ) ) { foreach ( $ this -> definitions as $ fqn => $ definition ) { $ this -> index -> removeDefinition ( $ fqn ) ; } } if ( isset ( $ this -> referenceNodes ) ) { foreach ( $ this -> referenceNodes as $ fqn => $ node ) { $ this -> i... | Updates the content on this document . Re - parses a source file updates symbols and reports parsing errors that may have occurred as diagnostics . |
8,103 | public function getNodeAtPosition ( Position $ position ) { if ( $ this -> sourceFileNode === null ) { return null ; } $ offset = $ position -> toOffset ( $ this -> sourceFileNode -> getFileContents ( ) ) ; $ node = $ this -> sourceFileNode -> getDescendantNodeAtPosition ( $ offset ) ; if ( $ node !== null && $ node ->... | Returns the node at a specified position |
8,104 | public function getRange ( Range $ range ) { $ content = $ this -> getContent ( ) ; $ start = $ range -> start -> toOffset ( $ content ) ; $ length = $ range -> end -> toOffset ( $ content ) - $ start ; return substr ( $ content , $ start , $ length ) ; } | Returns a range of the content |
8,105 | public static function fromNode ( Node $ node ) : Location { $ range = PositionUtilities :: getRangeFromPosition ( $ node -> getStart ( ) , $ node -> getWidth ( ) , $ node -> getFileContents ( ) ) ; return new Location ( $ node -> getUri ( ) , new Range ( new Position ( $ range -> start -> line , $ range -> start -> ch... | Returns the location of the node |
8,106 | public function xfiles ( string $ base = null ) : Promise { return $ this -> handler -> request ( 'workspace/xfiles' , [ 'base' => $ base ] ) -> then ( function ( array $ textDocuments ) { return $ this -> mapper -> mapArray ( $ textDocuments , [ ] , TextDocumentIdentifier :: class ) ; } ) ; } | Returns a list of all files in a directory |
8,107 | public function documentSymbol ( TextDocumentIdentifier $ textDocument ) : Promise { return $ this -> documentLoader -> getOrLoad ( $ textDocument -> uri ) -> then ( function ( PhpDocument $ document ) { $ symbols = [ ] ; foreach ( $ document -> getDefinitions ( ) as $ fqn => $ definition ) { $ symbols [ ] = $ definiti... | The document symbol request is sent from the client to the server to list all symbols found in a given text document . |
8,108 | public function references ( ReferenceContext $ context , TextDocumentIdentifier $ textDocument , Position $ position ) : Promise { return coroutine ( function ( ) use ( $ textDocument , $ position ) { $ document = yield $ this -> documentLoader -> getOrLoad ( $ textDocument -> uri ) ; $ node = $ document -> getNodeAtP... | The references request is sent from the client to the server to resolve project - wide references for the symbol denoted by the given text document position . |
8,109 | public function signatureHelp ( TextDocumentIdentifier $ textDocument , Position $ position ) : Promise { return coroutine ( function ( ) use ( $ textDocument , $ position ) { $ document = yield $ this -> documentLoader -> getOrLoad ( $ textDocument -> uri ) ; return $ this -> signatureHelpProvider -> getSignatureHelp ... | The signature help request is sent from the client to the server to request signature information at a given cursor position . |
8,110 | public function symbol ( string $ query ) : Promise { return coroutine ( function ( ) use ( $ query ) { if ( ! $ this -> sourceIndex -> isStaticComplete ( ) ) { yield waitForEvent ( $ this -> sourceIndex , 'static-complete' ) ; } $ symbols = [ ] ; foreach ( $ this -> sourceIndex -> getDefinitions ( ) as $ fqn => $ defi... | The workspace symbol request is sent from the client to the server to list project - wide symbols matching the query string . |
8,111 | public function didChangeWatchedFiles ( array $ changes ) { foreach ( $ changes as $ change ) { if ( $ change -> type === FileChangeType :: DELETED ) { $ this -> client -> textDocument -> publishDiagnostics ( $ change -> uri , [ ] ) ; } } } | The watched files notification is sent from the client to the server when the client detects changes to files watched by the language client . |
8,112 | public function getDeclarationLineFromNode ( $ node ) : string { if ( ( $ declaration = ParserHelpers \ tryGetPropertyDeclaration ( $ node ) ) && ( $ elements = $ declaration -> propertyElements ) || ( $ declaration = ParserHelpers \ tryGetConstOrClassConstDeclaration ( $ node ) ) && ( $ elements = $ declaration -> con... | Builds the declaration line for a given node . Declarations with multiple lines are trimmed . |
8,113 | public function getDocumentationFromNode ( $ node ) { if ( $ node instanceof Node \ Statement \ NamespaceDefinition ) { return null ; } $ constOrPropertyDeclaration = ParserHelpers \ tryGetPropertyDeclaration ( $ node ) ?? ParserHelpers \ tryGetConstOrClassConstDeclaration ( $ node ) ; if ( $ constOrPropertyDeclaration... | Gets the documentation string for a node if it has one |
8,114 | private function getDocBlock ( Node $ node ) { $ docCommentText = $ node -> getDocCommentText ( ) ; if ( $ docCommentText !== null ) { list ( $ namespaceImportTable , , ) = $ node -> getImportTablesForCurrentScope ( ) ; foreach ( $ namespaceImportTable as $ alias => $ name ) { $ namespaceImportTable [ $ alias ] = ( str... | Gets Doc Block with resolved names for a Node |
8,115 | public function createDefinitionFromNode ( Node $ node , string $ fqn = null ) : Definition { $ def = new Definition ; $ def -> fqn = $ fqn ; $ def -> canBeInstantiated = ( $ node instanceof Node \ Statement \ ClassDeclaration && ( $ node -> abstractOrFinalModifier === null || $ node -> abstractOrFinalModifier -> kind ... | Create a Definition for a definition node |
8,116 | public function resolveReferenceNodeToDefinition ( Node $ node ) { $ parent = $ node -> parent ; if ( $ node instanceof Node \ Expression \ Variable && ! ( $ parent instanceof Node \ Expression \ ScopedPropertyAccessExpression ) ) { if ( $ node -> getName ( ) === 'this' && $ fqn = $ this -> getContainingClassFqn ( $ no... | Given any node returns the Definition object of the symbol that is referenced |
8,117 | public function resolveReferenceNodeToFqn ( Node $ node ) { if ( $ node instanceof Node \ QualifiedName ) { return $ this -> resolveQualifiedNameNodeToFqn ( $ node ) ; } else if ( $ node instanceof Node \ Expression \ MemberAccessExpression ) { return $ this -> resolveMemberAccessExpressionNodeToFqn ( $ node ) ; } else... | Given any node returns the FQN of the symbol that is referenced Returns null if the FQN could not be resolved or the reference node references a variable May also return static self or parent |
8,118 | private static function getContainingClassFqn ( Node $ node ) { $ classNode = $ node -> getFirstAncestor ( Node \ Statement \ ClassDeclaration :: class ) ; if ( $ classNode === null ) { return null ; } return ( string ) $ classNode -> getNamespacedName ( ) ; } | Returns FQN of the class a node is contained in Returns null if the class is anonymous or the node is not contained in a class |
8,119 | private function getContainingClassType ( Node $ node ) { $ classFqn = $ this -> getContainingClassFqn ( $ node ) ; return $ classFqn ? new Types \ Object_ ( new Fqsen ( '\\' . $ classFqn ) ) : null ; } | Returns the type of the class a node is contained in Returns null if the class is anonymous or the node is not contained in a class |
8,120 | public function resolveVariableToNode ( $ var ) { $ n = $ var ; if ( $ var instanceof Node \ UseVariableName ) { $ n = $ var -> getFirstAncestor ( Node \ Expression \ AnonymousFunctionCreationExpression :: class ) -> parent ; $ name = $ var -> getName ( ) ; } else if ( $ var instanceof Node \ Expression \ Variable || $... | Returns the assignment or parameter node where a variable was defined |
8,121 | private static function isVariableDeclaration ( Node $ n , string $ name ) { if ( ( $ n instanceof Node \ Expression \ AssignmentExpression && $ n -> operator -> kind === PhpParser \ TokenKind :: EqualsToken ) && $ n -> leftOperand instanceof Node \ Expression \ Variable && $ n -> leftOperand -> getName ( ) === $ name ... | Checks whether the given Node declares the given variable name |
8,122 | public function setComplete ( ) { if ( ! $ this -> isStaticComplete ( ) ) { $ this -> setStaticComplete ( ) ; } $ this -> complete = true ; $ this -> emit ( 'complete' ) ; } | Marks this index as complete |
8,123 | public function getChildDefinitionsForFqn ( string $ fqn ) : \ Generator { $ parts = $ this -> splitFqn ( $ fqn ) ; if ( '' === end ( $ parts ) ) { array_pop ( $ parts ) ; } $ result = $ this -> getIndexValue ( $ parts , $ this -> definitions ) ; if ( ! $ result ) { return ; } foreach ( $ result as $ name => $ item ) {... | Returns a Generator that yields all the direct child Definitions of a given FQN |
8,124 | public function setDefinition ( string $ fqn , Definition $ definition ) { $ parts = $ this -> splitFqn ( $ fqn ) ; $ this -> indexDefinition ( 0 , $ parts , $ this -> definitions , $ definition ) ; $ this -> emit ( 'definition-added' ) ; } | Registers a definition |
8,125 | public function removeDefinition ( string $ fqn ) { $ parts = $ this -> splitFqn ( $ fqn ) ; $ this -> removeIndexedDefinition ( 0 , $ parts , $ this -> definitions , $ this -> definitions ) ; unset ( $ this -> references [ $ fqn ] ) ; } | Unsets the Definition for a specific symbol and removes all references pointing to that symbol |
8,126 | public function addReferenceUri ( string $ fqn , string $ uri ) { if ( ! isset ( $ this -> references [ $ fqn ] ) ) { $ this -> references [ $ fqn ] = [ ] ; } if ( array_search ( $ uri , $ this -> references [ $ fqn ] , true ) === false ) { $ this -> references [ $ fqn ] [ ] = $ uri ; } } | Adds a document URI as a referencee of a specific symbol |
8,127 | public function removeReferenceUri ( string $ fqn , string $ uri ) { if ( ! isset ( $ this -> references [ $ fqn ] ) ) { return ; } $ index = array_search ( $ fqn , $ this -> references [ $ fqn ] , true ) ; if ( $ index === false ) { return ; } array_splice ( $ this -> references [ $ fqn ] , $ index , 1 ) ; } | Removes a document URI as the container for a specific symbol |
8,128 | public function getIdentifier ( $ appendIdentifier = null ) { $ identifierParts = array_merge ( $ this -> parentScopes , [ $ this -> scopeIdentifier , $ appendIdentifier ] ) ; return implode ( '.' , array_filter ( $ identifierParts ) ) ; } | Get the unique identifier for this scope . |
8,129 | public function toArray ( ) { list ( $ rawData , $ rawIncludedData ) = $ this -> executeResourceTransformers ( ) ; $ serializer = $ this -> manager -> getSerializer ( ) ; $ data = $ this -> serializeResource ( $ serializer , $ rawData ) ; if ( $ serializer -> sideloadIncludes ( ) ) { $ rawIncludedData = array_map ( arr... | Convert the current data for this scope to an array . |
8,130 | public function transformPrimitiveResource ( ) { if ( ! ( $ this -> resource instanceof Primitive ) ) { throw new InvalidArgumentException ( 'Argument $resource should be an instance of League\Fractal\Resource\Primitive' ) ; } $ transformer = $ this -> resource -> getTransformer ( ) ; $ data = $ this -> resource -> get... | Transformer a primitive resource |
8,131 | protected function serializeResource ( SerializerAbstract $ serializer , $ data ) { $ resourceKey = $ this -> resource -> getResourceKey ( ) ; if ( $ this -> resource instanceof Collection ) { return $ serializer -> collection ( $ resourceKey , $ data ) ; } if ( $ this -> resource instanceof Item ) { return $ serialize... | Serialize a resource |
8,132 | protected function fireTransformer ( $ transformer , $ data ) { $ includedData = [ ] ; if ( is_callable ( $ transformer ) ) { $ transformedData = call_user_func ( $ transformer , $ data ) ; } else { $ transformer -> setCurrentScope ( $ this ) ; $ transformedData = $ transformer -> transform ( $ data ) ; } if ( $ this -... | Fire the main transformer . |
8,133 | protected function fireIncludedTransformers ( $ transformer , $ data ) { $ this -> availableIncludes = $ transformer -> getAvailableIncludes ( ) ; return $ transformer -> processIncludedResources ( $ this , $ data ) ? : [ ] ; } | Fire the included transformers . |
8,134 | protected function filterFieldsets ( array $ data ) { if ( ! $ this -> hasFilterFieldset ( ) ) { return $ data ; } $ serializer = $ this -> manager -> getSerializer ( ) ; $ requestedFieldset = iterator_to_array ( $ this -> getFilterFieldset ( ) ) ; $ filterFieldset = array_flip ( array_merge ( $ serializer -> getMandat... | Filter the provided data with the requested filter fieldset for the scope resource |
8,135 | public function processIncludedResources ( Scope $ scope , $ data ) { $ includedData = [ ] ; $ includes = $ this -> figureOutWhichIncludes ( $ scope ) ; foreach ( $ includes as $ include ) { $ includedData = $ this -> includeResourceIfAvailable ( $ scope , $ data , $ includedData , $ include ) ; } return $ includedData... | This method is fired to loop through available includes see if any of them are requested and permitted for this scope . |
8,136 | protected function callIncludeMethod ( Scope $ scope , $ includeName , $ data ) { $ scopeIdentifier = $ scope -> getIdentifier ( $ includeName ) ; $ params = $ scope -> getManager ( ) -> getIncludeParams ( $ scopeIdentifier ) ; $ methodName = 'include' . str_replace ( ' ' , '' , ucwords ( str_replace ( '_' , ' ' , str_... | Call Include Method . |
8,137 | protected function primitive ( $ data , $ transformer = null , $ resourceKey = null ) { return new Primitive ( $ data , $ transformer , $ resourceKey ) ; } | Create a new primitive resource object . |
8,138 | public function meta ( array $ meta ) { if ( empty ( $ meta ) ) { return [ ] ; } $ result [ 'meta' ] = $ meta ; if ( array_key_exists ( 'pagination' , $ result [ 'meta' ] ) ) { $ result [ 'links' ] = $ result [ 'meta' ] [ 'pagination' ] [ 'links' ] ; unset ( $ result [ 'meta' ] [ 'pagination' ] [ 'links' ] ) ; } return... | Serialize the meta . |
8,139 | public function includedData ( ResourceInterface $ resource , array $ data ) { list ( $ serializedData , $ linkedIds ) = $ this -> pullOutNestedIncludedData ( $ data ) ; foreach ( $ data as $ value ) { foreach ( $ value as $ includeObject ) { if ( $ this -> isNull ( $ includeObject ) || $ this -> isEmpty ( $ includeObj... | Serialize the included data . |
8,140 | public function filterIncludes ( $ includedData , $ data ) { if ( ! isset ( $ includedData [ 'included' ] ) ) { return $ includedData ; } $ this -> createRootObjects ( $ data ) ; $ filteredIncludes = array_filter ( $ includedData [ 'included' ] , [ $ this , 'filterRootObject' ] ) ; $ includedData [ 'included' ] = array... | Hook to manipulate the final sideloaded includes . The JSON API specification does not allow the root object to be included into the sideloaded included - array . We have to make sure it is filtered out in case some object links to the root object in a relationship . |
8,141 | protected function pullOutNestedIncludedData ( array $ data ) { $ includedData = [ ] ; $ linkedIds = [ ] ; foreach ( $ data as $ value ) { foreach ( $ value as $ includeObject ) { if ( isset ( $ includeObject [ 'included' ] ) ) { list ( $ includedData , $ linkedIds ) = $ this -> serializeIncludedObjectsWithCacheKey ( $... | Keep all sideloaded inclusion data on the top level . |
8,142 | private function createIncludeObjects ( $ includeObject ) { if ( $ this -> isCollection ( $ includeObject ) ) { $ includeObjects = $ includeObject [ 'data' ] ; return $ includeObjects ; } else { $ includeObjects = [ $ includeObject [ 'data' ] ] ; return $ includeObjects ; } } | Check if the objects are part of a collection or not |
8,143 | private function createRootObjects ( $ data ) { if ( $ this -> isCollection ( $ data ) ) { $ this -> setRootObjects ( $ data [ 'data' ] ) ; } else { $ this -> setRootObjects ( [ $ data [ 'data' ] ] ) ; } } | Sets the RootObjects either as collection or not . |
8,144 | private function fillRelationshipAsCollection ( $ data , $ relationship , $ key ) { foreach ( $ relationship as $ index => $ relationshipData ) { $ data [ 'data' ] [ $ index ] [ 'relationships' ] [ $ key ] = $ relationshipData ; if ( $ this -> shouldIncludeLinks ( ) ) { $ data [ 'data' ] [ $ index ] [ 'relationships' ]... | Loops over the relationships of the provided data and formats it |
8,145 | public function createData ( ResourceInterface $ resource , $ scopeIdentifier = null , Scope $ parentScopeInstance = null ) { if ( $ parentScopeInstance !== null ) { return $ this -> scopeFactory -> createChildScopeFor ( $ this , $ parentScopeInstance , $ resource , $ scopeIdentifier ) ; } return $ this -> scopeFactory... | Create Data . |
8,146 | public function parseIncludes ( $ includes ) { $ this -> requestedIncludes = $ this -> includeParams = [ ] ; if ( is_string ( $ includes ) ) { $ includes = explode ( ',' , $ includes ) ; } if ( ! is_array ( $ includes ) ) { throw new \ InvalidArgumentException ( 'The parseIncludes() method expects a string or an array.... | Parse Include String . |
8,147 | public function getFieldset ( $ type ) { return ! isset ( $ this -> requestedFieldsets [ $ type ] ) ? null : new ParamBag ( $ this -> requestedFieldsets [ $ type ] ) ; } | Get fieldset params for the specified type . |
8,148 | protected function autoIncludeParents ( ) { $ parsed = [ ] ; foreach ( $ this -> requestedIncludes as $ include ) { $ nested = explode ( '.' , $ include ) ; $ part = array_shift ( $ nested ) ; $ parsed [ ] = $ part ; while ( count ( $ nested ) > 0 ) { $ part .= '.' . array_shift ( $ nested ) ; $ parsed [ ] = $ part ; }... | Auto - include Parents |
8,149 | public static function filter_input ( array $ data , array $ filters ) { $ gump = self :: get_instance ( ) ; return $ gump -> filter ( $ data , $ filters ) ; } | Shorthand method for running only the data filters . |
8,150 | public function sanitize ( array $ input , array $ fields = array ( ) , $ utf8_encode = true ) { $ magic_quotes = ( bool ) get_magic_quotes_gpc ( ) ; if ( empty ( $ fields ) ) { $ fields = array_keys ( $ input ) ; } $ return = array ( ) ; foreach ( $ fields as $ field ) { if ( ! isset ( $ input [ $ field ] ) ) { contin... | Sanitize the input data . |
8,151 | public static function set_error_message ( $ rule , $ message ) { $ gump = self :: get_instance ( ) ; self :: $ validation_methods_errors [ $ rule ] = $ message ; } | Set a custom error message for a validation rule . |
8,152 | protected function get_messages ( ) { $ lang_file = __DIR__ . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR . $ this -> lang . '.php' ; $ messages = require $ lang_file ; if ( $ validation_methods_errors = self :: $ validation_methods_errors ) { $ messages = array_merge ( $ messages , $ validation_methods_errors )... | Get error messages . |
8,153 | public function get_readable_errors ( $ convert_to_string = false , $ field_class = 'gump-field' , $ error_class = 'gump-error-message' ) { if ( empty ( $ this -> errors ) ) { return ( $ convert_to_string ) ? null : array ( ) ; } $ resp = array ( ) ; $ messages = $ this -> get_messages ( ) ; foreach ( $ this -> errors ... | Process the validation errors and return human readable error messages . |
8,154 | public function get_errors_array ( $ convert_to_string = null ) { if ( empty ( $ this -> errors ) ) { return ( $ convert_to_string ) ? null : array ( ) ; } $ resp = array ( ) ; $ messages = $ this -> get_messages ( ) ; foreach ( $ this -> errors as $ e ) { $ field = ucwords ( str_replace ( array ( '_' , '-' ) , chr ( 3... | Process the validation errors and return an array of errors with field names as keys . |
8,155 | protected function filter_slug ( $ value , $ params = null ) { $ delimiter = '-' ; $ slug = strtolower ( trim ( preg_replace ( '/[\s-]+/' , $ delimiter , preg_replace ( '/[^A-Za-z0-9-]+/' , $ delimiter , preg_replace ( '/[&]/' , 'and' , preg_replace ( '/[\']/' , '' , iconv ( 'UTF-8' , 'ASCII//TRANSLIT' , $ str ) ) ) ) ... | Converts value to url - web - slugs . |
8,156 | protected function validate_contains ( $ field , $ input , $ param = null ) { if ( ! isset ( $ input [ $ field ] ) ) { return ; } $ param = trim ( strtolower ( $ param ) ) ; $ value = trim ( strtolower ( $ input [ $ field ] ) ) ; if ( preg_match_all ( '#\'(.+?)\'#' , $ param , $ matches , PREG_PATTERN_ORDER ) ) { $ par... | Verify that a value is contained within the pre - defined value set . |
8,157 | protected function validate_required ( $ field , $ input , $ param = null ) { if ( isset ( $ input [ $ field ] ) && ( $ input [ $ field ] === false || $ input [ $ field ] === 0 || $ input [ $ field ] === 0.0 || $ input [ $ field ] === '0' || ! empty ( $ input [ $ field ] ) ) ) { return ; } return array ( 'field' => $ f... | Check if the specified key is present and not empty . |
8,158 | protected function validate_valid_email ( $ field , $ input , $ param = null ) { if ( ! isset ( $ input [ $ field ] ) || empty ( $ input [ $ field ] ) ) { return ; } if ( ! filter_var ( $ input [ $ field ] , FILTER_VALIDATE_EMAIL ) ) { return array ( 'field' => $ field , 'value' => $ input [ $ field ] , 'rule' => __FUN... | Determine if the provided email is valid . |
8,159 | protected function validate_max_len ( $ field , $ input , $ param = null ) { if ( ! isset ( $ input [ $ field ] ) ) { return ; } if ( function_exists ( 'mb_strlen' ) ) { if ( mb_strlen ( $ input [ $ field ] ) <= ( int ) $ param ) { return ; } } else { if ( strlen ( $ input [ $ field ] ) <= ( int ) $ param ) { return ; ... | Determine if the provided value length is less or equal to a specific value . |
8,160 | protected function validate_numeric ( $ field , $ input , $ param = null ) { if ( ! isset ( $ input [ $ field ] ) || empty ( $ input [ $ field ] ) ) { return ; } if ( ! is_numeric ( $ input [ $ field ] ) ) { return array ( 'field' => $ field , 'value' => $ input [ $ field ] , 'rule' => __FUNCTION__ , 'param' => $ param... | Determine if the provided value is a valid number or numeric string . |
8,161 | protected function validate_valid_url ( $ field , $ input , $ param = null ) { if ( ! isset ( $ input [ $ field ] ) || empty ( $ input [ $ field ] ) ) { return ; } if ( ! filter_var ( $ input [ $ field ] , FILTER_VALIDATE_URL ) ) { return array ( 'field' => $ field , 'value' => $ input [ $ field ] , 'rule' => __FUNCTIO... | Determine if the provided value is a valid URL . |
8,162 | protected function validate_valid_ip ( $ field , $ input , $ param = null ) { if ( ! isset ( $ input [ $ field ] ) || empty ( $ input [ $ field ] ) ) { return ; } if ( ! filter_var ( $ input [ $ field ] , FILTER_VALIDATE_IP ) !== false ) { return array ( 'field' => $ field , 'value' => $ input [ $ field ] , 'rule' => _... | Determine if the provided value is a valid IP address . |
8,163 | protected function validate_valid_ipv6 ( $ field , $ input , $ param = null ) { if ( ! isset ( $ input [ $ field ] ) || empty ( $ input [ $ field ] ) ) { return ; } if ( ! filter_var ( $ input [ $ field ] , FILTER_VALIDATE_IP , FILTER_FLAG_IPV6 ) ) { return array ( 'field' => $ field , 'value' => $ input [ $ field ] , ... | Determine if the provided value is a valid IPv6 address . |
8,164 | protected function validate_valid_cc ( $ field , $ input , $ param = null ) { if ( ! isset ( $ input [ $ field ] ) || empty ( $ input [ $ field ] ) ) { return ; } $ number = preg_replace ( '/\D/' , '' , $ input [ $ field ] ) ; if ( function_exists ( 'mb_strlen' ) ) { $ number_length = mb_strlen ( $ number ) ; } else { ... | Determine if the input is a valid credit card number . |
8,165 | protected function validate_street_address ( $ field , $ input , $ param = null ) { if ( ! isset ( $ input [ $ field ] ) || empty ( $ input [ $ field ] ) ) { return ; } $ hasLetter = preg_match ( '/[a-zA-Z]/' , $ input [ $ field ] ) ; $ hasDigit = preg_match ( '/\d/' , $ input [ $ field ] ) ; $ hasSpace = preg_match ( ... | Determine if the provided input is likely to be a street address using weak detection . |
8,166 | protected function validate_starts ( $ field , $ input , $ param = null ) { if ( ! isset ( $ input [ $ field ] ) || empty ( $ input [ $ field ] ) ) { return ; } if ( strpos ( $ input [ $ field ] , $ param ) !== 0 ) { return array ( 'field' => $ field , 'value' => $ input [ $ field ] , 'rule' => __FUNCTION__ , 'param' =... | Determine if the provided value starts with param . |
8,167 | protected function validate_required_file ( $ field , $ input , $ param = null ) { if ( ! isset ( $ input [ $ field ] ) ) { return ; } if ( is_array ( $ input [ $ field ] ) && $ input [ $ field ] [ 'error' ] !== 4 ) { return ; } return array ( 'field' => $ field , 'value' => $ input [ $ field ] , 'rule' => __FUNCTION__... | Checks if a file was uploaded . |
8,168 | protected function validate_extension ( $ field , $ input , $ param = null ) { if ( ! isset ( $ input [ $ field ] ) ) { return ; } if ( is_array ( $ input [ $ field ] ) && $ input [ $ field ] [ 'error' ] !== 4 ) { $ param = trim ( strtolower ( $ param ) ) ; $ allowed_extensions = explode ( ';' , $ param ) ; $ path_info... | Check the uploaded file for extension for now checks only the ext should add mime type check . |
8,169 | protected function validate_equalsfield ( $ field , $ input , $ param = null ) { if ( ! isset ( $ input [ $ field ] ) || empty ( $ input [ $ field ] ) ) { return ; } if ( $ input [ $ field ] == $ input [ $ param ] ) { return ; } return array ( 'field' => $ field , 'value' => $ input [ $ field ] , 'rule' => __FUNCTION__... | Determine if the provided field value equals current field value . |
8,170 | protected function validate_phone_number ( $ field , $ input , $ param = null ) { if ( ! isset ( $ input [ $ field ] ) || empty ( $ input [ $ field ] ) ) { return ; } $ regex = '/^(\d[\s-\.]?)?[\(\[\s-\.]{0,2}?\d{3}[\)\]\s-\.]{0,2}?\d{3}[\s-\.]?\d{4}$/i' ; if ( ! preg_match ( $ regex , $ input [ $ field ] ) ) { return ... | Determine if the provided value is a valid phone number . |
8,171 | protected function validate_valid_json_string ( $ field , $ input , $ param = null ) { if ( ! isset ( $ input [ $ field ] ) || empty ( $ input [ $ field ] ) ) { return ; } if ( ! is_string ( $ input [ $ field ] ) || ! is_object ( json_decode ( $ input [ $ field ] ) ) ) { return array ( 'field' => $ field , 'value' => $... | JSON validator . |
8,172 | protected function validate_valid_array_size_greater ( $ field , $ input , $ param = null ) { if ( ! isset ( $ input [ $ field ] ) || empty ( $ input [ $ field ] ) ) { return ; } if ( ! is_array ( $ input [ $ field ] ) || sizeof ( $ input [ $ field ] ) < ( int ) $ param ) { return array ( 'field' => $ field , 'value' =... | Check if an input is an array and if the size is more or equal to a specific value . |
8,173 | protected function validate_valid_twitter ( $ field , $ input , $ param = NULL ) { if ( ! isset ( $ input [ $ field ] ) || empty ( $ input [ $ field ] ) ) { return ; } $ json_twitter = file_get_contents ( "http://twitter.com/users/username_available?username=" . $ input [ $ field ] ) ; $ twitter_response = json_decode ... | Determine if the provided value is a valid twitter handle . |
8,174 | public function run ( Image $ image ) { $ sharpen = $ this -> getSharpen ( ) ; if ( $ sharpen !== null ) { $ image -> sharpen ( $ sharpen ) ; } return $ image ; } | Perform sharpen image manipulation . |
8,175 | public function getSharpen ( ) { if ( ! is_numeric ( $ this -> sharp ) ) { return ; } if ( $ this -> sharp < 0 or $ this -> sharp > 100 ) { return ; } return ( int ) $ this -> sharp ; } | Resolve sharpen amount . |
8,176 | public function run ( Image $ image ) { if ( $ this -> filt === 'greyscale' ) { return $ this -> runGreyscaleFilter ( $ image ) ; } if ( $ this -> filt === 'sepia' ) { return $ this -> runSepiaFilter ( $ image ) ; } return $ image ; } | Perform filter image manipulation . |
8,177 | public function runSepiaFilter ( Image $ image ) { $ image -> greyscale ( ) ; $ image -> brightness ( - 10 ) ; $ image -> contrast ( 10 ) ; $ image -> colorize ( 38 , 27 , 12 ) ; $ image -> brightness ( - 10 ) ; $ image -> contrast ( 10 ) ; return $ image ; } | Perform sepia manipulation . |
8,178 | public function run ( Image $ image ) { $ contrast = $ this -> getContrast ( ) ; if ( $ contrast !== null ) { $ image -> contrast ( $ contrast ) ; } return $ image ; } | Perform contrast image manipulation . |
8,179 | public function getContrast ( ) { if ( ! preg_match ( '/^-*[0-9]+$/' , $ this -> con ) ) { return ; } if ( $ this -> con < - 100 or $ this -> con > 100 ) { return ; } return ( int ) $ this -> con ; } | Resolve contrast amount . |
8,180 | public function getSource ( ) { if ( ! isset ( $ this -> config [ 'source' ] ) ) { throw new InvalidArgumentException ( 'A "source" file system must be set.' ) ; } if ( is_string ( $ this -> config [ 'source' ] ) ) { return new Filesystem ( new Local ( $ this -> config [ 'source' ] ) ) ; } return $ this -> config [ 'so... | Get source file system . |
8,181 | public function getCache ( ) { if ( ! isset ( $ this -> config [ 'cache' ] ) ) { throw new InvalidArgumentException ( 'A "cache" file system must be set.' ) ; } if ( is_string ( $ this -> config [ 'cache' ] ) ) { return new Filesystem ( new Local ( $ this -> config [ 'cache' ] ) ) ; } return $ this -> config [ 'cache' ... | Get cache file system . |
8,182 | public function getWatermarks ( ) { if ( ! isset ( $ this -> config [ 'watermarks' ] ) ) { return ; } if ( is_string ( $ this -> config [ 'watermarks' ] ) ) { return new Filesystem ( new Local ( $ this -> config [ 'watermarks' ] ) ) ; } return $ this -> config [ 'watermarks' ] ; } | Get watermarks file system . |
8,183 | public function getImageManager ( ) { $ driver = 'gd' ; if ( isset ( $ this -> config [ 'driver' ] ) ) { $ driver = $ this -> config [ 'driver' ] ; } return new ImageManager ( [ 'driver' => $ driver , ] ) ; } | Get Intervention image manager . |
8,184 | public function getManipulators ( ) { return [ new Orientation ( ) , new Crop ( ) , new Size ( $ this -> getMaxImageSize ( ) ) , new Brightness ( ) , new Contrast ( ) , new Gamma ( ) , new Sharpen ( ) , new Filter ( ) , new Flip ( ) , new Blur ( ) , new Pixelate ( ) , new Watermark ( $ this -> getWatermarks ( ) , $ thi... | Get image manipulators . |
8,185 | public function run ( Image $ image ) { $ blur = $ this -> getBlur ( ) ; if ( $ blur !== null ) { $ image -> blur ( $ blur ) ; } return $ image ; } | Perform blur image manipulation . |
8,186 | public function getBlur ( ) { if ( ! is_numeric ( $ this -> blur ) ) { return ; } if ( $ this -> blur < 0 or $ this -> blur > 100 ) { return ; } return ( int ) $ this -> blur ; } | Resolve blur amount . |
8,187 | public function run ( Image $ image ) { $ orientation = $ this -> getOrientation ( ) ; if ( $ orientation === 'auto' ) { return $ image -> orientate ( ) ; } return $ image -> rotate ( $ orientation ) ; } | Perform orientation image manipulation . |
8,188 | public function run ( Image $ image ) { $ format = $ this -> getFormat ( $ image ) ; $ quality = $ this -> getQuality ( ) ; if ( in_array ( $ format , [ 'jpg' , 'pjpg' ] , true ) ) { $ image = $ image -> getDriver ( ) -> newImage ( $ image -> width ( ) , $ image -> height ( ) , '#fff' ) -> insert ( $ image , 'top-left'... | Perform output image manipulation . |
8,189 | public function getFormat ( Image $ image ) { $ allowed = [ 'gif' => 'image/gif' , 'jpg' => 'image/jpeg' , 'pjpg' => 'image/jpeg' , 'png' => 'image/png' , 'webp' => 'image/webp' , ] ; if ( array_key_exists ( $ this -> fm , $ allowed ) ) { return $ this -> fm ; } if ( $ format = array_search ( $ image -> mime ( ) , $ al... | Resolve format . |
8,190 | public function getQuality ( ) { $ default = 90 ; if ( ! is_numeric ( $ this -> q ) ) { return $ default ; } if ( $ this -> q < 0 or $ this -> q > 100 ) { return $ default ; } return ( int ) $ this -> q ; } | Resolve quality . |
8,191 | public function run ( Image $ image ) { $ coordinates = $ this -> getCoordinates ( $ image ) ; if ( $ coordinates ) { $ coordinates = $ this -> limitToImageBoundaries ( $ image , $ coordinates ) ; $ image -> crop ( $ coordinates [ 0 ] , $ coordinates [ 1 ] , $ coordinates [ 2 ] , $ coordinates [ 3 ] ) ; } return $ imag... | Perform crop image manipulation . |
8,192 | public function getCoordinates ( Image $ image ) { $ coordinates = explode ( ',' , $ this -> crop ) ; if ( count ( $ coordinates ) !== 4 or ( ! is_numeric ( $ coordinates [ 0 ] ) ) or ( ! is_numeric ( $ coordinates [ 1 ] ) ) or ( ! is_numeric ( $ coordinates [ 2 ] ) ) or ( ! is_numeric ( $ coordinates [ 3 ] ) ) or ( $ ... | Resolve coordinates . |
8,193 | public function limitToImageBoundaries ( Image $ image , array $ coordinates ) { if ( $ coordinates [ 0 ] > ( $ image -> width ( ) - $ coordinates [ 2 ] ) ) { $ coordinates [ 0 ] = $ image -> width ( ) - $ coordinates [ 2 ] ; } if ( $ coordinates [ 1 ] > ( $ image -> height ( ) - $ coordinates [ 3 ] ) ) { $ coordinates... | Limit coordinates to image boundaries . |
8,194 | public function generateSignature ( $ path , array $ params ) { unset ( $ params [ 's' ] ) ; ksort ( $ params ) ; return md5 ( $ this -> signKey . ':' . ltrim ( $ path , '/' ) . '?' . http_build_query ( $ params ) ) ; } | Generate an HTTP signature . |
8,195 | public function run ( Image $ image ) { $ width = $ this -> getWidth ( ) ; $ height = $ this -> getHeight ( ) ; $ fit = $ this -> getFit ( ) ; $ dpr = $ this -> getDpr ( ) ; list ( $ width , $ height ) = $ this -> resolveMissingDimensions ( $ image , $ width , $ height ) ; list ( $ width , $ height ) = $ this -> applyD... | Perform size image manipulation . |
8,196 | public function getFit ( ) { if ( in_array ( $ this -> fit , [ 'contain' , 'fill' , 'max' , 'stretch' ] , true ) ) { return $ this -> fit ; } if ( preg_match ( '/^(crop)(-top-left|-top|-top-right|-left|-center|-right|-bottom-left|-bottom|-bottom-right|-[\d]{1,3}-[\d]{1,3}(?:-[\d]{1,3}(?:\.\d+)?)?)*$/' , $ this -> fit )... | Resolve fit . |
8,197 | public function getDpr ( ) { if ( ! is_numeric ( $ this -> dpr ) ) { return 1.0 ; } if ( $ this -> dpr < 0 or $ this -> dpr > 8 ) { return 1.0 ; } return ( double ) $ this -> dpr ; } | Resolve the device pixel ratio . |
8,198 | public function resolveMissingDimensions ( Image $ image , $ width , $ height ) { if ( is_null ( $ width ) and is_null ( $ height ) ) { $ width = $ image -> width ( ) ; $ height = $ image -> height ( ) ; } if ( is_null ( $ width ) ) { $ width = $ height * ( $ image -> width ( ) / $ image -> height ( ) ) ; } if ( is_nul... | Resolve missing image dimensions . |
8,199 | public function applyDpr ( $ width , $ height , $ dpr ) { $ width = $ width * $ dpr ; $ height = $ height * $ dpr ; return [ ( int ) $ width , ( int ) $ height , ] ; } | Apply the device pixel ratio . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.