idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
700 | public function splice ( $ offset , $ length = null , $ replacement = [ ] ) { if ( func_num_args ( ) == 1 ) { return new DataStore ( array_splice ( $ this -> rows , $ offset ) , $ this -> metaData ) ; } return new DataStore ( array_splice ( $ this -> rows , $ offset , $ length , $ replacement ) , $ this -> metaData ) ;... | Splice the data and replace |
701 | public function where ( $ key , $ value ) { $ dstore = new DataStore ; $ dstore -> meta ( $ this -> metaData ) ; foreach ( $ this -> rows as $ row ) { if ( $ row [ $ key ] == $ value ) { $ dstore -> append ( $ row ) ; } } return $ dstore ; } | Return rows that has column equal to certain value |
702 | public function whereIn ( $ key , $ values = array ( ) ) { $ dstore = new DataStore ; $ dstore -> meta ( $ this -> metaData ) ; foreach ( $ this -> rows as $ row ) { if ( in_array ( $ row [ $ key ] , $ values ) ) { $ dstore -> append ( $ row ) ; } } return $ dstore ; } | Return rows that column contains value in an array . |
703 | private function _mapKeyIndex ( $ arr , $ keys ) { $ maps = array ( ) ; foreach ( $ arr as $ index => $ row ) { $ key = "n" ; foreach ( $ keys as $ cName ) { $ key .= $ row [ $ cName ] ; } if ( ! isset ( $ maps [ $ key ] ) ) { $ maps [ $ key ] = array ( ) ; } array_push ( $ maps [ $ key ] , $ index ) ; } return $ maps ... | Map Key Index |
704 | public function join ( $ secondStore , $ matching ) { $ dstore = new DataStore ; $ firstKeys = array_keys ( $ matching ) ; $ secondKeys = array_values ( $ matching ) ; $ firstMaps = $ this -> _mapKeyIndex ( $ this -> rows , $ firstKeys ) ; $ secondMaps = $ this -> _mapKeyIndex ( $ secondStore -> all ( ) , $ secondKeys ... | Join with another datastore on a matching keys |
705 | public function leftJoin ( $ secondStore , $ matching ) { $ dstore = new DataStore ; $ firstKeys = array_keys ( $ matching ) ; $ secondKeys = array_values ( $ matching ) ; $ firstMaps = $ this -> _mapKeyIndex ( $ this -> rows , $ firstKeys ) ; $ secondMaps = $ this -> _mapKeyIndex ( $ secondStore -> all ( ) , $ secondK... | Left join with another datastore on matching keys |
706 | public function columnMeta ( $ settings ) { foreach ( $ settings as $ cName => $ cMeta ) { if ( isset ( $ this -> metaData [ "columns" ] ) && $ this -> metaData [ "columns" ] [ $ cName ] ) { $ this -> metaData [ "columns" ] [ $ cName ] = array_merge ( $ this -> metaData [ "columns" ] [ $ cName ] , $ cMeta ) ; } } retur... | Add extra column meta to existing |
707 | public function offsetSet ( $ index , $ row ) { if ( is_null ( $ index ) ) { $ this -> rows [ ] = $ row ; } else { $ this -> rows [ $ index ] = $ row ; } } | Implement offsetSet for ArrayAccess interface |
708 | public function offsetGet ( $ index ) { return isset ( $ this -> rows [ $ index ] ) ? $ this -> rows [ $ index ] : null ; } | Implement offsetGet for ArrayAccess interface |
709 | public function publishAssetFolder ( $ fullLocalPath , $ version = "" ) { $ fullLocalPath = Utility :: standardizePathSeparator ( $ fullLocalPath ) ; $ fullLocalPath = Utility :: getSymbolicPath ( $ fullLocalPath ) ; $ assets = Utility :: get ( $ this -> report -> getSettings ( ) , "assets" ) ; $ document_root = Utilit... | Copy private asset folder to public place and return public asset url |
710 | protected function addScriptFile ( $ src , $ options = array ( ) , $ at = "begin" ) { $ options [ "type" ] = Utility :: get ( $ options , "type" , "text/javascript" ) ; $ options [ "src" ] = $ src ; $ this -> tags [ md5 ( $ src ) ] = array ( "at" => $ at , "tag" => "script" , "options" => $ options , "content" => "" , ... | Add script file to report |
711 | protected function addScript ( $ script , $ options = array ( ) , $ at = 'begin' ) { $ options [ "type" ] = Utility :: get ( $ options , "type" , "text/javascript" ) ; $ this -> tags [ md5 ( $ script ) ] = array ( "at" => $ at , "tag" => "script" , "options" => $ options , "content" => $ script , ) ; return $ this ; } | Add a custom script to the report |
712 | public function addStyle ( $ style , $ options = array ( ) ) { $ options [ "type" ] = Utility :: get ( $ options , "type" , "text/css" ) ; $ this -> tags [ md5 ( $ style ) ] = array ( "at" => 'begin' , "tag" => "style" , "options" => $ options , "content" => $ style , ) ; return $ this ; } | Adding a css style to report |
713 | public function addCssFile ( $ href , $ options = array ( ) ) { $ options [ "type" ] = Utility :: get ( $ options , "type" , "text/css" ) ; $ options [ "rel" ] = Utility :: get ( $ options , "rel" , "stylesheet" ) ; $ options [ "href" ] = $ href ; $ this -> tags [ md5 ( $ href ) ] = array ( "at" => 'begin' , "tag" => "... | Adding a css file to the report |
714 | public function addLinkTag ( $ options ) { $ unique = "u" ; foreach ( $ options as $ key => $ value ) { $ unique .= "[$key=$value]" ; } $ this -> tags [ md5 ( $ unique ) ] = array ( "at" => 'begin' , "tag" => "link" , "options" => $ options , "content" => "" , ) ; return $ this ; } | Add a link tag to the page |
715 | public function renderTag ( $ tag ) { $ str = "<" . $ tag [ "tag" ] ; foreach ( $ tag [ "options" ] as $ key => $ value ) { $ str .= " $key='$value'" ; } $ str .= ">" . $ tag [ "content" ] . "</" . $ tag [ "tag" ] . ">" ; return $ str ; } | Render a tag |
716 | public function process ( & $ content ) { $ begin = "" ; $ end = "" ; foreach ( $ this -> tags as $ tag ) { if ( $ tag [ "at" ] == "begin" ) { $ begin .= $ this -> renderTag ( $ tag ) ; } else { $ end .= $ this -> renderTag ( $ tag ) ; } } if ( $ begin !== '' ) { $ count = 0 ; $ content = preg_replace ( '/(<body\b[^>]*... | Take content of report and adds resource to content |
717 | public function pipe ( $ node ) { array_push ( $ this -> destinations , $ node ) ; $ node -> source ( $ this ) ; return $ node ; } | Add a new node that this node will send data to |
718 | public function previous ( $ index = 0 ) { if ( count ( $ this -> sources ) > 0 ) { return Utility :: get ( $ this -> sources , $ index ) ; } return null ; } | Get the previous source that send data to this node |
719 | public function next ( $ data ) { if ( $ this -> destinations != null ) { foreach ( $ this -> destinations as $ node ) { $ node -> input ( $ data , $ this ) ; } } } | Send data row to the next destinations |
720 | public function startInput ( $ source ) { $ this -> streamingSource = $ source ; $ this -> is_ended = false ; $ this -> onInputStart ( ) ; foreach ( $ this -> destinations as $ node ) { $ node -> startInput ( $ this ) ; } } | Receive signal from source node that this node will be about to receive data |
721 | public function endInput ( $ source ) { $ this -> streamingSource = $ source ; $ sourceAllEnded = true ; foreach ( $ this -> sources as $ src ) { $ sourceAllEnded &= $ src -> isEnded ( ) ; } if ( $ sourceAllEnded ) { $ this -> is_ended = true ; $ this -> onInputEnd ( ) ; foreach ( $ this -> destinations as $ node ) { $... | The source will call this method to tell that it finishes sending data |
722 | protected function sendMeta ( $ metaData ) { foreach ( $ this -> destinations as $ node ) { $ node -> receiveMeta ( $ metaData , $ this ) ; } } | Sending meta data to next nodes |
723 | public function receiveMeta ( $ metaData , $ source ) { $ this -> streamingSource = $ source ; $ this -> metaData = $ metaData ; $ metaData = $ this -> onMetaReceived ( $ metaData ) ; $ this -> sendMeta ( $ metaData ) ; } | Recieving meta data from the source |
724 | public function requestDataSending ( ) { if ( ! $ this -> isEnded ( ) ) { foreach ( $ this -> sources as $ source ) { $ source -> requestDataSending ( ) ; } } return $ this ; } | Request source nodes to send data . |
725 | public static function js ( ) { $ jsPath = dirname ( __FILE__ ) . "/clients/core/KoolReport.js" ; if ( is_file ( $ jsPath ) ) { return "<script type='text/javascript'>" . preg_replace ( '/\s+/S' , " " , file_get_contents ( $ jsPath ) ) . "</script>" ; } else { throw new \ Exception ( "Could not find KoolReport.js" ) ; ... | Return the javascript of KoolReport |
726 | public function registerEvent ( $ name , $ methodName , $ prepend = false ) { if ( ! isset ( $ this -> events [ $ name ] ) ) { $ this -> events [ $ name ] = array ( ) ; } if ( ! in_array ( $ methodName , $ this -> events [ $ name ] ) ) { if ( $ prepend ) { array_unshift ( $ this -> events [ $ name ] , $ methodName ) ; ... | Register callback function to be called on certain events |
727 | public function fireEvent ( $ name , $ params = null ) { $ handleList = Utility :: get ( $ this -> events , $ name , null ) ; $ result = true ; if ( $ handleList ) { foreach ( $ handleList as $ methodName ) { if ( gettype ( $ methodName ) == "string" ) { $ return = $ this -> $ methodName ( $ params ) ; } else { $ retur... | Fire an event with parameters in array form |
728 | protected function getServiceConstructs ( ) { $ serviceConstructs = array ( ) ; $ public_methods = get_class_methods ( $ this ) ; foreach ( $ public_methods as $ method ) { if ( strpos ( $ method , "__construct" ) === 0 && strlen ( $ method ) > 11 ) { array_push ( $ serviceConstructs , $ method ) ; } } return $ service... | Return list of contruction methods of services |
729 | protected function src ( $ name = null ) { $ dataSources = Utility :: get ( $ this -> reportSettings , "dataSources" , array ( ) ) ; if ( count ( $ dataSources ) == 0 ) { throw new \ Exception ( "There is no source available, please add at least one in the settings()" ) ; return false ; } if ( ! $ name ) { $ name = Uti... | Get a new source |
730 | public function dataStore ( $ name ) { if ( gettype ( $ name ) == "string" ) { if ( ! isset ( $ this -> dataStores [ $ name ] ) ) { $ this -> dataStores [ $ name ] = new DataStore ; } return $ this -> dataStores [ $ name ] ; } else { return $ name ; } } | Get the data store with a name if not found create a new one |
731 | public function run ( ) { if ( $ this -> fireEvent ( "OnBeforeRun" ) ) { if ( $ this -> dataSources != null ) { foreach ( $ this -> dataSources as $ dataSource ) { if ( ! $ dataSource -> isEnded ( ) ) { $ dataSource -> start ( ) ; } } } } $ this -> fireEvent ( "OnRunEnd" ) ; return $ this ; } | Run the report |
732 | public function debug ( ) { $ oldActiveReport = ( isset ( $ GLOBALS [ "__ACTIVE_KOOLREPORT__" ] ) ) ? $ GLOBALS [ "__ACTIVE_KOOLREPORT__" ] : null ; $ GLOBALS [ "__ACTIVE_KOOLREPORT__" ] = $ this ; include dirname ( __FILE__ ) . "/debug.view.php" ; if ( $ oldActiveReport === null ) { unset ( $ GLOBALS [ "__ACTIVE_KOOLR... | Return debug view |
733 | public function innerView ( $ view , $ params = null , $ return = false ) { $ currentDir = dirname ( Utility :: getClassPath ( $ this ) ) ; ob_start ( ) ; if ( $ params ) { foreach ( $ params as $ key => $ value ) { $ $ key = $ value ; } } include $ currentDir . "/" . $ view . ".view.php" ; $ content = ob_get_clean ( )... | Render inner view |
734 | protected function onInit ( ) { $ this -> filePath = Utility :: get ( $ this -> params , "filePath" ) ; $ this -> fieldSeparator = Utility :: get ( $ this -> params , "fieldSeparator" , "," ) ; $ this -> charset = Utility :: get ( $ this -> params , "charset" ) ; $ this -> precision = Utility :: get ( $ this -> params ... | Init the datasource |
735 | public static function create ( $ format , $ value = null ) { if ( 0 < func_num_args ( ) ) { $ format = vsprintf ( $ format , array_slice ( func_get_args ( ) , 1 ) ) ; } return new static ( $ format ) ; } | Creates a new exception using a format and values . |
736 | public static function toComponents ( Version $ version ) { return array ( Parser :: MAJOR => $ version -> getMajor ( ) , Parser :: MINOR => $ version -> getMinor ( ) , Parser :: PATCH => $ version -> getPatch ( ) , Parser :: PRE_RELEASE => $ version -> getPreRelease ( ) , Parser :: BUILD => $ version -> getBuild ( ) )... | Returns the components of a Version instance . |
737 | public static function toString ( Version $ version ) { return sprintf ( '%d.%d.%d%s%s' , $ version -> getMajor ( ) , $ version -> getMinor ( ) , $ version -> getPatch ( ) , $ version -> getPreRelease ( ) ? '-' . join ( '.' , $ version -> getPreRelease ( ) ) : '' , $ version -> getBuild ( ) ? '+' . join ( '.' , $ versi... | Returns the string representation of a Version instance . |
738 | public static function compareTo ( Version $ left , Version $ right ) { switch ( true ) { case ( $ left -> getMajor ( ) < $ right -> getMajor ( ) ) : return self :: LESS_THAN ; case ( $ left -> getMajor ( ) > $ right -> getMajor ( ) ) : return self :: GREATER_THAN ; case ( $ left -> getMinor ( ) > $ right -> getMinor (... | Compares one version with another . |
739 | public static function isEqualTo ( Version $ left , Version $ right ) { return ( self :: EQUAL_TO === self :: compareTo ( $ left , $ right ) ) ; } | Checks if the left version is equal to the right . |
740 | public static function isGreaterThan ( Version $ left , Version $ right ) { return ( self :: GREATER_THAN === self :: compareTo ( $ left , $ right ) ) ; } | Checks if the left version is greater than the right . |
741 | public static function isLessThan ( Version $ left , Version $ right ) { return ( self :: LESS_THAN === self :: compareTo ( $ left , $ right ) ) ; } | Checks if the left version is less than the right . |
742 | public static function compareIdentifiers ( array $ left , array $ right ) { if ( $ left && empty ( $ right ) ) { return self :: LESS_THAN ; } elseif ( empty ( $ left ) && $ right ) { return self :: GREATER_THAN ; } $ l = $ left ; $ r = $ right ; $ x = self :: GREATER_THAN ; $ y = self :: LESS_THAN ; if ( count ( $ l )... | Compares the identifier components of the left and right versions . |
743 | public function findRecent ( Version $ version , $ major = false , $ pre = false ) { $ current = null ; $ major = $ major ? $ version -> getMajor ( ) : null ; foreach ( $ this -> updates as $ update ) { if ( $ major && ( $ major !== $ update -> getVersion ( ) -> getMajor ( ) ) ) { continue ; } if ( ( false === $ pre ) ... | Finds the most recent update and returns it . |
744 | public function copyTo ( $ file ) { if ( null === $ this -> file ) { throw LogicException :: create ( 'The update file has not been downloaded.' ) ; } $ mode = 0755 ; if ( file_exists ( $ file ) ) { $ mode = fileperms ( $ file ) & 511 ; } if ( false === @ copy ( $ this -> file , $ file ) ) { throw FileException :: last... | Copies the update file to the destination . |
745 | public function deleteFile ( ) { if ( $ this -> file ) { if ( file_exists ( $ this -> file ) ) { if ( false === @ unlink ( $ this -> file ) ) { throw FileException :: lastError ( ) ; } } if ( file_exists ( $ this -> file . '.pubkey' ) ) { if ( false === @ unlink ( $ this -> file . '.pubkey' ) ) { throw FileException ::... | Cleans up by deleting the temporary update file . |
746 | public function getFile ( ) { if ( null === $ this -> file ) { unlink ( $ this -> file = tempnam ( sys_get_temp_dir ( ) , 'upd' ) ) ; mkdir ( $ this -> file ) ; $ this -> file .= DIRECTORY_SEPARATOR . $ this -> name ; $ in = new SplFileObject ( $ this -> url , 'rb' , false ) ; $ out = new SplFileObject ( $ this -> file... | Downloads the update file to a temporary location . |
747 | public function update ( $ version , $ major = false , $ pre = false ) { if ( false === ( $ version instanceof Version ) ) { $ version = Parser :: toVersion ( $ version ) ; } if ( null !== ( $ update = $ this -> manifest -> findRecent ( $ version , $ major , $ pre ) ) ) { $ update -> getFile ( ) ; $ update -> copyTo ( ... | Updates the running Phar if any is available . |
748 | public function callMethod ( $ class , $ method , array $ args = array ( ) ) { $ method = $ this -> findMethod ( $ class , $ method ) ; $ method -> setAccessible ( true ) ; return $ method -> invokeArgs ( is_object ( $ class ) ? $ class : null , $ args ) ; } | Calls a class or object method . |
749 | public function copyPath ( $ from , $ to , $ replace = true , $ purge = true ) { if ( false === file_exists ( $ from ) ) { throw FileSystemException :: invalidPath ( $ from ) ; } if ( is_dir ( $ from ) ) { if ( false === file_exists ( $ to ) ) { if ( false === @ mkdir ( $ to ) ) { throw FileSystemException :: lastError... | Recursively copies a file or directory tree to another location . |
750 | public function createDir ( $ name = null ) { unlink ( $ dir = $ this -> createFile ( ) ) ; if ( false === mkdir ( $ dir ) ) { throw FileSystemException :: lastError ( $ dir ) ; } if ( null !== $ name ) { $ dir .= DIRECTORY_SEPARATOR . $ name ; if ( false === mkdir ( $ dir ) ) { throw FileSystemException :: lastError (... | Creates a temporary directory path that will be automatically purged at the end of the test . |
751 | public function createFile ( $ name = null ) { if ( null === $ name ) { if ( false === ( $ file = tempnam ( sys_get_temp_dir ( ) , 'tst' ) ) ) { throw FileSystemException :: lastError ( $ name ) ; } $ this -> purgePaths [ ] = $ file ; } else { if ( false === touch ( $ file = $ this -> createDir ( ) . DIRECTORY_SEPARATO... | Creates a temporary file path that will be automatically purged at the end of the test . |
752 | public function findMethod ( $ class , $ name ) { $ reflection = new ReflectionClass ( $ class ) ; while ( false === $ reflection -> hasMethod ( $ name ) ) { if ( false === ( $ reflection = $ reflection -> getParentClass ( ) ) ) { throw new ReflectionException ( sprintf ( 'The method "%s" does not exist in the class "%... | Finds a class method and returns the ReflectionMethod instance . |
753 | public function findProperty ( $ class , $ name ) { $ reflection = new ReflectionClass ( $ class ) ; while ( false === $ reflection -> hasProperty ( $ name ) ) { if ( false === ( $ reflection = $ reflection -> getParentClass ( ) ) ) { throw new ReflectionException ( sprintf ( 'The property "%s" does not exist in the cl... | Finds a class property and returns the ReflectionProperty instance . |
754 | public function getPropertyValue ( $ class , $ name ) { $ property = $ this -> findProperty ( $ class , $ name ) ; $ property -> setAccessible ( true ) ; return $ property -> getValue ( is_object ( $ class ) ? $ class : null ) ; } | Returns the value of the property . |
755 | public function purgePath ( $ path ) { if ( false === file_exists ( $ path ) ) { throw FileSystemException :: invalidPath ( $ path ) ; } if ( is_dir ( $ path ) ) { if ( false === ( $ dh = @ opendir ( $ path ) ) ) { throw FileSystemException :: lastError ( $ path ) ; } while ( false !== ( $ item = readdir ( $ dh ) ) ) {... | Recursively deletes a file or directory tree . |
756 | protected function tearDown ( ) { foreach ( $ this -> purgePaths as $ path ) { if ( file_exists ( $ path ) ) { $ this -> purgePath ( $ path ) ; } } } | Purges the created paths and reverts changes made by Runkit . |
757 | public function getVersion ( ) { return new Version ( $ this -> major , $ this -> minor , $ this -> patch , $ this -> preRelease , $ this -> build ) ; } | Returns a readonly Version instance . |
758 | public function importComponents ( array $ components ) { if ( isset ( $ components [ Parser :: BUILD ] ) ) { $ this -> build = $ components [ Parser :: BUILD ] ; } else { $ this -> build = array ( ) ; } if ( isset ( $ components [ Parser :: MAJOR ] ) ) { $ this -> major = $ components [ Parser :: MAJOR ] ; } else { $ ... | Imports the version components . |
759 | public function importVersion ( $ version ) { return $ this -> setMajor ( $ version -> getMajor ( ) ) -> setMinor ( $ version -> getMinor ( ) ) -> setPatch ( $ version -> getPatch ( ) ) -> setPreRelease ( $ version -> getPreRelease ( ) ) -> setBuild ( $ version -> getBuild ( ) ) ; } | Imports an existing Version instance . |
760 | public function incrementMajor ( $ amount = 1 ) { $ this -> major += $ amount ; $ this -> minor = 0 ; $ this -> patch = 0 ; return $ this ; } | Increments the major version number and resets the minor and patch version numbers to zero . |
761 | public function setBuild ( array $ identifiers ) { foreach ( $ identifiers as $ identifier ) { if ( ! Validator :: isIdentifier ( $ identifier ) ) { throw new InvalidIdentifierException ( $ identifier ) ; } } $ this -> build = $ identifiers ; return $ this ; } | Sets the build metadata identifiers . |
762 | public function setMajor ( $ number ) { if ( ! Validator :: isNumber ( $ number ) ) { throw new InvalidNumberException ( $ number ) ; } $ this -> major = intval ( $ number ) ; return $ this ; } | Sets the major version number . |
763 | public function setMinor ( $ number ) { if ( ! Validator :: isNumber ( $ number ) ) { throw new InvalidNumberException ( $ number ) ; } $ this -> minor = intval ( $ number ) ; return $ this ; } | Sets the minor version number . |
764 | public function setPatch ( $ number ) { if ( ! Validator :: isNumber ( $ number ) ) { throw new InvalidNumberException ( $ number ) ; } $ this -> patch = intval ( $ number ) ; return $ this ; } | Sets the patch version number . |
765 | public function setPreRelease ( array $ identifiers ) { foreach ( $ identifiers as $ identifier ) { if ( ! Validator :: isIdentifier ( $ identifier ) ) { throw new InvalidIdentifierException ( $ identifier ) ; } } $ this -> preRelease = $ identifiers ; return $ this ; } | Sets the pre - release version identifiers . |
766 | public static function toComponents ( $ version ) { if ( ! Validator :: isVersion ( $ version ) ) { throw new InvalidStringRepresentationException ( $ version ) ; } if ( false !== strpos ( $ version , '+' ) ) { list ( $ version , $ build ) = explode ( '+' , $ version ) ; $ build = explode ( '.' , $ build ) ; } if ( fal... | Returns the components of the string representation . |
767 | public static function toVersion ( $ version ) { $ components = self :: toComponents ( $ version ) ; return new Version ( $ components [ 'major' ] , $ components [ 'minor' ] , $ components [ 'patch' ] , $ components [ 'pre' ] , $ components [ 'build' ] ) ; } | Returns a Version instance for the string representation . |
768 | public function process ( ServerRequestInterface $ request , RequestHandlerInterface $ handler ) : ResponseInterface { $ response = ( new ResponseFactory ) -> createResponse ( ) ; $ analyzer = CorsAnalyzer :: instance ( $ this -> buildSettings ( $ request , $ response ) ) ; if ( $ this -> logger ) { $ analyzer -> setLo... | Execute as PSR - 15 middleware . |
769 | private function buildSettings ( ServerRequestInterface $ request , ResponseInterface $ response ) : CorsSettings { $ settings = new CorsSettings ; $ origin = array_fill_keys ( ( array ) $ this -> options [ "origin" ] , true ) ; $ settings -> setRequestAllowedOrigins ( $ origin ) ; if ( is_callable ( $ this -> options ... | Build a CORS settings object . |
770 | private function methods ( $ methods ) : void { if ( is_callable ( $ methods ) ) { if ( $ methods instanceof Closure ) { $ this -> options [ "methods" ] = $ methods -> bindTo ( $ this ) ; } else { $ this -> options [ "methods" ] = $ methods ; } } else { $ this -> options [ "methods" ] = ( array ) $ methods ; } } | Set request methods to be allowed . |
771 | private function setUserCurrency ( $ currency , $ request ) { $ currency = strtoupper ( $ currency ) ; currency ( ) -> setUserCurrency ( $ currency ) ; $ request -> getSession ( ) -> put ( [ 'currency' => $ currency ] ) ; return $ currency ; } | Set the user currency . |
772 | private function updateFromOpenExchangeRates ( $ defaultCurrency , $ api ) { $ this -> info ( 'Updating currency exchange rates from OpenExchangeRates.org...' ) ; $ content = json_decode ( $ this -> request ( "http://openexchangerates.org/api/latest.json?base={$defaultCurrency}&app_id={$api}&show_alternative=1" ) ) ; i... | Fetch rates from the API |
773 | private function updateFromGoogle ( $ defaultCurrency ) { $ this -> info ( 'Updating currency exchange rates from finance.google.com...' ) ; foreach ( $ this -> currency -> getDriver ( ) -> all ( ) as $ code => $ value ) { if ( $ code === $ defaultCurrency ) { continue ; } $ response = $ this -> request ( 'http://finan... | Fetch rates from Google Finance |
774 | public function registerResources ( ) { if ( $ this -> isLumen ( ) === false ) { $ this -> publishes ( [ __DIR__ . '/../config/currency.php' => config_path ( 'currency.php' ) , ] , 'config' ) ; $ this -> mergeConfigFrom ( __DIR__ . '/../config/currency.php' , 'currency' ) ; } $ this -> publishes ( [ __DIR__ . '/../data... | Register currency resources . |
775 | protected function update ( $ currency ) { if ( ( $ data = $ this -> getCurrency ( $ currency ) ) === null ) { return $ this -> error ( "Currency \"{$currency}\" not found" ) ; } $ this -> output -> write ( "Updating {$currency} currency..." ) ; if ( is_string ( $ result = $ this -> storage -> update ( $ currency , $ d... | Update currency in storage . |
776 | protected function delete ( $ currency ) { $ this -> output -> write ( "Deleting {$currency} currency..." ) ; if ( is_string ( $ result = $ this -> storage -> delete ( $ currency ) ) ) { $ this -> output -> writeln ( '<error>' . ( $ result ? : 'Failed' ) . '</error>' ) ; } else { $ this -> output -> writeln ( "<info>su... | Delete currency from storage . |
777 | protected function getCurrencyArgument ( ) { $ value = preg_replace ( '/\s+/' , '' , $ this -> argument ( 'currency' ) ) ; if ( $ value === 'all' ) { return array_keys ( $ this -> currencies ) ; } return explode ( ',' , $ value ) ; } | Get currency argument . |
778 | protected function getActionArgument ( $ validActions = [ ] ) { $ action = strtolower ( $ this -> argument ( 'action' ) ) ; if ( in_array ( $ action , $ validActions ) === false ) { throw new \ RuntimeException ( "The \"{$action}\" option does not exist." ) ; } return $ action ; } | Get action argument . |
779 | public function format ( $ value , $ code = null , $ include_symbol = true ) { $ code = $ code ? : $ this -> config ( 'default' ) ; $ value = preg_replace ( '/[\s\',!]/' , '' , $ value ) ; if ( $ formatter = $ this -> getFormatter ( ) ) { return $ formatter -> format ( $ value , $ code ) ; } $ format = $ this -> getCur... | Format the value into the desired currency . |
780 | public function isActive ( $ code ) { return $ code && ( bool ) Arr :: get ( $ this -> getCurrency ( $ code ) , 'active' , false ) ; } | Determine if the provided currency is active . |
781 | public function getCurrency ( $ code = null ) { $ code = $ code ? : $ this -> getUserCurrency ( ) ; return Arr :: get ( $ this -> getCurrencies ( ) , strtoupper ( $ code ) ) ; } | Return the current currency if the one supplied is not valid . |
782 | public function getCurrencies ( ) { if ( $ this -> currencies_cache === null ) { if ( config ( 'app.debug' , false ) === true ) { $ this -> currencies_cache = $ this -> getDriver ( ) -> all ( ) ; } else { $ this -> currencies_cache = $ this -> cache -> rememberForever ( 'torann.currency' , function ( ) { return $ this ... | Return all currencies . |
783 | public function getDriver ( ) { if ( $ this -> driver === null ) { $ config = $ this -> config ( 'drivers.' . $ this -> config ( 'driver' ) , [ ] ) ; $ driver = Arr :: pull ( $ config , 'class' ) ; $ this -> driver = new $ driver ( $ config ) ; } return $ this -> driver ; } | Get storage driver . |
784 | public function getFormatter ( ) { if ( $ this -> formatter === null && $ this -> config ( 'formatter' ) !== null ) { $ config = $ this -> config ( 'formatters.' . $ this -> config ( 'formatter' ) , [ ] ) ; $ class = Arr :: pull ( $ config , 'class' ) ; $ this -> formatter = new $ class ( array_filter ( $ config ) ) ; ... | Get formatter driver . |
785 | protected function getCurrencyProp ( $ code , $ key , $ default = null ) { return Arr :: get ( $ this -> getCurrency ( $ code ) , $ key , $ default ) ; } | Get the given property value from provided currency . |
786 | private function validateEmail ( $ email ) { if ( ! filter_var ( $ email , FILTER_VALIDATE_EMAIL ) ) { throw MakeUserException :: invalidEmail ( $ email ) ; } if ( app ( config ( 'auth.providers.users.model' ) ) -> where ( 'email' , $ email ) -> exists ( ) ) { throw MakeUserException :: emailExists ( $ email ) ; } } | Determine if the given email address already exists . |
787 | protected function putln ( $ prefix , $ message ) { switch ( $ prefix ) { case '!' : $ prefix = "<error>$prefix</error>" ; break ; case '*' : $ prefix = "<info>$prefix</info>" ; break ; case '?' : $ prefix = "<comment>$prefix</comment>" ; break ; case '-' : case '+' : $ prefix = " <comment>$prefix</comment>" ; break ;... | Outputs a message with a colored prefix . |
788 | protected function verbose ( $ message , $ newline = false , $ type = 0 ) { if ( $ this -> isVerbose ( ) ) { $ this -> output -> write ( $ message , $ newline , $ type ) ; } } | Writes the message only when verbosity is set to VERBOSITY_VERBOSE . |
789 | public function getDefaultPath ( ) { if ( false === file_exists ( self :: FILE_NAME ) ) { if ( false === file_exists ( self :: FILE_NAME . '.dist' ) ) { throw new RuntimeException ( sprintf ( 'The configuration file could not be found.' ) ) ; } return realpath ( self :: FILE_NAME . '.dist' ) ; } return realpath ( self ... | Returns the file path to the default configuration file . |
790 | public function loadFile ( $ file = null ) { if ( null === $ file ) { $ file = $ this -> getDefaultPath ( ) ; } $ json = $ this -> json -> decodeFile ( $ file ) ; if ( isset ( $ json -> import ) ) { if ( ! Path :: isAbsolute ( $ json -> import ) ) { $ json -> import = Path :: join ( array ( dirname ( $ file ) , $ json ... | Loads the configuration file and returns it . |
791 | protected function getConfig ( InputInterface $ input ) { $ helper = $ this -> getHelper ( 'config' ) ; return $ helper -> loadFile ( $ input -> getOption ( 'configuration' ) ) ; } | Returns the configuration settings . |
792 | private function contents ( OutputInterface $ output , Traversable $ list , $ indent , $ base , Phar $ phar , $ root ) { foreach ( $ list as $ item ) { $ item = $ phar [ str_replace ( $ root , '' , $ item -> getPathname ( ) ) ] ; if ( false !== $ indent ) { $ output -> write ( str_repeat ( ' ' , $ indent ) ) ; $ path =... | Renders the contents of an iterator . |
793 | private function render ( OutputInterface $ output , array $ attributes ) { $ out = false ; foreach ( $ attributes as $ name => $ value ) { if ( $ out ) { $ output -> writeln ( '' ) ; } $ output -> write ( "<comment>$name:</comment>" ) ; if ( is_array ( $ value ) ) { $ output -> writeln ( '' ) ; foreach ( $ value as $ ... | Renders the list of attributes . |
794 | public function getBasePath ( ) { if ( isset ( $ this -> raw -> { 'base-path' } ) ) { if ( false === is_dir ( $ this -> raw -> { 'base-path' } ) ) { throw new InvalidArgumentException ( sprintf ( 'The base path "%s" is not a directory or does not exist.' , $ this -> raw -> { 'base-path' } ) ) ; } return realpath ( $ th... | Returns the base path . |
795 | public function getBinaryDirectories ( ) { if ( isset ( $ this -> raw -> { 'directories-bin' } ) ) { $ directories = ( array ) $ this -> raw -> { 'directories-bin' } ; $ base = $ this -> getBasePath ( ) ; array_walk ( $ directories , function ( & $ directory ) use ( $ base ) { $ directory = $ base . DIRECTORY_SEPARATOR... | Returns the list of relative directory paths for binary files . |
796 | public function getBinaryDirectoriesIterator ( ) { if ( array ( ) !== ( $ directories = $ this -> getBinaryDirectories ( ) ) ) { return Finder :: create ( ) -> files ( ) -> filter ( $ this -> getBlacklistFilter ( ) ) -> ignoreVCS ( true ) -> in ( $ directories ) ; } return null ; } | Returns the iterator for the binary directory paths . |
797 | public function getBinaryFiles ( ) { if ( isset ( $ this -> raw -> { 'files-bin' } ) ) { $ base = $ this -> getBasePath ( ) ; $ files = array ( ) ; foreach ( ( array ) $ this -> raw -> { 'files-bin' } as $ file ) { $ files [ ] = new SplFileInfo ( $ base . DIRECTORY_SEPARATOR . Path :: canonical ( $ file ) ) ; } return ... | Returns the list of relative paths for binary files . |
798 | public function getBlacklist ( ) { if ( isset ( $ this -> raw -> blacklist ) ) { $ blacklist = ( array ) $ this -> raw -> blacklist ; array_walk ( $ blacklist , function ( & $ file ) { $ file = Path :: canonical ( $ file ) ; } ) ; return $ blacklist ; } return array ( ) ; } | Returns the list of blacklisted relative file paths . |
799 | public function getBlacklistFilter ( ) { $ blacklist = $ this -> getBlacklist ( ) ; $ base = '/^' . preg_quote ( $ this -> getBasePath ( ) . DIRECTORY_SEPARATOR , '/' ) . '/' ; return function ( SplFileInfo $ file ) use ( $ base , $ blacklist ) { $ path = Path :: canonical ( preg_replace ( $ base , '' , $ file -> getPa... | Returns a filter callable for the configured blacklist . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.