idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
13,000 | private function analyzeModel ( $ model , $ textOnly ) { $ featureNum = count ( $ model -> getFeatures ( ) ) ; $ rootFeatureName = $ model -> getRootFeature ( ) -> getName ( ) ; $ constraintNum = count ( $ model -> getConstraintSolver ( ) -> getConstraints ( ) ) ; $ ruleNum = count ( $ model -> getXmlModel ( ) -> getRu... | Returns a model analysis . |
13,001 | private function analyzeConfiguration ( $ configuration , $ textOnly ) { $ validity = $ configuration -> isValid ( ) ? "valid" : "invalid" ; $ str = "" ; $ selectedColor = "\033[1;32m" ; $ deselectedColor = "\033[1;31m" ; if ( $ textOnly ) $ str .= "The given configuration has the following feature selection:\n\n" ; el... | Returns a configuration analysis . |
13,002 | public function getConfigTreeBuilder ( ) { $ treeBuilder = new TreeBuilder ( ) ; $ rootNode = $ treeBuilder -> root ( 'gauges' ) ; $ rootNode -> useAttributeAsKey ( 'path' ) -> prototype ( 'array' ) -> children ( ) -> scalarNode ( 'class' ) -> isRequired ( ) -> cannotBeEmpty ( ) -> end ( ) -> variableNode ( 'arguments'... | Provides configuration mapping |
13,003 | public function execute ( ProjectDescriptor $ project ) { $ this -> setObjectAliasesList ( $ project -> getIndexes ( ) -> elements -> getAll ( ) ) ; $ this -> substitute ( $ project ) ; } | Executes the linker . |
13,004 | public function substitute ( $ item , $ container = null ) { $ result = null ; if ( is_string ( $ item ) ) { $ result = $ this -> findAlias ( $ item , $ container ) ; } elseif ( is_array ( $ item ) || ( $ item instanceof \ Traversable && ! $ item instanceof ProjectInterface ) ) { $ isModified = false ; foreach ( $ item... | Substitutes the given item or its children s FQCN with an object alias . |
13,005 | protected function isDescriptorContainer ( $ item ) { return $ item instanceof FileDescriptor || $ item instanceof NamespaceDescriptor || $ item instanceof ClassDescriptor || $ item instanceof TraitDescriptor || $ item instanceof InterfaceDescriptor ; } | Returns true if the given Descriptor is a container type . |
13,006 | protected function replacePseudoTypes ( $ fqsen , $ container ) { $ pseudoTypes = array ( 'self' , '$this' ) ; foreach ( $ pseudoTypes as $ pseudoType ) { if ( ( strpos ( $ fqsen , $ pseudoType . '::' ) === 0 || $ fqsen === $ pseudoType ) && $ container ) { $ fqsen = $ container -> getFullyQualifiedStructuralElementNam... | Replaces pseudo - types such as self into a normalized version based on the last container that was encountered . |
13,007 | protected function fetchElementByFqsen ( $ fqsen ) { return isset ( $ this -> elementList [ $ fqsen ] ) ? $ this -> elementList [ $ fqsen ] : null ; } | Attempts to find an element with the given Fqsen in the list of elements for this project and returns null if it cannot find it . |
13,008 | public function widget ( $ args , $ instance ) { $ content = $ this -> widget_content ( $ instance ) ; if ( $ content ) { echo $ args [ 'before_widget' ] ; if ( isset ( $ instance [ 'title' ] ) && ! empty ( $ instance [ 'title' ] ) ) { echo $ args [ 'before_title' ] ; echo $ instance [ 'title' ] ; echo $ args [ 'after_... | Show widget content |
13,009 | protected function fill ( $ placeholder , $ instance ) { switch ( $ placeholder ) { case 'title' : return get_the_title ( ) ; break ; case 'url' : return get_permalink ( ) ; break ; case 'excerpt' : return get_the_excerpt ( ) ; break ; case 'date' : return get_the_date ( ) ; break ; case 'modified' : return get_the_mod... | Get placeholder s content |
13,010 | public function take ( ) { $ params = array_merge ( array ( 'author' => null , 'categories' => null ) , $ this -> input -> getOptions ( ) ) ; $ params = $ this -> fixAuthorSetupParameters ( $ params ) ; $ params = $ this -> fixCategoriesSetupParameters ( $ params ) ; $ this -> writeOutputLine ( "writing site configurat... | Creates the site structure . |
13,011 | protected function fixAuthorSetupParameters ( array $ params ) { if ( ! isset ( $ params [ 'author' ] ) ) { $ params [ 'author' ] = null ; } if ( preg_match ( '/(.*) <(.+)>/' , $ params [ 'author' ] , $ m ) ) { $ params [ 'author' ] = $ m [ 1 ] ; $ params [ 'author-email' ] = $ m [ 2 ] ; } else { $ params [ 'author-ema... | Fixes the author setup parameter . |
13,012 | public function field ( string $ field , ... $ rules ) : self { $ this -> validators [ $ field ] = $ this -> parser -> parse ( $ rules ) ; return $ this ; } | Adds one or more rules to this builder . |
13,013 | public function build ( $ ruleset = null ) : Validator { $ validators = array_merge ( [ ] , $ this -> validators ) ; if ( is_object ( $ ruleset ) || ( is_array ( $ ruleset ) && Parser :: isAssociative ( $ ruleset ) ) ) { foreach ( $ ruleset as $ field => $ rules ) { $ validators [ $ field ] = $ this -> parser -> parse ... | Builds a validator for the provided ruleset . |
13,014 | public function cmdGetShipping ( ) { $ result = $ this -> getListShipping ( ) ; $ this -> outputFormat ( $ result ) ; $ this -> outputFormatTableShipping ( $ result ) ; $ this -> output ( ) ; } | Callback for shipping - get command |
13,015 | protected function getListShipping ( ) { $ id = $ this -> getParam ( 0 ) ; if ( ! isset ( $ id ) ) { $ list = $ this -> shipping -> getList ( ) ; $ this -> limitArray ( $ list ) ; return $ list ; } $ method = $ this -> shipping -> get ( $ id ) ; if ( empty ( $ method ) ) { $ this -> errorAndExit ( $ this -> text ( 'Une... | Returns an array of shipping methods |
13,016 | public function setArraySource ( array $ data = null ) { if ( $ data === null ) { $ this -> iterator = null ; } else { $ this -> iterator = new \ ArrayIterator ( $ data ) ; } } | Array as import source |
13,017 | public function setIteratorSource ( \ Iterator $ iterator = null , $ start = 0 , $ end = - 1 ) { $ this -> iteratorstartindex = ( int ) $ start ; $ this -> iteratorendindex = ( int ) $ end ; $ this -> iterator = $ iterator ; } | Iterator as import source |
13,018 | public function importInto ( ArrayBase $ collection ) { if ( $ this -> iterator instanceof \ Iterator ) { $ i = 0 ; foreach ( $ this -> iterator as $ key => $ row ) { if ( $ this -> iteratorendindex >= 0 && $ i > $ this -> iteratorendindex ) { break ; } elseif ( $ i >= $ this -> iteratorstartindex ) { $ tempkey = $ key... | Import into ArrayBase |
13,019 | public function newInstance ( ) { $ class = get_called_class ( ) ; $ instance = new $ class ( ) ; $ instance -> setSerializer ( $ this -> getSerializer ( ) ) ; $ instance -> setItemConverter ( $ this -> getItemConverter ( ) -> newInstance ( ) ) ; return $ instance ; } | Creates a new instance of this class |
13,020 | public function setUp ( $ entityClass , array $ entityProperties , $ collectionClass , RepositoryInterface $ entityRepository = null ) { @ trigger_error ( __METHOD__ . '() is deprecated and will be removed in 2.0. Please use configureMetadata() instead.' , E_USER_DEPRECATED ) ; if ( $ entityRepository ) { @ trigger_err... | setUp method . |
13,021 | public function create ( $ fileName , $ data ) { $ path = $ this -> getPathBase ( $ fileName ) ; if ( file_exists ( $ path ) ) { return ; } $ data = serialize ( $ data ) ; return file_put_contents ( $ path , $ data ) ; } | serialises and creates cache file if required if the file already exists skip this |
13,022 | public function read ( $ fileName ) { $ path = $ this -> getPathBase ( $ fileName ) ; if ( ! file_exists ( $ path ) ) { return ; } $ data = file_get_contents ( $ path ) ; return $ this -> data = unserialize ( $ data ) ; } | reads in the cached file if it exists unserialises and stores in data property |
13,023 | public function delete ( $ fileName ) { $ path = $ this -> getPathBase ( $ fileName ) ; if ( ! file_exists ( $ path ) ) { return ; } return unlink ( $ path ) ; } | removes the file from the cache |
13,024 | public function checkOptions ( MvcEvent $ e ) { $ matches = $ e -> getRouteMatch ( ) ; $ response = $ e -> getResponse ( ) ; $ request = $ e -> getRequest ( ) ; $ method = $ request -> getMethod ( ) ; if ( $ matches -> getParam ( 'id' , false ) ) { if ( ! in_array ( $ method , $ this -> allowedResourceMethods ) ) { $ r... | Checks that is an allowed method |
13,025 | public function injectLinkHeader ( MvcEvent $ e ) { $ response = $ e -> getResponse ( ) ; $ headers = $ response -> getHeaders ( ) ; $ headers -> addHeaderLine ( 'Access-Control-Allow-Origin' , '*' ) ; $ headers -> addHeaderLine ( 'Access-Control-Allow-Methods' , 'POST PUT DELETE GET' ) ; } | Inject documentation link header to the response |
13,026 | private function buildQuery ( $ pattern , $ args ) { if ( count ( $ args [ 'parameters' ] ) > 0 ) { $ string = $ pattern [ 0 ] ; } else { $ string = $ pattern [ 1 ] ; } if ( preg_match_all ( "/:(\w+)/" , $ string , $ match ) ) { $ match = $ match [ 0 ] ; $ values = array_values ( $ args ) ; return str_replace ( $ match... | create the a sql query |
13,027 | public function endpoint ( ) { $ endpoint = $ this -> getset ( 'endpoint' , func_get_args ( ) ) ; return $ this -> validateEndpoint ( $ endpoint ? : self :: URI_API ) ; } | Get and optionally set the endpoint . |
13,028 | public function authorizationEndpoint ( ) { $ endpoint = $ this -> getset ( 'authorization_endpoint' , func_get_args ( ) ) ; return $ this -> validateEndpoint ( $ endpoint ? : self :: URI_AUTHORIZE ) ; } | Get and optionally set the authorization endpoint . |
13,029 | protected function run ( $ method , $ args ) { $ request = $ this -> request ( ) ; $ request -> method ( $ method ) ; $ request -> resource ( array_shift ( $ args ) ) ; if ( count ( $ args ) ) { $ request -> params ( array_shift ( $ args ) ) ; } if ( count ( $ args ) ) { $ request -> files ( array_shift ( $ args ) ) ; ... | Convenience method for sending a request and returning a response . |
13,030 | public function isAbstract ( $ status = null ) { $ this -> is_abstract = $ status !== null ? $ status : $ this -> is_abstract ; return $ this -> is_abstract ; } | Is an abstract class |
13,031 | public function addParam ( \ Deflection \ Element \ Param $ param ) { $ element = $ param -> getElement ( ) ; $ this -> params = array_merge ( $ this -> params , array ( '' ) , $ element ) ; return $ this ; } | Add function to structure |
13,032 | public function addFunction ( \ Deflection \ Element \ Functions $ function ) { $ element = $ function -> getElement ( ) ; $ this -> functions = array_merge ( $ this -> functions , array ( '' ) , $ element ) ; return $ this ; } | Add param to structure |
13,033 | public function isAllowed ( $ role , $ resource ) { if ( false === is_string ( $ role ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ role ) ) , E_USER_ERROR ) ; } if ( false === is_string ( $ resource ) ) { return trigger_error ( spri... | Returns if a role is allowed access to the resource |
13,034 | public function inherit ( $ roles , $ inherits ) { if ( true === is_string ( $ roles ) ) { $ roles = [ $ roles ] ; } if ( true === is_string ( $ inherits ) ) { $ inherits = [ $ inherits ] ; } if ( false === is_array ( $ roles ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string o... | Let a single or multiple roles inherit the resources of other single or multiple roles |
13,035 | public function getRoles ( ) { $ roles = [ ] ; foreach ( $ this -> permissions as $ role => $ permissions ) { $ roles [ $ role ] = $ this -> getRole ( $ role ) ; } return $ roles ; } | Returns all the roles as an array |
13,036 | public function getRole ( $ role ) { if ( false === is_string ( $ role ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ role ) ) , E_USER_ERROR ) ; } foreach ( $ this -> permissions as $ type => $ resources ) { if ( $ role === $ type ) ... | Returns the roles in array |
13,037 | public function getResources ( $ match = null ) { if ( null !== $ match && false === is_string ( $ match ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ match ) ) , E_USER_ERROR ) ; } $ permissions = [ ] ; $ match = null === $ match ? ... | Returns all the resourses in array |
13,038 | private function fill ( $ roles , $ resources , $ allow ) { if ( true === is_string ( $ roles ) ) { $ roles = [ $ roles ] ; } if ( true === is_string ( $ resources ) ) { $ resources = [ $ resources ] ; } if ( false === is_array ( $ roles ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the t... | Add a new permission entry |
13,039 | public function touch ( ) { $ path = $ this -> getFullPath ( ) ; if ( file_exists ( $ path ) ) { if ( ! is_writable ( $ path ) ) Path :: makeWritable ( $ path ) ; } touch ( $ path ) ; Path :: setPermissions ( $ path ) ; } | Touch the file updating its permissions |
13,040 | public function getMime ( ) { if ( ! $ this -> mime ) { $ type = FileType :: getFromFile ( $ this -> getFullPath ( ) ) ; $ this -> mime = $ type -> getMimeType ( ) ; } return $ this -> mime ; } | Return the appropriate mime type for the file |
13,041 | public function open ( string $ mode ) { $ read = strpbrk ( $ mode , "r+" ) !== false ; $ write = strpbrk ( $ mode , "waxc+" ) !== false ; $ x = strpbrk ( $ mode , "x" ) !== false ; $ path = $ this -> getFullPath ( ) ; $ fh = @ fopen ( $ path , $ mode ) ; if ( is_resource ( $ fh ) ) return $ fh ; if ( $ x && file_exist... | Open the file for reading or writing throwing informative exceptions when it fails . |
13,042 | public function arrayToClassElement ( $ definition ) { $ class = new Classes ( ) ; if ( isset ( $ definition [ 'docblock' ] ) ) { $ docblock = $ this -> arrayToDocblockElement ( $ definition [ 'docblock' ] ) ; $ class -> setDocbloc ( $ docblock ) ; } if ( isset ( $ definition [ 'namespace' ] ) ) { $ class -> setNamespa... | Transform an array to a class element object |
13,043 | public function arrayToDocblockElement ( array $ definition ) { $ docblock = new Docblock ( ) ; if ( isset ( $ definition [ 'description' ] ) ) { $ docblock -> setDescription ( $ definition [ 'description' ] ) ; } if ( isset ( $ definition [ 'params' ] ) ) { foreach ( $ definition [ 'params' ] as $ param => $ infos ) {... | Returns well formated header with descriptions param return ... |
13,044 | public function arrayToFunctionElement ( array $ definition ) { $ function = new Functions ; if ( isset ( $ definition [ 'docblock' ] ) ) { $ docblock = $ this -> arrayToDocblockElement ( $ definition [ 'docblock' ] ) ; $ function -> setDocbloc ( $ docblock ) ; } if ( isset ( $ definition [ 'public' ] ) ) { $ function ... | Returns well formated function declaration |
13,045 | public static function errToException ( $ turnOn = true ) { if ( ! $ turnOn ) { return set_error_handler ( null ) ; } $ handler = function ( $ errno , $ errStr , $ errFile , $ errLine ) { if ( ! ( error_reporting ( ) & $ errno ) ) { return ; } throw new ErrorException ( $ errStr , 0 , $ errno , $ errFile , $ errLine ) ... | Change errors to exceptions . |
13,046 | public function & __get ( $ name ) { list ( $ result , $ found ) = $ this -> peridotScanChildren ( $ this , function ( $ childScope , & $ accumulator ) use ( $ name ) { if ( property_exists ( $ childScope , $ name ) ) { $ accumulator = [ $ childScope -> $ name , true , $ childScope ] ; } } ) ; if ( ! $ found ) { throw ... | Lookup properties on child scopes . |
13,047 | protected function peridotScanChildren ( Scope $ scope , callable $ fn , & $ accumulator = [ ] ) { if ( ! empty ( $ accumulator ) ) { return $ accumulator ; } $ children = $ scope -> peridotGetChildScopes ( ) ; foreach ( $ children as $ childScope ) { $ fn ( $ childScope , $ accumulator ) ; $ this -> peridotScanChildre... | Scan child scopes and execute a function against each one passing an accumulator reference along . |
13,048 | public static function prepareContainer ( $ id ) { if ( array_key_exists ( 'id' , self :: $ container ) ) { return static :: $ container [ $ id ] ; } $ model = ColumnsetModel :: findByPk ( $ id ) ; if ( $ model === null ) { static :: $ container [ $ id ] = null ; return null ; } $ sizes = deserialize ( $ model -> sizes... | prepare the container which sub columns expects |
13,049 | protected static function prepareSize ( $ size , array $ definition ) { $ css = sprintf ( 'col-%s-%s' , $ size , $ definition [ 'width' ] ) ; if ( $ definition [ 'offset' ] ) { $ css .= sprintf ( ' col-%s-offset-%s' , $ size , $ definition [ 'offset' ] ) ; } if ( $ definition [ 'order' ] ) { $ css .= sprintf ( ' col-%s... | generates the css class defnition for one column |
13,050 | public function appendColumnsetIdToPalette ( $ dc ) { if ( $ GLOBALS [ 'TL_CONFIG' ] [ 'subcolumns' ] != 'bootstrap_customizable' ) { return ; } if ( $ dc -> table == 'tl_content' ) { $ model = \ ContentModel :: findByPK ( $ dc -> id ) ; if ( $ model -> sc_type > 0 ) { \ MetaPalettes :: appendFields ( $ dc -> table , '... | add column set field to the colsetStart content element . We need to do it dynamically because subcolumns creates its palette dynamically |
13,051 | public function appendColumnSizesToPalette ( $ dc ) { $ model = ColumnsetModel :: findByPk ( $ dc -> id ) ; $ sizes = array_merge ( deserialize ( $ model -> sizes , true ) ) ; foreach ( $ sizes as $ size ) { $ field = 'columnset_' . $ size ; \ MetaPalettes :: appendFields ( 'tl_columnset' , 'columnset' , array ( $ fiel... | Append column sizes fields dynamically to the palettes . Not using |
13,052 | public function createColumns ( $ value , $ mcw ) { $ columns = ( int ) $ mcw -> activeRecord -> columns ; $ value = deserialize ( $ value , true ) ; $ count = count ( $ value ) ; if ( $ count == 0 ) { for ( $ i = 0 ; $ i < $ columns ; $ i ++ ) { $ value [ $ i ] [ 'width' ] = floor ( 12 / $ columns ) ; } } elseif ( $ c... | create a MCW row for each column |
13,053 | public function getAllTypes ( $ dc ) { if ( $ GLOBALS [ 'TL_CONFIG' ] [ 'subcolumns' ] != 'bootstrap_customizable' ) { $ sc = new \ tl_content_sc ( ) ; return $ sc -> getAllTypes ( ) ; } $ this -> import ( 'Database' ) ; $ collection = $ this -> Database -> execute ( 'SELECT columns FROM tl_columnset GROUP BY columns O... | replace subcolumns getAllTypes method to load all created columnsets . There is a fallback provided if not bootstra_customizable is used |
13,054 | public function getAllColumnsets ( $ dc ) { $ collection = ColumnsetModel :: findBy ( 'published=1 AND columns' , $ dc -> activeRecord -> sc_type , array ( 'order' => 'title' ) ) ; $ set = array ( ) ; if ( $ collection !== null ) { while ( $ collection -> next ( ) ) { $ set [ $ collection -> id ] = $ collection -> titl... | get all columnsets which fits to the selected type |
13,055 | public function getService ( $ service ) { foreach ( $ this -> queue as $ extension ) { $ new = call_user_func ( $ extension , $ service , $ this -> container ) ; if ( $ new ) { $ service = $ new ; } } return $ service ; } | Gets the extended version of the service . |
13,056 | public function update ( array $ collection ) { foreach ( $ collection as $ key => $ value ) { $ this -> collection [ $ key ] = $ value ; } return $ this ; } | Update and append to Collection array |
13,057 | public function at ( $ index ) { $ return = NULL ; $ index = intval ( $ index ) ; $ data = $ this -> asArray ( ) ; reset ( $ data ) ; if ( $ index < 0 ) { $ index += $ this -> length ( ) ; } $ c = 1 ; while ( $ c <= $ index ) { next ( $ data ) ; $ c ++ ; } $ return = current ( $ data ) ; $ Model = $ this -> buildModel ... | Get a model based on numerical index |
13,058 | protected function updateCollection ( ) { $ responseBody = $ this -> Response -> getBody ( ) ; if ( is_array ( $ responseBody ) ) { if ( isset ( $ this -> model ) ) { $ modelIdKey = $ this -> buildModel ( ) -> modelIdKey ( ) ; foreach ( $ responseBody as $ key => $ model ) { if ( isset ( $ model [ $ modelIdKey ] ) ) { ... | Configures the collection based on the Response Body |
13,059 | protected function buildModel ( array $ data = array ( ) ) { $ Model = NULL ; if ( isset ( $ this -> model ) ) { $ Model = new $ this -> model ( ) ; $ Model -> setBaseUrl ( $ this -> getBaseUrl ( ) ) ; if ( $ this -> getAuth ( ) !== NULL ) { $ Model -> setAuth ( $ this -> getAuth ( ) ) ; } if ( ! empty ( $ data ) ) { f... | Build the ModelEndpoint |
13,060 | private function detectPool ( CommandInterface $ command ) { $ commandClass = get_class ( $ command ) ; return $ this -> poolDetector -> detect ( $ commandClass ) ; } | Detect correct pool for given command . |
13,061 | public static function prefixArrayKeys ( $ array , $ prefix ) { $ prefixedArray = array ( ) ; foreach ( $ array as $ key => $ value ) { $ prefixedArray [ $ prefix . $ key ] = $ value ; } return $ prefixedArray ; } | Take an associative array as input and return a new array with all the original keys prefixed by the passed prefix . |
13,062 | public static function getAllArrayItemsByKeyPrefix ( $ array , $ prefix , $ stripPrefix = false ) { $ returnValues = array ( ) ; foreach ( $ array as $ key => $ value ) { $ positionOfPrefix = strpos ( $ key , $ prefix ) ; if ( is_numeric ( $ positionOfPrefix ) && $ positionOfPrefix == 0 ) { if ( $ stripPrefix ) $ key =... | Find all parameters in the passed array with a key starting with the supplied prefix . Return them as an associative array by key . |
13,063 | public static function arrayDiff ( $ array1 , $ array2 ) { return array_udiff ( $ array1 , $ array2 , function ( $ a , $ b ) { if ( is_object ( $ a ) ) { return strcmp ( spl_object_hash ( $ a ) , spl_object_hash ( $ b ) ) ; } else if ( is_array ( $ a ) ) { return ArrayUtils :: arrayDiff ( $ a , $ b ) ; } else { return ... | Diff function for arrays which works with arrays of objects as well as string comparables . |
13,064 | public static function recursiveMerge ( $ array1 , $ array2 ) { if ( $ array1 instanceof AssociativeArray ) { $ array1 = $ array1 -> toArray ( ) ; } if ( $ array2 instanceof AssociativeArray ) { $ array2 = $ array2 -> toArray ( ) ; } if ( ArrayUtils :: isAssociative ( $ array1 ) != ArrayUtils :: isAssociative ( $ array... | Recursively merge array1 and array2 . If keys exist in both arrays at any level take the value from array1 in preference . |
13,065 | public static function recursiveDiff ( $ array1 , $ array2 , $ caseInsensitive = true , $ matchingKeysOnly = true ) { if ( $ array1 instanceof AssociativeArray ) { $ array1 = $ array1 -> toArray ( ) ; } if ( $ array2 instanceof AssociativeArray ) { $ array2 = $ array2 -> toArray ( ) ; } $ sharedKeys = array_intersect (... | Return an array of different elements within the 2 arrays . If matching keys only is supplied only elements which exist in both but which are different are included . |
13,066 | public static function reduceToElementsWithKey ( $ array , $ key ) { if ( $ array instanceof AssociativeArray ) { $ array = $ array -> toArray ( ) ; } $ targetArray = array ( ) ; foreach ( $ array as $ itemKey => $ value ) { if ( $ itemKey == $ key ) { $ targetArray [ $ key ] = $ value ; } else if ( is_array ( $ value ... | Reduce the array to only elements with the passed key at any depth . |
13,067 | public static function findElementsByKey ( $ array , $ key , & $ targetArray = null , $ prefix = "" ) { if ( $ array instanceof AssociativeArray ) { $ array = $ array -> toArray ( ) ; } if ( ! $ targetArray ) $ targetArray = array ( ) ; foreach ( $ array as $ itemKey => $ value ) { if ( $ itemKey === $ key ) { $ target... | Find elements by key . |
13,068 | public static function groupElementsByValueKeys ( $ array , $ groupKeys ) { if ( ! is_array ( $ groupKeys ) ) { $ groupKeys = array ( $ groupKeys ) ; } $ newArray = new AssociativeArray ( ) ; foreach ( $ array as $ element ) { $ applyObject = $ newArray ; foreach ( $ groupKeys as $ index => $ groupKey ) { if ( $ index ... | Group an array of elements by one or more of it s keys . Essentially convert into an indexed array for each key type . |
13,069 | protected function & searchTree ( $ key , & $ tree , $ create = false ) { $ found = & $ tree ; $ parts = explode ( $ this -> field_splitter , $ key ) ; while ( null !== ( $ part = array_shift ( $ parts ) ) ) { if ( ! isset ( $ found [ $ part ] ) ) { if ( $ create ) { $ found [ $ part ] = [ ] ; } else { $ bad = null ; r... | Return a node in an array structure |
13,070 | public function addRow ( $ data , $ rowId = null ) { if ( ( $ rowId === null ) && isset ( $ data [ 'id' ] ) ) { $ rowId = $ data [ 'id' ] ; } if ( $ rowId === null ) { $ rowId = count ( $ this -> rows ) ; } $ this -> rows [ $ rowId ] = $ data ; return $ this ; } | Add a row . |
13,071 | public function addRows ( $ data ) { foreach ( $ data as $ key => $ row ) { $ this -> addRow ( $ row , isset ( $ row [ 'id' ] ) ? $ row [ 'id' ] : $ key ) ; } return $ this ; } | Add rows . |
13,072 | public function getRow ( $ index ) { $ keys = array_keys ( $ this -> rows ) ; return isset ( $ keys [ $ index ] ) ? $ this -> rows [ $ keys [ $ index ] ] : null ; } | Retrieve the row with the given index . |
13,073 | public static function asType ( $ type , array $ data ) { $ converter = new TypeStringListConverter ( $ type ) ; $ converter -> setArraySource ( $ data ) ; return new static ( $ converter ) ; } | Create arraylist of class |
13,074 | public function serializeGenerator ( ) { if ( $ this -> __converter instanceof IListConverter ) { foreach ( $ this -> __converter -> toGenerator ( $ this ) as $ index => $ row ) { yield $ index => $ row ; } } else { foreach ( $ this -> toArray ( ) as $ index => $ row ) { yield $ index => $ row ; } } } | Serialize via converter as generator |
13,075 | public function setTranslations ( array $ translations ) { $ this -> translations = [ ] ; foreach ( $ translations as $ domain => $ data ) { if ( ! is_array ( $ data ) ) { throw new InvalidArgumentException ( 'Translator translations must be a 3-level array' ) ; } foreach ( $ data as $ locale => $ messages ) { if ( ! i... | Set mapping of additional translations . |
13,076 | public function exchangeArray ( array $ array ) { foreach ( $ array as $ key => $ value ) { $ setMethod = 'set' . StaticFilter :: execute ( $ key , 'WordUnderscoreToCamelCase' ) ; if ( method_exists ( $ this , $ setMethod ) ) { $ this -> $ setMethod ( $ value ) ; } } } | Exchange properties with values from array |
13,077 | public function getArrayCopy ( ) { $ data = [ ] ; foreach ( get_object_vars ( $ this ) as $ key => $ value ) { $ getMethod = 'get' . ucfirst ( $ key ) ; $ arrayKey = StaticFilter :: execute ( $ key , 'WordCamelCaseToUnderscore' ) ; $ arrayKey = StaticFilter :: execute ( $ arrayKey , 'StringToLower' ) ; if ( method_exis... | Generate an array copy from property values |
13,078 | static public function registerSerializer_ ( string $ mime , $ serializer ) : string { static :: checkSerializerNotRegistered_ ( $ mime ) ; static :: checkSerializer_ ( $ serializer ) ; static :: $ serializers_ [ $ mime ] = $ serializer ; return self :: class ; } | Static method registerSerializer_ |
13,079 | static protected function checkSerializer_ ( $ serializer ) : void { if ( ! ( ( is_object ( $ serializer ) && $ serializer instanceof S \ ASerializer ) or ( is_string ( $ serializer ) && class_exists ( $ serializer ) && isset ( class_parents ( $ serializer ) [ S \ ASerializer :: class ] ) ) ) ) { $ caller = debug_backt... | Static method checkSerializer_ |
13,080 | static protected function achieveSerializer_ ( string $ mime ) : S \ ASerializer { static :: checkSerializerSupported_ ( $ mime ) ; $ serializer = static :: getSerializer_ ( $ mime ) ; return static :: instantiateSerializer_ ( $ serializer ) ; } | Static method achieveSerializer_ |
13,081 | protected function set_post ( $ post ) { $ this -> post = $ post ; $ this -> id = ( isset ( $ post -> ID ) ) ? $ post -> ID : false ; if ( ! empty ( $ this -> taxonomies ( ) ) ) { foreach ( $ this -> taxonomies ( ) as $ taxonomy ) { $ this -> { $ taxonomy } = $ this -> get_terms ( $ taxonomy , array ( 'fields' => 'all'... | Sets Post Data . |
13,082 | public function featured_image_id ( ) { if ( isset ( $ this -> featured_image_id ) ) { return $ this -> featured_image_id ; } $ this -> featured_image_id = \ get_post_thumbnail_id ( $ this -> post ) ; return $ this -> featured_image_id ; } | Returns Featured Image ID . |
13,083 | public function featured_image_url ( $ size = 'thumbnail' , $ default = '' ) { $ featured_image = \ get_the_post_thumbnail_url ( $ this -> id ( ) , $ size ) ; return ( false !== $ featured_image ) ? $ featured_image : $ default ; } | Returns Featured Image URL . |
13,084 | public function parent ( $ only_id = true ) { if ( $ only_id ) { return $ this -> post -> post_parent ; } $ class = get_called_class ( ) ; return new $ class ( $ this -> post -> post_parent ) ; } | Returns Post Parent . |
13,085 | public function update_meta ( $ meta_key = '' , $ values = '' , $ prev_values = '' ) { return \ update_post_meta ( $ this -> id ( ) , $ meta_key , $ values , $ prev_values ) ; } | Updates Post Meta . |
13,086 | public function add_meta ( $ meta_key = '' , $ values = '' , $ unique = false ) { return \ add_post_meta ( $ this -> id ( ) , $ meta_key , $ values , $ unique ) ; } | Adds Post Meta . |
13,087 | public function taxonomies ( ) { if ( ! empty ( $ this -> taxes ) ) { return $ this -> taxes ; } $ taxes = \ get_post_taxonomies ( $ this -> post ) ; $ this -> taxes = $ taxes ; return $ this -> taxes ; } | Returns All Post Taxonomies . |
13,088 | public function get_terms ( $ taxonomy = '' , $ args = array ( ) ) { if ( isset ( $ this -> { $ taxonomy } ) && empty ( $ args ) ) { return $ this -> { $ taxonomy } ; } else { $ name = $ taxonomy . '_' . md5 ( json_encode ( $ args ) ) ; if ( isset ( $ this -> { $ name } ) ) { return $ this -> { $ name } ; } $ data = \ ... | Returns All Terms From Post . |
13,089 | public function set_terms ( $ terms = array ( ) , $ taxonomy = '' , $ append = false ) { return \ wp_set_post_terms ( $ this -> id ( ) , $ terms , $ taxonomy , $ append ) ; } | Sets Given Terms With Tax To The Current Post . |
13,090 | public function in ( $ key = '' , $ data = '' , $ default = false ) { if ( is_array ( $ data ) ) { return ( in_array ( $ key , $ data ) ) ? $ key : $ default ; } if ( isset ( $ this -> { $ data } ) ) { return ( in_array ( $ key , $ this -> { $ data } ) ) ? $ key : $ default ; } return $ default ; } | Checks if given key is in array |
13,091 | protected function doException ( \ Exception $ e ) { $ command = new DefaultConsoleCommand ( ) ; $ command -> data = '"Error #' . $ e -> getCode ( ) . ' - ' . $ e -> getMessage ( ) . '"' ; $ command -> execute ( ) ; $ response = ( new ResponseInjector ) -> build ( ) ; $ response = $ response -> withHeader ( 'status' , ... | Run application with error |
13,092 | public static function startNewContext ( string $ name , bool $ inherit = true ) { if ( $ inherit ) { $ current = static :: getInjector ( ) ; $ new_injector = new Injector ( $ current ) ; } else $ new_injector = new Injector ( ) ; return static :: $ injectors [ $ name ] = $ new_injector ; } | Start a new injection context . Useful to be able to release all static context to a certain run of the software for example in testing . |
13,093 | public static function destroyContext ( string $ name ) { end ( static :: $ injectors ) ; if ( $ name !== key ( static :: $ injectors ) ) throw new DIException ( "Injection context $name is not at top of the stack" ) ; $ injector = array_pop ( static :: $ injectors ) ; } | Destroy a context - the injector at the top of the stack is released . |
13,094 | public function getHtml ( $ variable , $ default = '' , $ allowed = "" , $ escape = true ) { return ( string ) rawurldecode ( $ this -> get ( $ variable , $ default , $ allowed , $ escape ) ) ; } | Same as _get but it rawurldecodes the string |
13,095 | public function getString ( $ variable , $ default = '' , $ allowed = "" , $ escape = true ) { return ( string ) strip_tags ( $ this -> getHtml ( $ variable , $ default , $ allowed , $ escape ) ) ; } | Same as _getHtml but it also strips tags |
13,096 | public function getBool ( $ variable , $ default = false ) { return ( bool ) $ this -> get ( $ variable , $ default , array ( false , true ) , false ) ; } | Same as _get but casts return value to bollean |
13,097 | public function htmlEncode ( $ string , $ quoteStyle = ENT_QUOTES , $ charset = 'UTF-8' , $ doubleEncode = false ) { return htmlspecialchars ( ( string ) $ string , $ quoteStyle , $ charset , $ doubleEncode ) ; } | Replacement for htmlspecialchars |
13,098 | public function query ( string $ sql , array $ values = [ ] ) : int { return $ this -> dbConnection -> prepare ( $ sql ) -> execute ( $ values ) -> count ( ) ; } | sends a query to the database and returns amount of affected records |
13,099 | public function fetchOne ( string $ sql , array $ values = [ ] , int $ columnNumber = 0 ) : string { return $ this -> dbConnection -> prepare ( $ sql ) -> execute ( $ values ) -> fetchOne ( $ columnNumber ) ; } | fetch single value from a result set |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.