idx int64 0 241k | question stringlengths 64 6.21k | target stringlengths 5 803 |
|---|---|---|
232,800 | public function next ( ) { if ( $ this -> isValid ( ) ) { $ colorNames = Colors :: getW3CIndex ( ) ; $ pos = array_search ( $ this -> name , $ colorNames ) ; if ( $ pos !== false ) { if ( $ pos === ( count ( $ colorNames ) - 1 ) ) { return $ colorNames [ 0 ] ; } else { return $ colorNames [ $ pos + 1 ] ; } } else { ret... | Return the next name on the main Colors name index |
232,801 | public function editSettings ( ) { $ this -> setTitleEditSettings ( ) ; $ this -> setBreadcrumbEditSettings ( ) ; $ this -> setData ( 'stores' , $ this -> store -> getList ( ) ) ; $ this -> setData ( 'credentials' , $ this -> getCredentialSettings ( ) ) ; $ this -> setData ( 'handlers' , $ this -> report_model -> getHa... | Route page callback Displays the module settings page |
232,802 | protected function validateGaProfileSettings ( ) { $ profiles = $ this -> getSubmitted ( 'ga_profile_id' , array ( ) ) ; if ( empty ( $ profiles ) ) { $ this -> setError ( 'ga_profile_id' , $ this -> text ( 'Profile ID is required' ) ) ; return false ; } $ stores = $ this -> store -> getList ( ) ; foreach ( $ profiles ... | Validates Google Analytics profiles |
232,803 | public function install ( ) { if ( ! isset ( $ this -> complement [ 'installation-files' ] ) ) { self :: $ errors [ ] = [ 'message' => $ this -> complement [ 'path' ] [ 'root' ] ] ; return false ; } $ this -> deleteDirectory ( ) ; $ this -> changeState ( ) ; $ installed = $ this -> installComplement ( $ this -> complem... | Complement installation handler . |
232,804 | public function remove ( ) { $ this -> setState ( 'uninstall' ) ; $ this -> changeState ( ) ; if ( ! $ this -> deleteDirectory ( ) ) { $ this -> setState ( 'uninstalled' ) ; } return true ; } | Delete complement . |
232,805 | private function deleteDirectory ( ) { $ path = $ this -> complement [ 'path' ] [ 'root' ] ; if ( ! $ this -> validateRoute ( $ path ) ) { return false ; } $ isUninstall = ( $ this -> getState ( ) === 'inactive' ) ; if ( ! File :: deleteDirRecursively ( $ path ) && $ isUninstall ) { $ type = self :: getType ( 'ucfirst'... | Delete complement directory . |
232,806 | private function installComplement ( $ complement , $ path , $ slug , $ root = true ) { $ path = ( $ root ) ? $ path : $ path . key ( $ complement ) . '/' ; if ( ! $ this -> validateRoute ( $ path ) ) { return false ; } if ( ! File :: createDir ( $ path ) ) { $ msg = "The directory exists or couldn't be created in: $pa... | Install complement . |
232,807 | private function saveRemoteFile ( $ fileUrl , $ filePath ) { if ( ! $ file = @ file_get_contents ( $ fileUrl ) ) { self :: $ errors [ ] = [ 'message' => 'Error to download file: ' . $ fileUrl ] ; return false ; } if ( ! @ file_put_contents ( $ filePath , $ file ) ) { self :: $ errors [ ] = [ 'message' => 'Failed to sav... | Save remote file . |
232,808 | public function boot ( ) { if ( ! is_dir ( Remember :: $ tokensDir ) ) { mkdir ( Remember :: $ tokensDir , 0777 , true ) ; } $ this -> hasTokens ( ) ; $ this -> configure ( ) ; $ this -> start ( ) ; } | Boot remember me component |
232,809 | public function hasTokens ( ) { if ( ! is_writable ( Remember :: $ tokensDir ) || ! is_dir ( Remember :: $ tokensDir ) ) { $ tokens = Remember :: $ tokensDir ; return $ this -> exception ( "'$tokens' does not exist or is not writable by the web server" ) ; } } | Check if the tokens directory exists or is writable |
232,810 | public function configure ( ) { $ tokenGenerator = new DefaultToken ( 94 , DefaultToken :: FORMAT_BASE64 ) ; $ expire = strtotime ( Remember :: $ expire , 0 ) ; $ cookie = new PHPCookie ( "application_session" , $ expire , "/" , "" , true , true ) ; Remember :: $ storage = new FileStorage ( Remember :: $ tokensDir ) ; ... | Configure remember me |
232,811 | public function start ( ) { $ rememberMe = Remember :: $ rememberMe ; $ loginResult = $ rememberMe -> login ( ) ; if ( $ loginResult -> isSuccess ( ) ) { $ _SESSION [ '_uas' ] = $ loginResult -> getCredential ( ) ; $ _SESSION [ 'remembered_by_cookie' ] = true ; return ; } if ( $ loginResult -> hasPossibleManipulation (... | Start remember me |
232,812 | public static function unwrap ( array $ input , $ default = null ) { if ( count ( $ input ) > 1 ) { return $ input ; } return ! empty ( $ input ) ? current ( $ input ) : $ default ; } | Unwraps a single item array into the item . If the array contains more than one item it will be returned as - is . A default value can be provided and will be used when an empty array is given . |
232,813 | public function resolveClass ( $ class ) { if ( ! is_string ( $ class ) ) throw new ResolverException ( "Class must be a string" ) ; if ( array_key_exists ( $ class , $ this -> classAlias ) ) try { return $ this -> resolve ( null , $ this -> classAlias [ $ class ] ) ; } catch ( ResolverException $ e ) { } foreach ( $ t... | Called the a class needs resolving . Each registered resolver will be called for this purpose the first to return non - false will succeed . |
232,814 | public static function additionalConfiguration ( $ extensionKey ) { $ extConf = self :: getSanitizedExtConf ( $ extensionKey ) ; if ( $ extConf [ 'cachingConfigEnable' ] == 1 ) { self :: handleCachingConfiguration ( $ extConf ) ; } } | Called from additionalConfiguration . php . |
232,815 | public function setResponseBody ( $ data ) { if ( ! is_string ( $ data ) ) { $ data = json_encode ( $ data , \ JSON_PRETTY_PRINT ) ; } $ this -> response -> getBody ( ) -> write ( $ data ) ; return $ this ; } | Set response body if is not string json_encode |
232,816 | protected function _curl ( $ data , $ url ) { if ( ! function_exists ( "curl_init" ) ) { return array ( "output" => NULL , "status" => - 1 ) ; } $ data_string = json_encode ( $ data ) ; $ curl = curl_init ( ) ; curl_setopt ( $ curl , CURLOPT_POST , true ) ; curl_setopt ( $ curl , CURLOPT_POSTFIELDS , $ data_string ) ; ... | request berupa CURL |
232,817 | public function setAction ( AbstractAction $ action ) : DateTime { $ this -> action = $ action ; $ this -> action -> setDateTime ( $ this ) ; return $ this ; } | Set strategy pattern action for modification array . Action callable object resieves whole array in container and return array ro replace . |
232,818 | public function add ( $ interval ) : DateTime { if ( $ interval instanceof DateInterval ) { $ this -> value -> add ( $ interval ) ; return $ this ; } $ i = $ this -> tryToCreateIntervalByDesignators ( $ interval ) ; if ( ! $ i ) { $ i = DateInterval :: createFromDateString ( $ interval ) ; } $ this -> value -> add ( $ ... | Performs dates arithmetic . |
232,819 | public function getDateMonday ( $ format = 'Y-m-d' ) { $ weekDay = $ this -> format ( 'N' ) - 1 ; $ dateTime = clone $ this ; if ( $ weekDay ) { $ dateTime -> add ( sprintf ( '- %d days' , $ weekDay ) ) ; } if ( $ format ) { return $ dateTime -> format ( $ format ) ; } return $ dateTime ; } | Returns monday date . |
232,820 | public function unserialize ( $ serialized ) { $ serialized = @ unserialize ( $ serialized ) ; if ( ! is_array ( $ serialized ) ) { throw new \ InvalidArgumentException ( 'Invalid argument 1, arguments must be serialized of array.' , E_USER_ERROR ) ; } $ this -> replace ( $ serialized ) ; } | Un - serialize Magic Method |
232,821 | public function setup ( string $ host , string $ username , string $ password , string $ security , bool $ use_smtp = true ) : void { $ this -> use_smtp = $ use_smtp ; $ this -> email_host = $ host ; $ this -> email_username = $ username ; $ this -> email_password = $ password ; $ this -> email_security = $ security ; ... | Use this function when you use it in your own project |
232,822 | public function emvc_config ( ) : void { $ this -> use_smtp = USE_SMTP ; $ this -> email_host = EMAIL_HOST ; $ this -> email_username = EMAIL_USERNAME ; $ this -> email_password = EMAIL_PASSWORD ; $ this -> email_security = EMAIL_SECURITY ; } | Use this function when you use it in the EasyMVC framework |
232,823 | public function setTextMessage ( array $ to , string $ subject , string $ body , array $ attachment = null , array $ cc = null , array $ bcc = EMAIL_BCC ) : void { $ this -> email -> setFrom ( $ this -> from ) ; foreach ( $ to as $ value ) { $ this -> email -> addTo ( $ value ) ; } if ( $ cc != null ) { foreach ( $ cc ... | Prepare a plain text E - mail |
232,824 | public function sendMail ( ) : void { if ( $ this -> use_smtp ) { $ mailer = new SmtpMailer ( [ 'host' => $ this -> email_host , 'username' => $ this -> email_username , 'password' => $ this -> email_password , 'secure' => $ this -> email_security ] ) ; } else { $ mailer = new SendmailMailer ( ) ; } $ mailer -> send ( ... | Use this after your E - mail has been prepared |
232,825 | public function emvcRenderHtml ( string $ latteFile , array $ data ) : string { $ latte = new Engine ( ) ; $ latte -> setTempDirectory ( $ _SERVER [ 'DOCUMENT_ROOT' ] . BASE_URL . '/tmp/latte' ) ; return $ latte -> renderToString ( $ _SERVER [ 'DOCUMENT_ROOT' ] . BASE_URL . '/private/latte/' . $ latteFile , $ data ) ; ... | Use Latte for rendering HTML E - mails in the EasyMVC framework |
232,826 | public function renderHtml ( string $ latteFile , array $ data , string $ tempFolderLatte = '/tmp/latte' ) : string { $ latte = new Engine ( ) ; $ latte -> setTempDirectory ( $ tempFolderLatte ) ; return $ latte -> renderToString ( $ latteFile , $ data ) ; } | Use Latte for rendering HTML E - mails in your own project |
232,827 | public function labelSetFormat ( $ format , $ unit ) { $ this -> format = $ format ; $ this -> paperSize = $ this -> getFormatValue ( 'paper-size' ) ; $ this -> orientation = $ this -> getFormatValue ( 'orientation' ) ; $ this -> fontName = $ this -> getFormatValue ( 'font-name' ) ; $ this -> charSize = $ this -> getFo... | initialize label format settings . |
232,828 | public function addPdfLabel ( string $ text ) { if ( $ this -> countX == $ this -> xNumber ) { $ this -> AddPage ( ) ; $ this -> countX = 0 ; $ this -> countY = 0 ; } $ posX = $ this -> marginLeft + ( $ this -> countX * ( $ this -> width + $ this -> xSpace ) ) ; $ posY = $ this -> marginTop + ( $ this -> countY * ( $ t... | Print a label . |
232,829 | public static function arrayWalkRecursive ( array $ data , callable $ function ) { if ( ! is_array ( $ data ) ) { return call_user_func ( $ function , $ data ) ; } foreach ( $ data as $ k => & $ item ) { $ item = self :: arrayWalkRecursive ( $ data [ $ k ] , $ function ) ; } return $ data ; } | Array walk recursive |
232,830 | public static function getSubArrayFromArrayByKeys ( array $ array , array $ keys ) { $ result = [ ] ; foreach ( $ keys as $ key ) { if ( array_key_exists ( $ key , $ array ) ) { $ result [ $ key ] = $ array [ $ key ] ; } } return $ result ; } | Get SubArray from array by keys |
232,831 | public static function doDelete ( $ values , ConnectionInterface $ con = null ) { if ( null === $ con ) { $ con = Propel :: getServiceContainer ( ) -> getWriteConnection ( M2PTableMap :: DATABASE_NAME ) ; } if ( $ values instanceof Criteria ) { $ criteria = $ values ; } elseif ( $ values instanceof \ Attogram \ SharedM... | Performs a DELETE on the database given a M2P or Criteria object OR a primary key value . |
232,832 | public static function doInsert ( $ criteria , ConnectionInterface $ con = null ) { if ( null === $ con ) { $ con = Propel :: getServiceContainer ( ) -> getWriteConnection ( M2PTableMap :: DATABASE_NAME ) ; } if ( $ criteria instanceof Criteria ) { $ criteria = clone $ criteria ; } else { $ criteria = $ criteria -> bui... | Performs an INSERT on the database given a M2P or Criteria object . |
232,833 | final public function filterByLevel ( $ level , array $ levels = [ ] ) { if ( $ level !== $ this -> minLevel ) { $ this -> minLevel = $ level ; $ this -> consumer = null ; } if ( ! empty ( $ levels ) ) { $ this -> levels = $ levels ; $ this -> consumer = null ; } return $ this ; } | One can set minimum level of logs that will be streamed to OutputWriter by this LogsMonitor . This is optional and if method is not call all available logs are supposed to be streamed . |
232,834 | final public function filterByContext ( array $ context ) { if ( $ context !== $ this -> withContext ) { $ this -> withContext = $ context ; $ this -> consumer = null ; } return $ this ; } | One can set context that is required to stream logs to OutputWriter by this LogsMonitor . This is optional and if method is not call all available logs are supposed to be streamed . |
232,835 | final public function setOutputWriter ( OutputWriter $ outputWriter ) { if ( $ outputWriter !== $ this -> outputWriter ) { $ this -> outputWriter = $ outputWriter ; $ this -> consumer = null ; } return $ this ; } | Call of this method is required before logs are streamed to OutputWriter . |
232,836 | public static function name ( $ color ) { if ( false === is_string ( $ color ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ color ) ) , E_USER_ERROR ) ; } if ( 1 !== preg_match ( '#^[0-9a-fA-F]{6,6}$#' , $ color ) ) { return trigger_e... | Convert a hexadecimal color to color name in human language |
232,837 | private static function index ( ) { $ colors = ColorList :: get ( 'colors' ) ; foreach ( $ colors as $ hex => $ color ) { $ rgb = static :: rgb ( $ hex ) ; $ hsl = static :: hsl ( $ hex ) ; $ shade = ColorList :: get ( [ 'shades' , $ color [ 's' ] ] ) ; $ base = ColorList :: get ( [ 'base' , $ shade [ 'b' ] ] ) ; stati... | Initialise all colors |
232,838 | private static function rgb ( $ color ) { return ( object ) [ 'r' => intval ( hexdec ( substr ( $ color , 0 , 2 ) ) ) , 'g' => intval ( hexdec ( substr ( $ color , 2 , 2 ) ) ) , 'b' => intval ( hexdec ( substr ( $ color , 4 , 2 ) ) ) ] ; } | Convert hexadecimal color to RGB |
232,839 | private static function hsl ( $ color ) { $ r = intval ( hexdec ( substr ( $ color , 0 , 2 ) ) ) / 255 ; $ g = intval ( hexdec ( substr ( $ color , 2 , 2 ) ) ) / 255 ; $ b = intval ( hexdec ( substr ( $ color , 4 , 2 ) ) ) / 255 ; $ min = min ( $ r , $ g , $ b ) ; $ max = max ( $ r , $ g , $ b ) ; $ delta = $ max - $ m... | Convert hexadecimal color to HSL |
232,840 | public function serialize ( SerializedTokenIterator $ it ) { $ it -> append ( $ this -> type ) ; $ it -> append ( $ this -> text ) ; } | Serialize the token into the given token interation . |
232,841 | public static function getTypeName ( $ type ) { static $ ref = [ ] ; $ key = static :: class ; if ( empty ( $ ref [ $ key ] ) ) { $ ref [ $ key ] = new \ ReflectionClass ( $ key ) ; } foreach ( $ ref [ $ key ] -> getConstants ( ) as $ k => $ v ) { if ( $ v === $ type && strpos ( $ k , 'T_' ) === 0 ) { return $ k ; } } ... | Get a human - readable name of the given token type . |
232,842 | public static function getEntityManager ( $ db = null , $ context = 'shared' ) { $ dbConfig = \ erdiko \ core \ Helper :: getConfig ( "database" , $ context ) ; if ( $ db == null ) $ db = $ dbConfig [ 'default' ] ; $ dbParams = $ dbConfig [ 'connections' ] [ $ db ] ; $ dbParams [ 'dbname' ] = $ dbParams [ 'database' ] ... | Get Doctrine entity manager |
232,843 | public static function update ( $ entity ) { $ entityManager = self :: getEntityManager ( ) ; $ entity = $ entityManager -> merge ( $ entity ) ; $ entityManager -> flush ( ) ; return $ entity ; } | Update a single record Convenience method to update a row . You should use the Doctrine EntityManager directly to take control of the Entity merge process . |
232,844 | public function addSeedBatch ( \ Librinfo \ SeedBatchBundle \ Entity \ SeedBatch $ seedBatch ) { $ this -> seedBatches [ ] = $ seedBatch ; return $ this ; } | Add seedBatch . |
232,845 | public function removeSeedBatch ( \ Librinfo \ SeedBatchBundle \ Entity \ SeedBatch $ seedBatch ) { return $ this -> seedBatches -> removeElement ( $ seedBatch ) ; } | Remove seedBatch . |
232,846 | public function setProducer ( \ Librinfo \ CRMBundle \ Entity \ Organism $ producer = null ) { $ this -> producer = $ producer ; return $ this ; } | Set producer . |
232,847 | public function addCertification ( \ Librinfo \ SeedBatchBundle \ Entity \ Certification $ certifications ) { $ this -> certifications [ ] = $ certifications ; return $ this ; } | Add certifications . |
232,848 | public function removeCertification ( \ Librinfo \ SeedBatchBundle \ Entity \ Certification $ certification ) { $ this -> certifications -> removeElement ( $ certification ) ; } | Remove certification . |
232,849 | public function replaceTags ( $ model ) { if ( isset ( $ model -> attributes ) ) { foreach ( $ model -> attributes as $ key => $ attribute ) { if ( in_array ( $ key , $ this -> dataAttributes ) ) { $ val = Yii :: $ app -> formatter -> asDatetime ( $ model -> { $ key } , 'short' ) ; } else { $ val = $ model -> { $ key }... | Replace tags by values in text and subject field |
232,850 | public function replaceExtraTag ( $ tag , $ value ) { $ this -> subject = str_replace ( '{' . $ tag . '}' , $ value , $ this -> subject ) ; $ this -> user_subject = str_replace ( '{' . $ tag . '}' , $ value , $ this -> user_subject ) ; $ this -> text = str_replace ( '{' . $ tag . '}' , $ value , $ this -> text ) ; $ th... | Replace additional tags in email subject and text |
232,851 | public function fields ( $ fields ) { if ( ! is_string ( $ fields ) ) { throw new FatalException ( 'Only strings are allowed in COUNT query' ) ; } $ this -> fields = sprintf ( 'COUNT(%s)' , DatabaseConnectionFactory :: get ( ) -> quoteIdentifier ( $ fields ) ) ; return $ this ; } | Set the field to count . |
232,852 | public function get ( Container $ container ) { if ( $ this -> singleton ) { if ( $ this -> instance === null ) { $ f = $ this -> factory ; $ this -> instance = $ f ( $ container ) ; } return $ this -> instance ; } else { $ f = $ this -> factory ; return $ f ( $ container ) ; } } | Gets the value instance . |
232,853 | public function loadMedia ( ) { $ files = $ this -> getMediaFiles ( ) ; foreach ( $ files as $ file ) { $ mediaFile = $ this -> getCollection ( ) -> newMedia ( ) ; $ mediaFile -> setFile ( $ file ) ; $ this -> appendMediaInCollection ( $ mediaFile ) ; } } | Load media for a collection |
232,854 | public function istantiateObjects ( ) { $ this -> validateObjectClassName ( ) ; $ objects_iterator = new ArrayIterator ; $ this -> appendObjectDataToIterator ( $ objects_iterator ) ; $ this -> objects_istantiated = $ objects_iterator ; return $ this -> objects_istantiated ; } | Assuming that we can pass all the proprieties to that object as an array we istantiate each of that StdClass as a IstantiatedObject |
232,855 | public static function isDue ( $ pattern , \ DateTime $ time = null ) { if ( $ time === null ) { $ time = new \ DateTime ( ) ; } $ time -> setTime ( $ time -> format ( 'H' ) , $ time -> format ( 'i' ) ) ; $ expression = Expression :: createFromPattern ( $ pattern ) ; foreach ( self :: $ _formats as $ pos => $ fmt ) { i... | Returns true if the time matches the pattern supplied . Time defaults to current time . |
232,856 | final public function getAttributes ( $ parsed = false ) { if ( ! is_array ( $ this -> attributes ) ) { $ this -> attributes = array ( ) ; } return ( $ parsed ) ? $ this -> parseAttributes ( ) : $ this -> attributes ; } | Fetches the attributes of the fieldset |
232,857 | final public function setModel ( IModel $ model ) { $ this -> model = $ model ; $ this -> setData ( $ model -> toArray ( false , true ) ) ; return $ this ; } | Maps the form to a model |
232,858 | public function getModel ( ) { if ( ! $ this -> model ) return null ; $ data = $ this -> data ; if ( $ this -> isValid ( ) && $ this -> model ) { foreach ( $ this -> fieldsets as $ name ) { if ( ! isset ( $ this -> elements [ $ name ] ) ) continue ; $ fieldset = $ this -> elements [ $ name ] -> options -> value ; $ fie... | Fetches the populated model |
232,859 | public function add ( $ element ) { if ( ( is_object ( $ element ) && ! is_a ( $ element , 'DScribe\Form\Element' ) ) || ( ! is_object ( $ element ) && ! is_array ( $ element ) ) ) throw new Exception ( 'Form elements must be either an array or an object subclass of DScribe\Form\Element' ) ; else if ( is_array ( $ elem... | Adds an element to the fieldset |
232,860 | final public function setData ( $ data ) { if ( ( is_object ( $ data ) && ! is_a ( $ data , 'Object' ) ) || ( ! is_object ( $ data ) && ! is_array ( $ data ) ) ) throw new \ Exception ( 'Data must be either an array or an object that extends Object: ' . gettype ( $ data ) ) ; $ data = is_array ( $ data ) ? $ data : $ d... | Sets data to validate |
232,861 | final public function getData ( $ toArray = false ) { if ( is_null ( $ this -> valid ) ) throw new \ Exception ( 'Form must be validated before you can get data' ) ; if ( $ toArray ) return ( $ this -> data ) ? $ this -> data : array ( ) ; else return ( $ this -> data ) ? new \ Object ( $ this -> data ) : new \ Object ... | Fetches the filtered data |
232,862 | public function render ( ) { $ rendered = '' ; foreach ( $ this -> elements as $ element ) { if ( ! method_exists ( $ this , 'openTag' ) ) { $ element -> name = $ this -> multiple ? $ element -> name . '[]' : $ this -> getName ( ) . '[' . $ element -> name . ']' ; $ element -> parent = $ this -> getName ( ) ; } $ rende... | Renders the elements of the fieldset out |
232,863 | public static function formatBytes ( $ bytes , $ precision = 2 ) { if ( $ bytes < 1024 ) { return $ bytes . ' B' ; } elseif ( $ bytes < 1048576 ) { return round ( $ bytes / 1024 , $ precision ) . ' KB' ; } elseif ( $ bytes < 1073741824 ) { return round ( $ bytes / 1048576 , $ precision ) . ' MB' ; } elseif ( $ bytes < ... | Convert size in bytes to human readable format |
232,864 | public function validate ( $ command ) { if ( $ command instanceof SelfValidating ) { return $ this -> container -> call ( [ $ command , 'validate' ] ) ; } $ validatorClass = $ this -> getValidatorClass ( $ command ) ; if ( ! $ validatorClass ) { return ; } $ validator = $ this -> container -> make ( $ validatorClass )... | Validate a command with its appropriate validator . |
232,865 | protected function loadBuffer ( ) { $ this -> remainder = 0 ; if ( $ this -> ended ) { return ; } while ( ! $ this -> stream -> eof ( ) && strlen ( $ this -> buffer ) < self :: BUFFER_SIZE ) { $ this -> buffer .= $ this -> stream -> read ( self :: BUFFER_SIZE ) ; } $ m = NULL ; if ( preg_match ( "'^\r?\n?([a-fA-F0-9]+)... | Load data of the next chunk into memory . |
232,866 | protected function wrap ( StorageInterface $ input , array $ definition ) { foreach ( $ definition as $ property => $ class ) { $ is_array = $ class { 0 } == '[' && $ class { 1 } == ']' ; $ class = ltrim ( $ class , '[]' ) ; $ value = $ input [ $ property ] ; if ( ! class_exists ( $ class ) || ! is_subclass_of ( $ clas... | Wrap input elements in classes |
232,867 | protected function getData ( $ key ) { $ query = $ this -> db -> query ( "SELECT value FROM cache WHERE key='" . $ this -> key ( $ key ) . "' AND expire >= datetime('now')" ) ; return $ query -> fetch ( ) ; } | Retrieves the data from the database |
232,868 | protected function writeData ( $ key , $ value , $ ttl ) { if ( ! is_numeric ( $ ttl ) || $ ttl < 0 ) throw new CacheException ( 'TTL invalid: ' . $ ttl ) ; if ( $ ttl == 0 ) $ expiration = "datetime('now', '+100 years')" ; else $ expiration = "datetime('now', '+{$ttl} seconds')" ; return $ this -> db -> queryExec ( "I... | Writes the data to the database |
232,869 | public function previous ( ) { $ this -> _itemValid = true ; if ( ! prev ( $ this -> _items ) ) { $ this -> _itemValid = false ; } else { $ this -> _itemPosition -- ; } } | set previous item as current item |
232,870 | public function parseFeed ( $ url , $ nativeOrder = false , $ force = false ) { require_once PATH_SYSTEM . '/vendors/SimplePie.php' ; $ feed = new SimplePie ( ) ; $ feed -> set_timeout ( $ this -> timeout ) ; $ feed -> set_feed_url ( $ url ) ; $ feed -> enable_order_by_date ( ! $ nativeOrder ) ; $ feed -> force_feed ( ... | Opens an RSS feed parses and loads the contents . |
232,871 | public function setUp ( $ kernelDir , FileLocatorInterface $ fileLocator ) { $ this -> kernelDir = realpath ( $ kernelDir ) ; $ this -> fileLocator = $ fileLocator ; } | abstract class setting up method |
232,872 | protected function resolveTargetFilePath ( $ target , $ basePath ) { switch ( true ) { case strpos ( $ target , '@' ) === 0 : $ targetPath = $ this -> fileLocator -> locate ( $ target ) ; break ; case strpos ( $ target , '/' ) === 0 : $ targetPath = sprintf ( '%s%s' , $ this -> kernelDir , $ target ) ; break ; default ... | resolve given target file path |
232,873 | public function getTypeId ( $ type , $ createIfMissing = true ) { if ( null === $ this -> types ) { $ this -> loadCache ( ) ; } if ( false === ( $ key = array_search ( $ type , $ this -> types , true ) ) ) { if ( ! $ createIfMissing ) { return null ; } try { $ this -> backend -> getConnection ( ) -> insert ( 'apb_msg_t... | Get type identifier |
232,874 | public function getType ( $ id ) { if ( null === $ id ) { return null ; } if ( null === $ this -> types ) { $ this -> loadCache ( ) ; } if ( ! isset ( $ this -> types [ $ id ] ) ) { $ this -> loadCache ( ) ; if ( ! isset ( $ this -> types [ $ id ] ) ) { $ this -> types [ $ id ] = false ; } } if ( false === $ this -> ty... | Get type from identifier |
232,875 | public function convertQueryCondition ( $ value ) { if ( null === $ value ) { return 0 ; } if ( ! is_array ( $ value ) ) { $ value = [ $ value ] ; } $ hasOperator = false ; if ( ! Misc :: isIndexed ( $ value ) ) { $ operator = array_keys ( $ value ) [ 0 ] ; $ values = $ value [ $ operator ] [ 0 ] ; $ hasOperator = true... | Convert given query condition value which is supposed to contain types identifiers to integer identifiers |
232,876 | public function getUsingFileTimestamps ( $ key ) { $ value = $ this -> get ( $ this -> cacheKey ( $ key ) ) ; $ timestamps = $ this -> get ( $ this -> cachetskey ( $ key ) ) ; if ( $ value !== false && $ timestamps !== false ) { foreach ( $ timestamps as $ file => $ timestamp ) { if ( filemtime ( $ file ) !== $ timesta... | get cache using key but check associated timestamps on cached file array |
232,877 | public function putUsingFileTimestamps ( $ key , $ value , array $ filenames , $ duration = null ) { if ( empty ( $ duration ) ) $ duration = 0 ; $ files = array ( ) ; foreach ( $ filenames as $ file ) { $ files [ $ file ] = filemtime ( $ file ) ; } $ timestamps = md5 ( $ files ) ; $ this -> put ( $ this -> cacheKey ( ... | put cache value into cache store using timestamps of supplied files as a tie on the validity of the cache |
232,878 | public function getFileContents ( $ filename ) { $ cachecontents = $ this -> get ( $ this -> cachefilekey ( $ filename ) ) ; if ( $ cachecontents !== false && is_array ( $ cachecontents ) ) { $ contents = array_key_exists ( 'v' , $ cachecontents ) ? $ cachecontents [ 'v' ] : false ; $ timestamp = array_key_exists ( 't'... | return the file contents but cache the results indefinitely break cache if timestamp changes |
232,879 | public function request ( $ type , $ url , $ args = [ ] ) { $ response = $ this -> getHTTPClient ( ) -> $ type ( $ url , $ args ) -> getBody ( ) -> getContents ( ) ; return json_decode ( $ response ) ; } | Our main request method to Montage . Uses Guzzle under the hood to make the request and will return the json_decoded response from Montage . |
232,880 | public function auth ( $ user = null , $ password = null ) { if ( $ this -> token ) return $ this ; if ( is_null ( $ user ) || is_null ( $ password ) ) { throw new MontageAuthException ( 'Must provide a username and password.' ) ; } try { $ response = $ this -> request ( 'post' , $ this -> url ( 'auth' ) , [ 'form_para... | Authenticate with Montage and set the local token . |
232,881 | public function url ( $ endpoint , $ schema = null , $ doc_id = null , $ file_id = null ) { return sprintf ( 'api/v%d/%s' , $ this -> version , $ this -> endpoint ( $ endpoint , $ schema , $ doc_id , $ file_id ) ) ; } | Gets a formatted Montage endpoint prefixed with api version . |
232,882 | private function getHTTPClient ( ) { $ config = [ 'base_uri' => sprintf ( 'http://%s.%s/' , $ this -> subdomain , $ this -> domain ) , 'headers' => [ 'Accept' => 'application/json' , 'User-Agent' => sprintf ( 'Montage PHP v%d' , $ this -> version ) , 'X-Requested-With' => 'XMLHttpRequest' ] ] ; if ( $ this -> token ) {... | Does what it says . Gets a guzzle client with an Authorization header set in case of an existing token . |
232,883 | private function endpoint ( $ endpoint , $ schema = null , $ doc_id = null , $ file_id = null ) { $ endpoints = [ 'auth' => 'auth/' , 'user' => 'auth/user/' , 'schema-list' => 'schemas/' , 'schema-detail' => 'schemas/%s/' , 'document-query' => 'schemas/%s/query/' , 'document-save' => 'schemas/%s/save/' , 'document-deta... | Creates a formatted Montage API endpoint string . |
232,884 | public function schemas ( $ schemaName = null ) { if ( is_null ( $ schemaName ) ) { $ url = $ this -> url ( 'schema-list' ) ; return $ this -> request ( 'get' , $ url ) ; } return $ this -> schema ( $ schemaName ) ; } | Get a list of all schemas for the given users token . |
232,885 | public static function hypotenuse ( Segment $ a , Segment $ b ) : Segment { $ hypotenuse = $ a -> length ( ) -> power ( new Integer ( 2 ) ) -> add ( $ b -> length ( ) -> power ( new Integer ( 2 ) ) ) -> squareRoot ( ) ; return new Segment ( $ hypotenuse ) ; } | Compute the hypotenuse for adjacent sides A and B |
232,886 | public static function adjacentSide ( Segment $ hypotenuse , Segment $ adjacentSide ) : Segment { $ side = $ hypotenuse -> length ( ) -> power ( new Integer ( 2 ) ) -> subtract ( $ adjacentSide -> length ( ) -> power ( new Integer ( 2 ) ) ) -> squareRoot ( ) ; return new Segment ( $ side ) ; } | Compute a side A or B from the hypotenuse and one side |
232,887 | public function createFromImportedData ( $ data ) { $ revision = new Revision ( ) ; $ revision -> setReleasedAt ( new \ DateTime ( $ data [ 'released_at' ] ) ) ; $ revision -> setReleasedBy ( $ data [ 'released_by' ] ) ; $ revision -> setComment ( $ data [ 'comment' ] ) ; foreach ( $ data [ 'groups' ] as $ groupData ) ... | Create Revision instance from imported data . |
232,888 | public function identQuote ( string $ name ) { return $ this -> iquotechar . str_replace ( $ this -> iquotechar , $ this -> iquotechar . $ this -> iquotechar , $ name ) . $ this -> iquotechar ; } | Quote the name of an identity |
232,889 | public function getName ( $ entity , $ quote = true ) { if ( is_object ( $ entity ) ) $ entity = $ entity -> getName ( ) ; if ( ! is_string ( $ entity ) ) throw new InvalidTypeException ( "Provide a string or a object with a getName method" ) ; $ entity = $ this -> table_prefix . $ entity ; return $ quote ? $ this -> i... | Return the identity name quoted and prefixed with the configured prefix . |
232,890 | public function truncateTable ( $ table ) { $ query = "TRUNCATE " . $ this -> getName ( $ table -> getName ( ) ) ; $ this -> db -> exec ( $ query ) ; return $ this ; } | Remove all rows from the table |
232,891 | public function toSQL ( Parameters $ params , Query \ Clause $ clause , bool $ inner_clause = false ) { $ params -> setDriver ( $ this ) ; return $ clause -> toSQL ( $ params , $ inner_clause ) ; } | Write an query clause as SQL query syntax |
232,892 | public static function fromNative ( ) { $ args = func_get_args ( ) ; $ hour = new Hour ( $ args [ 0 ] ) ; $ minute = new Minute ( $ args [ 1 ] ) ; $ second = new Second ( $ args [ 2 ] ) ; return new static ( $ hour , $ minute , $ second ) ; } | Returns a nee Time object from native int hour minute and second |
232,893 | public static function fromNativeDateTime ( \ DateTime $ time ) { $ hour = \ intval ( $ time -> format ( 'G' ) ) ; $ minute = \ intval ( $ time -> format ( 'i' ) ) ; $ second = \ intval ( $ time -> format ( 's' ) ) ; return static :: fromNative ( $ hour , $ minute , $ second ) ; } | Returns a new Time from a native PHP \ DateTime |
232,894 | public function sameValueAs ( ValueObjectInterface $ time ) { if ( false === Util :: classEquals ( $ this , $ time ) ) { return false ; } return $ this -> getHour ( ) -> sameValueAs ( $ time -> getHour ( ) ) && $ this -> getMinute ( ) -> sameValueAs ( $ time -> getMinute ( ) ) && $ this -> getSecond ( ) -> sameValueAs ... | Tells whether two Time are equal by comparing their values |
232,895 | public static function factory ( $ resource = '' , $ size = null ) { $ type = gettype ( $ resource ) ; if ( $ type == 'string' ) { $ stream = fopen ( 'php://temp' , 'r+' ) ; if ( $ resource !== '' ) { fwrite ( $ stream , $ resource ) ; fseek ( $ stream , 0 ) ; } return new self ( $ stream ) ; } if ( $ type == 'resource... | Create a new stream based on the input type |
232,896 | protected function getModuleInfo ( ) : array { if ( $ this -> moduleInfo === null ) { $ this -> moduleInfo = $ this -> package ( ) -> getExtra ( ) [ 'module' ] ?? [ ] ; } return $ this -> moduleInfo ; } | Resolve module info |
232,897 | protected function resolveTitle ( ) : string { $ title = trim ( $ this -> getModuleInfo ( ) [ 'title' ] ?? '' ) ; if ( empty ( $ title ) ) { $ name = substr ( $ this -> name , strpos ( $ this -> name , '/' ) + 1 ) ; $ name = array_map ( function ( $ value ) { return strtolower ( $ value ) ; } , explode ( '-' , $ name )... | Resolve module s title |
232,898 | protected function resolveDirectory ( string $ name ) : string { $ dir = rtrim ( $ this -> manager -> vendorDir ( ) , DIRECTORY_SEPARATOR ) . DIRECTORY_SEPARATOR ; $ dir .= rtrim ( implode ( DIRECTORY_SEPARATOR , explode ( '/' , $ name ) ) , DIRECTORY_SEPARATOR ) ; return $ dir ; } | Resolve module s directory |
232,899 | protected function resolveCollector ( ) : ? string { $ value = $ this -> getModuleInfo ( ) [ 'collector' ] ?? null ; return is_string ( $ value ) ? $ value : null ; } | Resolve collector class |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.