idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
10,900 | protected function autoCreateTable ( ) { if ( ! $ this -> tableCreator ) { return false ; } try { $ this -> connection -> select ( "SELECT {$this->quotedIdKey} FROM {$this->quotedTable} LIMIT 1" ) ; return true ; } catch ( SQLNameNotFoundException $ e ) { } if ( $ e -> missingType != 'table' ) { throw $ e ; } call_user... | Try to create the table if a creator was assigned . |
10,901 | public function action ( $ action , $ table , $ where = array ( ) , $ options = array ( ) ) { $ sql = "{$action} FROM {$table}" ; $ value = array ( ) ; if ( ! empty ( $ where ) ) { $ sql .= " WHERE " ; foreach ( $ where as $ clause ) { if ( count ( $ clause ) === 3 ) { $ operators = array ( '=' , '>' , '<' , ' >=' , '<... | Method for dynamically generating SQL queries |
10,902 | public function addDuplicateLinks ( $ type , array $ packages ) { if ( ! isset ( $ this -> duplicateLinks [ $ type ] ) ) { $ this -> duplicateLinks [ $ type ] = [ ] ; } $ this -> duplicateLinks [ $ type ] = array_merge ( $ this -> duplicateLinks [ $ type ] , $ packages ) ; return $ this ; } | Add duplicate packages . |
10,903 | public function loadSettings ( ) { $ extra = $ this -> composer -> getPackage ( ) -> getExtra ( ) ; $ config = static :: mergeConfig ( $ extra ) ; $ this -> includes = is_array ( $ config [ 'include' ] ) ? $ config [ 'include' ] : [ $ config [ 'include' ] ] ; $ this -> requires = is_array ( $ config [ 'require' ] ) ? $... | Load plugin settings . |
10,904 | private function readPreviousVersionNumber ( ) { if ( $ this -> myFilename ) { if ( is_file ( $ this -> myFilename ) ) { $ content = file_get_contents ( $ this -> myFilename ) ; if ( $ content === false ) { $ this -> logError ( "Not readable file %s." , $ this -> myFilename ) ; } if ( $ content ) { $ this -> myPrevious... | Reads previous version from file if filename is set . |
10,905 | private function setProjectVersionProperties ( ) { if ( $ this -> myVersionProperty ) { $ this -> project -> setProperty ( $ this -> myVersionProperty , $ this -> myNewVersion [ 'version' ] ) ; } if ( $ this -> myReleaseProperty ) { $ this -> project -> setProperty ( $ this -> myReleaseProperty , $ this -> myNewVersion... | Adds new properties to phing project with data about version number . |
10,906 | private function updateVersionInFile ( ) { if ( $ this -> myFilename ) { $ status = file_put_contents ( $ this -> myFilename , $ this -> myNewVersion [ 'version' ] ) ; if ( ! $ status ) { $ this -> logError ( "File %s is not writable" , $ this -> myFilename ) ; } } } | Writes new version number into file if the filename is set . |
10,907 | private function validateSemanticVersion ( $ theVersion ) { $ status = preg_match ( '/^(\d+)(?:\.(\d+))?(?:\.((\d+)(?:-([A-Za-z]+)(?:\.(\w+))?)?))?$/' , $ theVersion , $ matches ) ; $ version = [ ] ; if ( $ status ) { $ version [ 'version' ] = $ matches [ 0 ] ; $ version [ 'major' ] = $ matches [ 1 ] ; $ version [ 'min... | Validates a string is a valid Semantic Version . If the string is semantic version returns an array with the parts of the semantic version . Otherwise returns null . |
10,908 | protected function compileCondition ( ConditionContract $ condition ) { $ operand = $ condition -> operand ( ) ; $ matcher = $ this -> compile ( $ condition -> constraint ( ) ) ; return function ( $ data ) use ( $ operand , $ matcher ) { return $ matcher ( $ this -> value ( $ data , $ operand ) ) ; } ; } | Make a Closure to match a Condition . |
10,909 | protected function compileConstraint ( $ constraint ) { return function ( $ value ) use ( $ constraint ) { if ( ! $ value instanceof MatchesCollection ) { return $ this -> checker -> check ( $ value , $ constraint ) ; } foreach ( $ value as $ item ) { if ( $ this -> checker -> check ( $ item , $ constraint ) ) { return... | Compile a constraint or group . |
10,910 | protected function value ( $ root , $ path = null ) { if ( ! $ path instanceof KeyExpression ) { return $ path instanceof Expression ? "$path" : $ path ; } if ( ! is_array ( $ root ) && ! is_object ( $ root ) ) { return $ root ; } $ pathString = $ path -> toString ( ) ; if ( $ value = $ this -> extractor -> value ( $ r... | Return a value from subject . |
10,911 | public function addField ( Field $ field ) { $ tmp = $ this -> fields -> getValue ( $ this -> entity ) ; $ tmp [ $ field -> name ] = $ field ; $ this -> fields -> setValue ( $ this -> entity , $ tmp ) ; if ( $ field -> role == 'id' ) { $ key = new \ ReflectionProperty ( Entity :: class , 'key' ) ; $ key -> setAccessibl... | Add a field to the entity |
10,912 | public function addHandler ( $ name , $ handler ) { $ tmp = $ this -> relationHandlers -> getValue ( $ this -> entity ) ; $ tmp [ $ name ] = $ handler ; $ this -> relationHandlers -> setValue ( $ this -> entity , $ tmp ) ; } | Add a relation handler to the entity |
10,913 | public function setDefinition ( EntityStructure $ definition ) { $ tmp = new \ ReflectionProperty ( entity :: class , 'definition' ) ; $ tmp -> setAccessible ( true ) ; $ tmp -> setValue ( $ this -> entity , $ definition ) ; } | Set the data definition |
10,914 | public function form ( string $ slug , array $ args = [ ] ) : Classes \ SCore \ PostMetaBoxForm { return $ this -> App -> Di -> get ( Classes \ SCore \ PostMetaBoxForm :: class , compact ( 'slug' , 'args' ) ) ; } | A post meta box form class instance . |
10,915 | public function getRelease ( $ name ) { $ key = strtolower ( $ name ) ; if ( ! $ this -> hasRelease ( $ key ) ) { return null ; } return $ this -> releases [ $ key ] ; } | Gets the named release . |
10,916 | public function addRelease ( Release $ release ) { $ name = strtolower ( $ release -> getName ( ) ) ; $ this -> releases [ $ name ] = $ release ; $ this -> sortReleases ( ) ; } | Adds a release to the Log . Can be used to replace existing releases too . |
10,917 | public function sortReleases ( ) { $ unreleased = null ; if ( isset ( $ this -> releases [ 'unreleased' ] ) ) { $ unreleased = $ this -> releases [ 'unreleased' ] ; unset ( $ this -> releases [ 'unreleased' ] ) ; } $ order = Sort :: sort ( array_keys ( $ this -> releases ) ) ; $ order = array_reverse ( $ order ) ; $ ne... | Sorts the releases inside this log in accordance with semantic versioning latest release first . |
10,918 | public function mergeLog ( Log $ log ) { foreach ( $ log as $ release ) { $ name = $ release -> getName ( ) ; if ( $ this -> hasRelease ( $ name ) ) { $ this -> mergeRelease ( $ log , $ name ) ; } else { $ this -> addRelease ( $ release ) ; } } } | Merges another Log s releases with this log . |
10,919 | protected function mergeRelease ( Log $ log , $ name ) { $ myRelease = $ this -> getRelease ( $ name ) ; $ theirRelease = $ log -> getRelease ( $ name ) ; $ changes = $ this -> mergeChangesArrays ( $ theirRelease -> getAllChanges ( ) , $ myRelease -> getAllChanges ( ) ) ; $ myRelease -> setAllChanges ( $ changes ) ; } | Combines all changes of the name of the given release from the given log into this log . |
10,920 | protected function mergeChangesArrays ( $ left , $ right ) { $ return = $ left ; foreach ( $ right as $ type => $ changes ) { if ( isset ( $ left [ $ type ] ) ) { $ return [ $ type ] = array_merge ( $ right [ $ type ] , $ left [ $ type ] ) ; } else { $ return [ $ type ] = $ changes ; } } return $ return ; } | Merges two sets of changes . |
10,921 | public function matchesMarks ( array $ marks ) { if ( ! $ this -> markFilter ) { return true ; } foreach ( $ this -> markFilter as $ mark => $ mustBe ) { if ( $ mustBe === true ) { if ( ! isset ( $ marks [ $ mark ] ) || ! $ marks [ $ mark ] ) { return false ; } } if ( $ mustBe === false ) { if ( ! isset ( $ marks [ $ m... | Manually check if passed marks matches the marksFilter . |
10,922 | protected function indexedMarksToArray ( array $ givenMarks ) { $ marks = [ ] ; foreach ( $ givenMarks as $ mark ) { if ( strpos ( $ mark , '!' ) === 0 ) { $ marks [ substr ( $ mark , 1 ) ] = false ; continue ; } $ marks [ $ mark ] = true ; } return $ marks ; } | Allows shortcuts to boolean values by prefixing a mark with ! . |
10,923 | protected function checkParsedMark ( $ mark , $ value ) { if ( strpos ( $ mark , '!' ) === 0 ) { throw new InvalidArgumentException ( "Leading ! cannot be used in associative marks." ) ; } if ( ! is_bool ( $ value ) && ! is_string ( $ value ) ) { throw new UnsupportedParameterException ( "This MatchingListener can only... | Does some checks if the passed filter value is valid . |
10,924 | public static function fromNode ( $ node ) { $ p = new self ( ) ; $ p -> setNid ( $ node -> id ( ) ) ; $ p -> setPhpVersion ( '7.0' ) ; if ( $ node -> hasField ( 'field_pull_request_template' ) && ! $ node -> get ( 'field_pull_request_template' ) -> isEmpty ( ) ) { $ p -> setCustomPrMessage ( $ node -> get ( 'field_pul... | Create an object from a node . |
10,925 | protected function getFromEngine ( ) { $ this -> parseInputOnce ( ) ; return $ this -> engine -> search ( $ this -> buildConditions ( $ this -> filters ) , $ this -> sorting ( ) , $ this -> queryKeys ( ) ) ; } | Get result from SearchEngine . |
10,926 | public function validateAttribute ( $ model , $ attribute ) { $ this -> _model = $ model ; $ this -> _attributeName = $ attribute ; $ result = $ this -> validateValue ( $ model -> $ attribute ) ; if ( ! empty ( $ result ) ) { $ this -> addError ( $ model , $ attribute , $ result [ 0 ] , $ result [ 1 ] ) ; } } | Validates a single model attribute . Child classes must implement this method to provide the actual validation logic . |
10,927 | public function validateValue ( $ value ) { $ model = & $ this -> _model ; $ attribute = $ this -> _attributeName ; if ( ( ! is_array ( $ model -> $ attribute ) || ! count ( $ model -> $ attribute ) ) && $ this -> skipOnEmpty ) { return '' ; } $ result = count ( $ model -> $ attribute ) > 0 ; $ class = $ this -> baseMo... | Validates models array . |
10,928 | public function imageSpecs ( string $ size ) : array { $ specs = wp_get_additional_image_sizes ( ) ; if ( $ size === 'thumbnail' && ! isset ( $ specs [ $ size ] ) ) { $ width = ( int ) get_option ( 'thumbnail_size_w' ) ; $ height = ( int ) get_option ( 'thumbnail_size_h' ) ; $ crop = ( bool ) get_option ( 'thumbnail_cr... | Get image specs . |
10,929 | public function boot ( ) { if ( in_array ( $ this -> app -> environment ( ) , config ( 'nodes.bugsnag.notify_release_stages' , [ ] ) ) ) { $ this -> app -> singleton ( 'Illuminate\Contracts\Debug\ExceptionHandler' , function ( $ app ) { return app ( BugsnagHandler :: class ) ; } ) ; } $ this -> publishGroups ( ) ; $ th... | Bootstrap the application service . |
10,930 | protected function registerBugsnag ( ) { $ config = config ( 'nodes.bugsnag' ) ; if ( ! in_array ( $ this -> app -> environment ( ) , config ( 'nodes.bugsnag.notify_release_stages' , [ ] ) ) ) { return ; } $ this -> app -> singleton ( 'nodes.bugsnag' , function ( Container $ app ) use ( $ config ) { $ bugsnag = new Cli... | Register Bugsnag instance . |
10,931 | protected function gatherUserAgentData ( ) { $ userAgents = [ 'original' => null , 'nodes_meta' => null ] ; $ originalUserAgent = user_agent ( ) ; if ( ! empty ( $ originalUserAgent ) ) { $ userAgents [ 'original' ] = [ 'browser' => $ originalUserAgent -> getBrowserWithVersion ( ) , 'platform' => $ originalUserAgent ->... | Gather user agent data . |
10,932 | protected function registerFailedJobsListener ( ) { if ( ! in_array ( $ this -> app -> environment ( ) , config ( 'nodes.bugsnag.notify_release_stages' , [ ] ) ) ) { return ; } $ shouldReport = config ( 'nodes.bugsnag.report_failed_jobs' ) ; if ( $ shouldReport ) { Queue :: failing ( function ( JobFailed $ event ) { $ ... | Register an event listener to trigger on failed jobs from queues . |
10,933 | private function getWebpackNode ( ) { $ treeBuilder = new TreeBuilder ( 'webpack' ) ; $ node = $ treeBuilder -> getRootNode ( ) ; $ node -> canBeDisabled ( ) -> addDefaultsIfNotSet ( ) -> children ( ) -> enumNode ( 'adapter' ) -> values ( [ 'auto' , 'manifest' , 'assets' ] ) -> defaultValue ( 'auto' ) -> cannotBeEmpty ... | Get webpack config node . |
10,934 | public function counter ( $ metric , $ count = 1 , array $ tags = array ( ) , $ sampleRate = AbstractMetric :: DEFAULT_SAMPLE_RATE ) { return new Counter ( $ this -> prefix ( $ metric ) , $ count , array_merge ( $ this -> defaultTags , $ tags ) , $ sampleRate ) ; } | Creates a new counter |
10,935 | public function gauge ( $ metric , $ level , array $ tags = array ( ) , $ sampleRate = AbstractMetric :: DEFAULT_SAMPLE_RATE ) { return new Gauge ( $ this -> prefix ( $ metric ) , $ level , array_merge ( $ this -> defaultTags , $ tags ) , $ sampleRate ) ; } | Creates a new gauge |
10,936 | public function histogram ( $ metric , $ duration = null , array $ tags = array ( ) , $ sampleRate = AbstractMetric :: DEFAULT_SAMPLE_RATE ) { return new Histogram ( $ this -> prefix ( $ metric ) , $ duration , array_merge ( $ this -> defaultTags , $ tags ) , $ sampleRate ) ; } | Creates a new histogram |
10,937 | public function timer ( $ metric , $ duration = null , array $ tags = array ( ) , $ sampleRate = AbstractMetric :: DEFAULT_SAMPLE_RATE ) { return new Timer ( $ this -> prefix ( $ metric ) , $ duration , array_merge ( $ this -> defaultTags , $ tags ) , $ sampleRate ) ; } | Creates a new timer |
10,938 | public function set ( $ metric , $ uniqueValue , array $ tags = array ( ) , $ sampleRate = AbstractMetric :: DEFAULT_SAMPLE_RATE ) { return new Set ( $ this -> prefix ( $ metric ) , $ uniqueValue , array_merge ( $ this -> defaultTags , $ tags ) , $ sampleRate ) ; } | Creates a new set |
10,939 | protected function normalizeMetaData ( $ path ) { $ meta = $ this -> client -> getObjectMeta ( $ this -> bucket , $ path ) ; if ( is_null ( $ meta ) ) { return false ; } return [ 'path' => $ path , 'timestamp' => strtotime ( $ meta [ strtolower ( 'Last-Modified' ) ] ) , 'dirname' => Util :: dirname ( $ path ) , 'mimety... | Builds the normalized output array from a object . |
10,940 | private function applyCurlOptions ( $ authMethod ) { $ this -> curl -> reset ( ) ; $ this -> curl -> setUserAgent ( 'Shopello-PHP API Client/1.0' ) ; $ this -> curl -> setOpt ( CURLOPT_ENCODING , 'gzip' ) ; $ this -> curl -> setOpt ( CURLOPT_HEADER , false ) ; $ this -> curl -> setOpt ( CURLOPT_NOBODY , false ) ; $ thi... | Apply cURL options |
10,941 | private function setAuthMethod ( $ authMethod ) { switch ( $ authMethod ) { case 'apikey' : $ this -> curl -> setHeader ( 'X-API-KEY' , $ this -> apiKey ) ; break ; case 'basic' : default : $ this -> curl -> setBasicAuthentication ( $ this -> apiUsername , $ this -> apiPassword ) ; break ; } } | Set auth method for curl request |
10,942 | public function attach ( $ owner ) { parent :: attach ( $ owner ) ; if ( $ this -> name === null ) { throw new InvalidConfigException ( "No name specified for " . get_class ( $ this ) ) ; } if ( method_exists ( $ owner , "getPrimaryKey" ) ) { $ this -> _oldName = $ this -> name ; $ pk = $ owner -> getPrimaryKey ( ) ; i... | Attaches the entity to a component |
10,943 | public function detach ( ) { parent :: detach ( ) ; if ( method_exists ( $ this -> owner , "getPrimaryKey" ) ) { $ this -> name = $ this -> _oldName ; } } | Detaches the entity from a component |
10,944 | public function setConnection ( $ connection ) { if ( is_string ( $ connection ) ) { $ connection = Yii :: $ app -> { $ connection } ; } $ this -> _connection = $ connection ; } | Sets the redis connection to use for this entity |
10,945 | public function getConnection ( ) { if ( $ this -> _connection === null ) { if ( ! isset ( Yii :: $ app -> redis ) ) { throw new InvalidConfigException ( get_class ( $ this ) . " expects a 'redis' application component" ) ; } $ this -> _connection = Yii :: $ app -> redis ; } return $ this -> _connection ; } | Gets the redis connection to use for this entity |
10,946 | public function respond ( $ event , array $ data = [ ] ) { $ event = ( string ) $ event ; if ( strpos ( $ event , '.' ) == false ) { throw new \ InvalidArgumentException ( 'The event name is invalid (expecting "action.event")' ) ; } foreach ( $ this -> listeners as $ pattern => $ listener ) { if ( self :: match ( $ pat... | Responds to an event . |
10,947 | public function getListener ( $ event ) { if ( ! is_string ( $ event ) || empty ( $ event ) ) { throw new \ InvalidArgumentException ( 'The event name is invalid' ) ; } return $ this -> listeners [ $ event ] ; } | Gets the listener assigned to the given event . |
10,948 | public function setListener ( $ event , callable $ listener ) { if ( ! is_string ( $ event ) || empty ( $ event ) ) { throw new \ InvalidArgumentException ( 'The event name is invalid' ) ; } $ this -> listeners [ $ event ] = $ listener ; } | Assigns a listener to the given event . |
10,949 | public static function match ( $ pattern , $ event ) { if ( strpos ( $ pattern , '*' ) === false ) { return $ event == $ pattern ; } $ event = explode ( '.' , $ event ) ; $ pattern = explode ( '.' , $ pattern ) ; if ( count ( $ event ) != ( $ count = count ( $ pattern ) ) ) { return false ; } for ( $ i = 0 ; $ i < $ co... | Checks if an event name matches the given pattern . |
10,950 | public function getSlot ( $ name ) { if ( ! isset ( $ this -> slots [ $ name ] ) ) { throw new ResourceNotFoundException ( "Slot $name not found" ) ; } return $ this -> slots [ $ name ] ; } | Return a known Slot . |
10,951 | public function getSignalsUrl ( ) { if ( $ this -> signalsUrl ) { return $ this -> signalsUrl ; } if ( ! $ this -> baseUrl ) { throw new UnConfiguredException ( 'No SignalsUrl and no baseUrl found to generate a SignalsUrl' ) ; } return $ this -> baseUrl -> append ( 'signals' ) ; } | Return the signals url |
10,952 | public function getSlotsUrl ( ) { if ( $ this -> slotsUrl ) { return $ this -> slotsUrl ; } if ( ! $ this -> baseUrl ) { throw new UnConfiguredException ( 'No SlotsUrl and no baseUrl found to generate a SlotsUrl' ) ; } return $ this -> baseUrl -> append ( 'slots' ) ; } | Return the slots base url . |
10,953 | protected function signalHasReceiverUrl ( $ signalName , UrlContract $ url ) { foreach ( $ this -> receivers ( $ signalName ) as $ receiver ) { if ( $ receiver -> getUrl ( ) -> equals ( $ url , [ 'user' , 'host' , 'path' ] ) ) { return true ; } } return false ; } | Check if a url was already added to a signal . |
10,954 | public static final function cast ( $ value ) : string { if ( is_string ( $ value ) ) { return $ value ; } if ( is_object ( $ value ) && method_exists ( $ value , 'toString' ) ) { return $ value -> toString ( ) ; } if ( is_object ( $ value ) && method_exists ( $ value , '__toString' ) ) { return $ value -> __toString (... | Converts any value into a string . |
10,955 | public static final function collect ( \ Generator $ Input ) { return self :: join ( PHP_EOL , array_map ( function ( ) { return self :: unbreak ( self :: cast ( func_get_arg ( 0 ) ) , 1 ) ; } , iterator_to_array ( $ Input , false ) ) ) ; } | Converts the iterator into a string . |
10,956 | public final static function join ( $ separator , $ source ) { return implode ( $ separator , array_map ( function ( $ value ) { return self :: cast ( $ value ) ; } , array_filter ( Arr :: simplify ( array_slice ( func_get_args ( ) , 1 ) ) ) ) ) ; } | Joins the given arguments into a single string using the given separator . |
10,957 | public function registerToken ( $ type = 'ERC20' , $ name , $ symbol , $ address ) { $ response = $ this -> apiClient -> post ( 'tokens/register' , [ 'token_type' => $ type , 'name' => $ name , 'symbol' => $ symbol , 'address' => $ address , ] ) ; if ( ! isset ( $ response [ 'uid' ] ) ) throw new \ ErrorException ( 'Un... | Registers a new Token |
10,958 | private static function parseCommands ( array $ arguments ) : array { $ commands = [ ] ; foreach ( $ arguments as $ one ) { if ( strpos ( $ one , '--' ) === false ) { $ commands [ ] = $ one ; } } return ( $ commands ) ; } | Parse commands on console |
10,959 | private static function parseOptions ( array $ arguments ) : array { $ options = [ ] ; foreach ( $ arguments as $ one ) { if ( strpos ( $ one , '--' ) !== false && strlen ( $ one ) > 2 ) { $ options [ ] = $ one ; } } return ( $ options ) ; } | Parse options on console |
10,960 | private static function getVersionFrom ( $ path ) { $ matches = [ ] ; preg_match ( self :: $ semverRegex , $ path , $ matches ) ; return array_shift ( $ matches ) ; } | Returns the first match of a semver version number in the path . |
10,961 | private static function getRevisionFrom ( $ path ) { $ matches = [ ] ; preg_match ( self :: $ revisionRegex , $ path , $ matches ) ; $ match = array_shift ( $ matches ) ; return substr ( $ match , 0 , 7 ) ; } | Returns the short representation of a revision number bc6bbf8e2006d15cbe883d8045724cdb1166e759 is turned into bc6bbf8 |
10,962 | public function attributesToString ( array $ attributes = [ ] ) : string { $ html = [ ] ; foreach ( $ attributes as $ key => $ value ) { if ( is_array ( $ value ) ) { $ value = json_encode ( $ value ) ; } if ( in_array ( $ key , $ this -> booleanAttributes , true ) ) { $ value = $ this -> prepareBooleanAttribute ( $ ke... | Formatting a given array into a key = value - string for each entry . |
10,963 | public function remove ( MailConfigProvider $ provider ) { $ this -> providers = array_filter ( $ this -> providers , function ( $ known ) use ( $ provider ) { return spl_object_hash ( $ known ) != spl_object_hash ( $ provider ) ; } ) ; return $ this ; } | Remove a provider . |
10,964 | public function create ( array $ subscriber ) { $ defaults = [ 'language' => 'sv' , 'update_on_duplicate' => true , 'tags' => [ ] , 'automation' => false ] ; $ subscriber = array_merge ( $ defaults , $ subscriber ) ; $ this -> assertValidSubscriberParams ( $ subscriber ) ; $ params = [ 'automation' => $ subscriber [ 'a... | Creates new subscriber |
10,965 | public function createMultiple ( array $ subscribers ) { $ defaults = [ 'language' => 'sv' , 'update_on_duplicate' => true , 'tags' => [ ] , 'automation' => false ] ; $ subscribers = array_merge ( $ defaults , $ subscribers ) ; foreach ( $ subscribers [ 'subscribers' ] as $ subscriber ) { $ this -> assertValidSubscribe... | Create new subscribers |
10,966 | public function addTags ( $ id , array $ tags , $ identifyBy = 'email' ) { $ request = new Request ( 'subscribers' ) ; $ request -> setQuery ( [ 'identified_by' => $ identifyBy ] ) ; $ request -> setIdParam ( $ id ) ; $ request -> addSubresource ( [ 'name' => 'tags' ] ) ; $ request -> setParams ( [ 'tags' => $ tags ] )... | Adds tags to subscriber |
10,967 | public function deleteTag ( $ id , $ tag , $ identifyBy = "email" ) { $ request = new Request ( 'subscribers' ) ; $ request -> setQuery ( [ 'identified_by' => $ identifyBy ] ) ; $ request -> setIdParam ( $ id ) ; $ request -> addSubresource ( [ 'name' => 'tags' , 'id' => urlencode ( $ tag ) ] ) ; $ response = $ this ->... | Removes subscriber tags |
10,968 | public function getEncoding ( LocalFileNodeInterface $ file ) { $ cmd = "file --brief --uncompress --mime {$file->getPath()}" ; $ process = $ this -> getProcess ( $ cmd ) ; $ process -> mustRun ( ) ; $ result = $ process -> getOutput ( ) ; if ( preg_match ( '/charset=([^\s]+)/i' , $ result , $ matches ) ) { $ this -> l... | Find the Encoding of a specified file |
10,969 | private function filter ( string $ name , $ value ) { if ( ! isset ( $ this -> filters [ $ name ] ) ) { return $ value ; } return array_reduce ( $ this -> filters [ $ name ] , function ( $ value , FilterInterface $ filter ) { return $ filter -> filter ( $ value ) ; } , $ value ) ; } | Filter a value to a given name . |
10,970 | function createRow ( $ name , $ properties = array ( ) , $ result = null ) { return new Row ( $ this , $ name , $ properties , $ result ) ; } | Create a row from given properties . Optionally bind it to the given result . |
10,971 | function setPrimary ( $ table , $ key ) { $ this -> primary [ $ table ] = $ key ; if ( is_array ( $ key ) ) { foreach ( $ key as $ k ) { $ this -> setRequired ( $ table , $ k ) ; } } return $ this ; } | Set primary key of a table . Compound keys may be passed as an array . Always set compound primary keys explicitly with this method . |
10,972 | function getReference ( $ table , $ name ) { if ( isset ( $ this -> references [ $ table ] [ $ name ] ) ) { return $ this -> references [ $ table ] [ $ name ] ; } return $ name . '_id' ; } | Get a reference key for an association on a table |
10,973 | function setReference ( $ table , $ name , $ key ) { $ this -> references [ $ table ] [ $ name ] = $ key ; return $ this ; } | Set a reference key for an association on a table |
10,974 | function getBackReference ( $ table , $ name ) { if ( isset ( $ this -> backReferences [ $ table ] [ $ name ] ) ) { return $ this -> backReferences [ $ table ] [ $ name ] ; } return $ table . '_id' ; } | Get a back reference key for an association on a table |
10,975 | function setBackReference ( $ table , $ name , $ key ) { $ this -> backReferences [ $ table ] [ $ name ] = $ key ; return $ this ; } | Set a back reference key for an association on a table |
10,976 | function getAlias ( $ alias ) { return isset ( $ this -> aliases [ $ alias ] ) ? $ this -> aliases [ $ alias ] : $ alias ; } | Get alias of a table |
10,977 | function rewriteTable ( $ table ) { if ( is_callable ( $ this -> rewrite ) ) { return call_user_func ( $ this -> rewrite , $ table ) ; } return $ table ; } | Get rewritten table name |
10,978 | function select ( $ table , $ options = array ( ) ) { $ options = array_merge ( array ( 'expr' => null , 'where' => array ( ) , 'orderBy' => array ( ) , 'limitCount' => null , 'limitOffset' => null , 'params' => array ( ) ) , $ options ) ; $ query = "SELECT " ; if ( empty ( $ options [ 'expr' ] ) ) { $ query .= "*" ; }... | Select rows from a table |
10,979 | function insert ( $ table , $ rows , $ method = null ) { if ( empty ( $ rows ) ) return ; if ( ! isset ( $ rows [ 0 ] ) ) $ rows = array ( $ rows ) ; if ( $ method === 'prepared' ) { return $ this -> insertPrepared ( $ table , $ rows ) ; } else if ( $ method === 'batch' ) { return $ this -> insertBatch ( $ table , $ ro... | Insert one ore more rows into a table |
10,980 | protected function insertPrepared ( $ table , $ rows ) { $ columns = $ this -> getColumns ( $ rows ) ; if ( empty ( $ columns ) ) return ; $ query = $ this -> insertHead ( $ table , $ columns ) ; $ query .= "( ?" . str_repeat ( ", ?" , count ( $ columns ) - 1 ) . " )" ; $ statement = $ this -> prepare ( $ query ) ; for... | Insert rows using a prepared query |
10,981 | protected function insertBatch ( $ table , $ rows ) { $ columns = $ this -> getColumns ( $ rows ) ; if ( empty ( $ columns ) ) return ; $ query = $ this -> insertHead ( $ table , $ columns ) ; $ lists = $ this -> valueLists ( $ rows , $ columns ) ; $ query .= implode ( ", " , $ lists ) ; $ this -> onQuery ( $ query ) ;... | Insert rows using a single batch query |
10,982 | protected function insertDefault ( $ table , $ rows ) { $ columns = $ this -> getColumns ( $ rows ) ; if ( empty ( $ columns ) ) return ; $ query = $ this -> insertHead ( $ table , $ columns ) ; $ lists = $ this -> valueLists ( $ rows , $ columns ) ; foreach ( $ lists as $ list ) { $ singleQuery = $ query . $ list ; $ ... | Insert rows using one query per row |
10,983 | protected function getColumns ( $ rows ) { $ columns = array ( ) ; foreach ( $ rows as $ row ) { foreach ( $ row as $ column => $ value ) { $ columns [ $ column ] = true ; } } return array_keys ( $ columns ) ; } | Get list of all columns used in the given rows |
10,984 | protected function valueLists ( $ rows , $ columns ) { $ lists = array ( ) ; foreach ( $ rows as $ row ) { $ values = array ( ) ; foreach ( $ columns as $ column ) { $ values [ ] = $ this -> quote ( @ $ row [ $ column ] ) ; } $ lists [ ] = "( " . implode ( ", " , $ values ) . " )" ; } return $ lists ; } | Build lists of quoted values for INSERT |
10,985 | function update ( $ table , $ data , $ where = array ( ) , $ params = array ( ) ) { if ( empty ( $ data ) ) return ; $ set = array ( ) ; foreach ( $ data as $ column => $ value ) { $ set [ ] = $ this -> quoteIdentifier ( $ column ) . " = " . $ this -> quote ( $ value ) ; } if ( ! is_array ( $ where ) ) $ where = array ... | Execute update query and return statement |
10,986 | function delete ( $ table , $ where = array ( ) , $ params = array ( ) ) { if ( ! is_array ( $ where ) ) $ where = array ( $ where ) ; if ( ! is_array ( $ params ) ) $ params = array_slice ( func_get_args ( ) , 2 ) ; $ table = $ this -> rewriteTable ( $ table ) ; $ query = "DELETE FROM " . $ this -> quoteIdentifier ( $... | Execute delete query and return statement |
10,987 | function quote ( $ value ) { $ value = $ this -> format ( $ value ) ; if ( $ value === null ) { return "NULL" ; } if ( $ value === false ) { return "'0'" ; } if ( $ value === true ) { return "'1'" ; } if ( is_int ( $ value ) ) { return "'" . ( ( string ) $ value ) . "'" ; } if ( is_float ( $ value ) ) { return "'" . sp... | Quote a value for SQL |
10,988 | function onQuery ( $ query , $ params = array ( ) ) { if ( is_callable ( $ this -> queryCallback ) ) { call_user_func ( $ this -> queryCallback , $ query , $ params ) ; } } | Calls the query callback if any |
10,989 | public function getMobileRules ( ) { $ arrReturn = array ( ) ; foreach ( $ this -> MobileDetect -> getRules ( ) as $ name => $ regex ) { $ check = $ this -> MobileDetect -> { 'is' . $ name } ( ) ; if ( $ check ) { array_push ( $ arrReturn , $ name ) ; } } return $ arrReturn ; } | getMobileRules - Custom detection methods only on mobile devices |
10,990 | public function attribute ( string $ key ) { if ( $ key !== 'value' ) { return parent :: attribute ( $ key ) ; } return array_map ( function ( ElementInterface $ element ) { return $ element -> value ( ) ; } , $ this -> elements ( ) ) ; } | Returns a list of values for each element inside the collection . |
10,991 | public function withErrors ( array $ errors = [ ] ) : CollectionElement { $ this -> allErrors = $ errors ; array_walk ( $ this -> elements , function ( ElementInterface $ element ) use ( $ errors ) { $ name = $ element -> name ( ) ; if ( isset ( $ errors [ $ name ] ) && $ element instanceof ErrorAwareInterface ) { $ el... | Delegate errors down to the children . |
10,992 | public static function setExceptionHandler ( ContainerInterface $ container , string $ context = '' ) { set_exception_handler ( function ( \ Throwable $ throwable ) use ( $ container , $ context ) { $ trace = $ msg = null ; try { $ msg = rtrim ( get_class ( $ throwable ) . '(' . $ throwable -> getCode ( ) . ')@' . $ th... | Attempts to log trace or just exception details . |
10,993 | public static function setErrorHandler ( ContainerInterface $ container , string $ context = '' ) { set_error_handler ( function ( $ severity , $ message , $ file , $ line ) use ( $ container , $ context ) { if ( ! ( error_reporting ( ) & $ severity ) ) { return false ; } try { $ name = 'Unknown PHP error type' ; $ lev... | Attempts to log trace or just error details . |
10,994 | public function getCategoryTree ( $ categoryId = null ) { $ method = 'category_tree' ; if ( $ categoryId !== null ) { $ method .= '/' . $ categoryId ; } return $ this -> call ( $ method ) ; } | Get Category Tree |
10,995 | private function createImagens ( string $ file , array $ data , string $ pathFile ) { Helper :: createFolderIfNoExist ( PATH_HOME . "assetsPublic/img" ) ; foreach ( $ data as $ datum ) { if ( ! empty ( $ datum [ 'imagens' ] ) && ! file_exists ( PATH_HOME . "assetsPublic/img/{$datum['nome']}" ) ) { Helper :: createFolde... | Cria as imagens |
10,996 | private function createPageJs ( string $ name , array $ data , string $ pathFile ) { $ minifier = new Minify \ JS ( "" ) ; foreach ( $ data as $ datum ) { if ( in_array ( $ datum [ 'nome' ] , $ this -> param [ 'js' ] ) ) { foreach ( $ datum [ 'arquivos' ] as $ file ) { if ( $ file [ 'type' ] === "text/javascript" ) $ m... | Cria View Assets JS |
10,997 | private function createPageCss ( string $ name , array $ data , string $ pathFile ) { $ minifier = new Minify \ CSS ( "" ) ; if ( ! empty ( $ this -> param [ 'css' ] ) && is_array ( $ this -> param [ 'css' ] ) ) { foreach ( $ this -> param [ 'css' ] as $ item ) { $ datum = array_values ( array_filter ( array_map ( func... | Cria View Assets CSS |
10,998 | public static function isBooleanValue ( string $ value ) : bool { return in_array ( strtolower ( trim ( $ value ) ) , StringUtils :: TRUES ) || in_array ( strtolower ( trim ( $ value ) ) , StringUtils :: FALSES ) ; } | Check wether a string value equals a human - readable boolean value . |
10,999 | public static function toBooleanValue ( string $ value ) : bool { if ( empty ( $ value ) ) { return false ; } return ! in_array ( strtolower ( trim ( $ value ) ) , StringUtils :: FALSES ) ; } | Convert a human - readable string values to boolean value . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.