idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
19,800 | public function setQuantityAllocation ( $ subscriptionId , $ componentId ) { $ service = $ this -> getService ( ) ; $ rawData = $ this -> getRawData ( array ( 'component' => $ this -> _params ) ) ; $ response = $ service -> request ( 'subscriptions/' . ( int ) $ subscriptionId . '/components/' . ( int ) $ componentId ,... | Set quantity of Quantity Based Components for a subscription |
19,801 | public function listProductFamily ( $ productFamilyId ) { $ service = $ this -> getService ( ) ; $ response = $ service -> request ( 'product_families/' . ( int ) $ productFamilyId . '/components' , 'GET' ) ; $ responseArray = $ this -> getResponseArray ( $ response ) ; if ( ! $ this -> isError ( ) ) { $ this -> _data ... | List components for a product family |
19,802 | public function readProductFamily ( $ productFamilyId , $ componentId ) { $ service = $ this -> getService ( ) ; $ response = $ service -> request ( 'product_families/' . ( int ) $ productFamilyId . '/components/' . ( int ) $ componentId , 'GET' ) ; $ responseArray = $ this -> getResponseArray ( $ response ) ; if ( ! $... | Read a component belonging to a product family |
19,803 | public function createComponent ( $ productFamilyId , $ componentType ) { $ service = $ this -> getService ( ) ; $ rawDataKey = '' ; switch ( $ componentType ) { case 'metered_components' : $ rawDataKey = 'metered_component' ; break ; case 'quantity_based_components' : $ rawDataKey = 'quantity_based_component' ; break ... | Create a component |
19,804 | public function update ( $ id ) { $ service = $ this -> getService ( ) ; $ rawData = $ this -> getRawData ( array ( 'customer' => $ this -> getParams ( ) ) ) ; $ response = $ service -> request ( 'customers/' . ( int ) $ id , 'PUT' , $ rawData ) ; $ responseArray = $ this -> getResponseArray ( $ response ) ; if ( ! $ t... | Update the customer record in Chargify . |
19,805 | public function listProducts ( ) { $ service = $ this -> getService ( ) ; $ response = $ service -> request ( 'products' , 'GET' ) ; $ responseArray = $ this -> getResponseArray ( $ response ) ; if ( ! $ this -> isError ( ) ) { $ this -> _data = $ this -> _normalizeResponseArray ( $ responseArray ) ; } else { $ this ->... | List all products for your site |
19,806 | public function readByChargifyId ( $ id ) { $ service = $ this -> getService ( ) ; $ response = $ service -> request ( 'products/' . $ id , 'GET' ) ; $ responseArray = $ this -> getResponseArray ( $ response ) ; if ( ! $ this -> isError ( ) ) { $ this -> _data = $ responseArray [ 'product' ] ; } else { $ this -> _data ... | Get product details by Chargify ID |
19,807 | public function readByHandle ( $ handle ) { $ service = $ this -> getService ( ) ; $ response = $ service -> request ( 'products/handle/' . $ handle , 'GET' ) ; $ responseArray = $ this -> getResponseArray ( $ response ) ; if ( ! $ this -> isError ( ) ) { $ this -> _data = $ responseArray [ 'product' ] ; } else { $ thi... | Get product details by API handle |
19,808 | protected function buildIssueAdapter ( $ name ) { $ issueAdapter = $ this -> getApplication ( ) -> getAdapterFactory ( ) -> createIssueTracker ( $ name , $ this -> getConfig ( ) -> get ( [ 'adapters' , $ name ] , \ Gush \ Config :: CONFIG_SYSTEM ) , $ this -> getConfig ( ) ) ; $ issueAdapter -> authenticate ( ) ; retur... | Build a valid IssueTracker instance . |
19,809 | public function addAttachmentFromFile ( $ name , $ path , $ mimeType = 'application/octet-stream' , $ contentId = null ) { if ( file_exists ( $ path ) && is_file ( $ path ) && is_readable ( $ path ) ) { $ this -> addAttachmentFromData ( $ name , file_get_contents ( $ path ) , $ mimeType , $ contentId ) ; } } | Add email attachment via file path |
19,810 | public function validate ( ) { if ( count ( $ this -> _to ) == 0 && count ( $ this -> _cc ) == 0 && count ( $ this -> _bcc ) == 0 ) { return new SimpleEmailServiceError ( 'Destination' ) ; } if ( strlen ( $ this -> _source ) == 0 ) { return new SimpleEmailServiceError ( 'EmailSource' ) ; } if ( strlen ( $ this -> _subj... | Validates instance . This is used before attempting a SendEmail or SendRawEmail . |
19,811 | public function buildParameters ( ) { $ params = array ( ) ; if ( ! empty ( $ this -> _attachments ) ) { $ this -> action = 'SendRawEmail' ; $ params [ 'RawMessage.Data' ] = $ this -> _buildRaw ( ) ; return $ params ; } $ i = 1 ; foreach ( $ this -> _to as $ to ) { $ params [ 'Destination.ToAddresses.member.' . $ i ] =... | Build parameters for sendEmail . |
19,812 | private function _buildRaw ( ) { $ boundary = md5 ( uniqid ( rand ( ) , true ) ) ; $ raw_message = 'From: ' . $ this -> _encodeHeader ( $ this -> _source ) . "\n" ; if ( ! empty ( $ this -> _to ) ) { $ raw_message .= 'To: ' . $ this -> _encodeHeader ( $ this -> _to ) . "\n" ; } if ( ! empty ( $ this -> _cc ) ) { $ raw_... | Build raw envelope . |
19,813 | private function _encodeHeader ( $ val ) { if ( is_array ( $ val ) ) { return join ( ', ' , array_map ( array ( $ this , '_encodeHeader' ) , $ val ) ) ; } if ( preg_match ( "/(.*)<(.*)>/" , $ val , $ match ) ) { return '=?' . $ this -> _charset . '?B?' . base64_encode ( $ match [ 1 ] ) . '?= <' . $ match [ 2 ] . '>' ; ... | Encode header field body and return it . |
19,814 | public function generateFromArray ( array $ data ) { $ xml = $ this -> processGenerate ( $ this -> rootName , $ data ) ; $ this -> createPiNode ( ) ; $ this -> getDomDocument ( ) -> appendChild ( $ xml ) ; $ xml = $ this -> getDomDocument ( ) -> saveXML ( ) ; $ this -> flush ( ) ; return $ xml ; } | Process convert array to XML |
19,815 | protected function createPiNode ( ) { $ piNode = $ this -> getPiNode ( ) ; if ( 0 !== count ( $ piNode ) ) { foreach ( $ piNode as $ target => $ data ) { $ xslt = $ this -> getDomDocument ( ) -> createProcessingInstruction ( $ target , $ data ) ; $ this -> getDomDocument ( ) -> appendChild ( $ xslt ) ; } } } | Creates new PI node |
19,816 | protected function processGenerate ( $ element , $ data ) { $ this -> prepareElementName ( $ element ) ; if ( '' === ( string ) $ element ) { $ element = array_keys ( $ data ) [ 0 ] ; return $ this -> processGenerate ( $ element , $ data [ $ element ] ) ; } $ node = $ this -> getDomDocument ( ) -> createElement ( $ ele... | Recursive creation of XML |
19,817 | protected function applyValue ( & $ data , & $ node ) { $ data [ '@value' ] = $ this -> getBooleanAsString ( $ data [ '@value' ] ) ; if ( is_array ( $ data [ '@value' ] ) ) { $ this -> processGenerate ( key ( $ data [ '@value' ] ) , $ data [ '@value' ] ) ; } else { $ node -> appendChild ( $ this -> getDomDocument ( ) -... | Adding element value |
19,818 | protected function getDomDocument ( ) { if ( null === $ this -> domDocument ) { $ this -> domDocument = new \ DOMDocument ( $ this -> getVersion ( ) , $ this -> getEncoding ( ) ) ; $ this -> domDocument -> formatOutput = $ this -> formatOutputFlag ; } return $ this -> domDocument ; } | Gets DomDocument object |
19,819 | protected function prepareElementName ( & $ elementName ) { $ tempElementName = explode ( '_' , $ elementName ) ; $ elementName = isset ( $ tempElementName [ 0 ] ) && is_numeric ( $ tempElementName [ 0 ] ) ? $ tempElementName [ 1 ] : $ elementName ; } | Support for multiple elements with the same name |
19,820 | public static function output ( $ noOldApple = false , $ noAndroid = false , $ noMs = false , $ tileColor = '#FFFFFF' , $ browserConfigFile = '' , $ appName = '' ) { $ result = array ( ) ; if ( ! $ noMs ) { if ( ! $ browserConfigFile ) { $ result [ ] = '<meta name="msapplication-config" content="none" />' ; } else { $ ... | Write meta and link tags |
19,821 | public function runCommand ( $ command , $ allowFailures = false , $ callback = null ) { if ( is_string ( $ command ) ) { $ command = $ this -> parseProcessArguments ( $ command ) ; } $ builder = new ProcessBuilder ( $ command ) ; $ builder -> setWorkingDirectory ( getcwd ( ) ) -> setTimeout ( 3600 ) ; $ process = $ bu... | Run a command through the ProcessBuilder . |
19,822 | public function runCommands ( array $ commands ) { $ output = $ this -> output ; $ callback = function ( $ type , $ buffer ) use ( $ output ) { if ( Process :: ERR === $ type ) { $ output -> write ( '<info>OUT</info> ' . $ buffer ) ; } else { $ output -> write ( '<comment>OUT</comment> ' . $ buffer ) ; } } ; foreach ( ... | Run a series of shell command through a Process . |
19,823 | private function json_validate_zipcode ( ) { if ( ! empty ( $ this -> valueJson ) && is_string ( $ this -> valueJson ) ) { $ ret = @ json_decode ( $ this -> valueJson , true ) ; return ( json_last_error ( ) === JSON_ERROR_NONE && isset ( $ ret [ 'cep' ] ) && isset ( $ ret [ 'logradouro' ] ) && isset ( $ ret [ 'compleme... | validate zipcode format |
19,824 | protected function toRegex ( $ str ) { $ value = Expression :: create ( $ str ) ; if ( $ value -> isGlob ( ) ) { $ value = $ value -> getRegex ( ) ; if ( false === strpos ( $ str , '/' ) ) { $ value -> setStartFlag ( false ) ; } } return $ value -> render ( ) ; } | Converts glob to regexp . |
19,825 | public function getParameter ( InputInterface $ input , $ key ) { $ config = $ this -> getConfig ( ) ; $ adapter = $ input -> getOption ( 'repo-adapter' ) ; if ( $ value = $ config -> get ( [ 'adapters' , $ adapter , $ key ] ) ) { return $ value ; } return $ config -> get ( $ key ) ; } | Gets a specific parameter . |
19,826 | protected function render ( $ templateName , array $ placeholderValuePairs ) { $ resultString = Messages :: get ( $ templateName ) ; foreach ( $ placeholderValuePairs as $ placeholder => $ value ) { $ resultString = str_replace ( '{{ ' . $ placeholder . ' }}' , $ value , $ resultString ) ; } return $ resultString ; } | Render a string from the Messages library . |
19,827 | protected function initialize ( InputInterface $ input , OutputInterface $ output ) { $ this -> getApplication ( ) -> getDispatcher ( ) -> dispatch ( GushEvents :: INITIALIZE , new ConsoleCommandEvent ( $ this , $ input , $ output ) ) ; } | We override the initialize function as this is the only place where we can dispatch an event which can validate the input when it has been bound with values . |
19,828 | private function guardCommitsBetweenLocalBranchAndRemoteBaseBranch ( $ org , $ repo , $ branch , $ sourceBranch ) { $ gitHelper = $ this -> getHelper ( 'git' ) ; if ( ! $ commitCount = $ gitHelper -> getCommitCountBetweenLocalAndBase ( $ org , $ branch , $ sourceBranch ) ) { throw new UserException ( sprintf ( 'Cannot ... | Gets the number of commits between local and base branch failing if there isn t any . |
19,829 | protected function defaultCurlOptions ( ) { $ result = parent :: defaultCurlOptions ( ) ; $ result [ CURLOPT_NOSIGNAL ] = 1 ; if ( $ this -> speed == self :: SPEED_LONG || $ this -> big ) { $ result [ CURLOPT_CONNECTTIMEOUT_MS ] = 60000 ; $ result [ CURLOPT_TIMEOUT_MS ] = 60000 ; $ this -> big = false ; } else { $ resu... | Returns default cURL options . |
19,830 | public function prepareArrayBeforeToXmlConvert ( array $ data , $ primaryKey = '' ) { $ result = [ ] ; $ iterator = new RecursiveArrayIterator ( $ data ) ; $ this -> arrayWalk ( $ iterator , $ result , '' ) ; return '' !== ( string ) $ primaryKey ? [ $ primaryKey => $ result ] : $ result ; } | Preparing the array to convert to XML |
19,831 | protected function arrayWalk ( RecursiveArrayIterator $ iterator , & $ result , $ primaryKey ) { while ( $ iterator -> valid ( ) ) { if ( $ iterator -> hasChildren ( ) ) { if ( $ iterator -> getChildren ( ) -> hasChildren ( ) ) { $ this -> arrayWalk ( $ iterator -> getChildren ( ) , $ result [ $ iterator -> key ( ) ] ,... | Recursive traversal of array |
19,832 | public static function validateEnums ( InputInterface $ input , $ domain , $ types = [ ] ) { $ ret = [ ] ; foreach ( $ types as $ type ) { $ v = $ input -> getOption ( $ type ) ; if ( null !== $ v ) { self :: validateEnum ( $ domain , $ type , $ v ) ; $ ret [ $ type ] = $ v ; } } return $ ret ; } | Validate the given enum fields in the given Input . |
19,833 | public static function validateEnum ( $ domain , $ type , $ value ) { self :: validateEnumDomainAndType ( $ domain , $ type ) ; if ( ! in_array ( $ value , self :: $ enum [ $ domain ] [ $ type ] [ 'values' ] , true ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Unknown value "%s" for "%s"' , $ value , $ type )... | Check if a given value is a valid enum . |
19,834 | public static function formatEnum ( $ domain , $ type ) { self :: validateEnumDomainAndType ( $ domain , $ type ) ; return sprintf ( '%s (One of <comment>%s</comment>)' , self :: $ enum [ $ domain ] [ $ type ] [ 'desc' ] , implode ( '</comment>, <comment>' , self :: $ enum [ $ domain ] [ $ type ] [ 'values' ] ) ) ; } | Return a description for the given enum type . |
19,835 | public function applyProfileOpenApiBindings ( ) { $ this -> openAPI -> info = $ this -> profile [ 'openapi_bindings' ] [ 'info' ] ; if ( isset ( $ this -> profile [ 'openapi_bindings' ] [ 'security' ] ) ) { $ this -> openAPI -> security = $ this -> profile [ 'openapi_bindings' ] [ 'security' ] ; } if ( isset ( $ this -... | Apply profile Open API bindings provided from configuration file |
19,836 | public function processRoutes ( $ routes ) { if ( is_null ( $ this -> openAPI -> paths ) ) { $ this -> openAPI -> paths = [ ] ; } foreach ( $ routes as $ route ) { $ this -> processRoute ( $ route ) ; } } | Process routes and create path item objects on the root Open API document . |
19,837 | protected function getDocBlockOperationId ( $ docBlock ) { $ apiOperationIdTags = $ docBlock -> getTagsByName ( 'OpenApiOperationId' ) ; if ( count ( $ apiOperationIdTags ) > 0 ) { $ apiOperationIdTag = $ apiOperationIdTags [ 0 ] ; $ apiOperationId = trim ( str_replace ( '@OpenApiOperationId' , '' , $ apiOperationIdTag... | Return the OpenAPI Operation Id from a doc block or null if not found . |
19,838 | protected function getDocBlockOperationTags ( $ docBlock ) { $ apiOperationTagTags = $ docBlock -> getTagsByName ( 'OpenApiOperationTag' ) ; foreach ( $ apiOperationTagTags as $ apiOperationTagTag ) { $ apiOperationTag = trim ( str_replace ( '@OpenApiOperationTag' , '' , $ apiOperationTagTag -> render ( ) ) ) ; if ( st... | Return the OpenAPI Operation Tags from a doc block . |
19,839 | protected function getDocBlockExtraParameterRefTags ( $ docBlock ) { $ results = [ ] ; $ apiExtraParameterRefTags = $ docBlock -> getTagsByName ( 'OpenApiExtraParameterRef' ) ; foreach ( $ apiExtraParameterRefTags as $ apiExtraParameterRefTag ) { $ apiExtraParameterRef = trim ( str_replace ( '@OpenApiExtraParameterRef'... | Return the OpenAPI Extra Parameter Ref Tags from a doc block . |
19,840 | protected function getValidationRulesSchemaRequired ( $ validationRules ) { $ required = [ ] ; foreach ( $ validationRules as $ propertyName => $ rulesString ) { $ propertyRules = explode ( '|' , $ rulesString ) ; foreach ( $ propertyRules as $ rule ) { $ explodedRule = explode ( ':' , $ rule ) ; $ ruleName = $ explode... | Get schema required array from validation rules or null if no required fields |
19,841 | protected function getPropertyValidationRulesSchema ( $ propertyRules , $ errorContext , $ logCommandError = false ) { $ schema = new Schema ( ) ; foreach ( $ propertyRules as $ rule ) { $ explodedRule = explode ( ':' , $ rule ) ; $ ruleName = $ explodedRule [ 0 ] ; if ( count ( $ explodedRule ) > 1 ) { $ ruleParams = ... | Return a new schema based on validation rules for a property . |
19,842 | protected function getRoutePathParameters ( $ route ) { $ parameters = [ ] ; $ routeAction = $ route -> getAction ( ) ; list ( $ class , $ method ) = explode ( '@' , $ routeAction [ 'uses' ] ) ; $ reflection = new ReflectionClass ( $ class ) ; $ reflectionMethod = $ reflection -> getMethod ( $ method ) ; foreach ( $ re... | Try to get route method path parameters |
19,843 | protected function getRouteControllerDocBlock ( $ route ) { $ routeAction = $ route -> getAction ( ) ; list ( $ class , $ method ) = explode ( '@' , $ routeAction [ 'uses' ] ) ; $ reflectionClass = new ReflectionClass ( $ class ) ; $ comment = $ reflectionClass -> getDocComment ( ) ; if ( $ comment ) { return ( $ this ... | Return route controller class doc block if comments are provided else return null . |
19,844 | protected function getRouteMethodDocBlock ( $ route ) { $ routeAction = $ route -> getAction ( ) ; list ( $ class , $ method ) = explode ( '@' , $ routeAction [ 'uses' ] ) ; $ reflectionClass = new ReflectionClass ( $ class ) ; $ reflectionMethod = $ reflectionClass -> getMethod ( $ method ) ; $ comment = $ reflectionM... | Return route method doc block if comments are provided else return null . |
19,845 | protected function getRouteCallExampleResponse ( $ route , $ method ) { $ url = $ this -> getRouteUrlWithBindings ( $ route ) ; $ response = $ this -> callRoute ( $ method , $ url , [ ] ) ; if ( is_null ( $ response ) ) { return null ; } if ( is_object ( $ response ) ) { $ response = $ response -> content ( ) ; } retur... | Call the specified route to get an example response |
19,846 | protected function getRouteUrlWithBindings ( $ route ) { $ urlRouteBindings = [ ] ; $ urlInjectedBindings = [ ] ; $ routeAction = $ route -> getAction ( ) ; if ( isset ( $ routeAction [ 'as' ] ) ) { if ( isset ( $ this -> profile [ 'api_calls_bindings' ] ) ) { foreach ( $ this -> profile [ 'api_calls_bindings' ] as $ a... | Return the route url to call with bindings from configuration files . |
19,847 | public function trimXmlString ( $ xmlString ) { $ xmlString = preg_replace ( '/[\r\n]+(?![^(]*\))/' , '' , $ xmlString ) ; $ xmlString = preg_replace ( '/[\s]{2,}/' , ' ' , $ xmlString ) ; $ xmlString = str_replace ( [ "\r\n" , "\n" ] , '' , $ xmlString ) ; return trim ( $ xmlString ) ; } | Removing all spaces and line breaks |
19,848 | public function formatXmlString ( $ xmlString ) { if ( true === $ this -> isXml ( $ xmlString ) ) { $ dom = new \ DOMDocument ; $ dom -> preserveWhiteSpace = false ; $ dom -> loadXML ( $ xmlString ) ; $ dom -> formatOutput = true ; return $ dom -> saveXml ( ) ; } else { throw new InvalidArgumentException ( 'Incorrect X... | Pretty print for XML |
19,849 | public function build ( $ rowNumber , $ cellNumber , $ cellValue , $ styleId = 0 ) { $ cellId = $ this -> getCellId ( $ cellNumber , $ rowNumber ) ; if ( is_int ( $ cellValue ) || is_float ( $ cellValue ) ) { return sprintf ( CellXml :: NUMBER_XML , $ cellId , $ styleId , $ cellValue ) ; } elseif ( is_bool ( $ cellValu... | Build and return the string for a single cell . |
19,850 | public function finalize ( $ output ) { $ zipFileUrl = sys_get_temp_dir ( ) . '/' . uniqid ( ) ; $ this -> fillZipWithFileContents ( $ zipFileUrl ) ; if ( ! $ this -> zip -> close ( ) ) { throw new \ RuntimeException ( 'Failed to close zip file!' ) ; } $ this -> copyToOutputAndCleanup ( $ output , $ zipFileUrl ) ; } | Finalize the xlsx file . |
19,851 | private function fillZipWithFileContents ( $ zipFileUrl ) { $ this -> zip -> open ( $ zipFileUrl , \ ZipArchive :: CREATE ) ; $ this -> finalizeSheet ( ) ; $ this -> finalizeStyles ( ) ; $ this -> finalizeDefaultXmls ( ) ; } | Add all file and string contents to zip file . |
19,852 | private function finalizeDefaultXmls ( ) { $ this -> zip -> addFromString ( '[Content_Types].xml' , DefaultXml :: CONTENT_TYPES ) ; $ this -> zip -> addFromString ( 'docProps/core.xml' , sprintf ( DefaultXml :: DOCPROPS_CORE , date ( DATE_ISO8601 ) , date ( DATE_ISO8601 ) ) ) ; $ this -> zip -> addFromString ( 'docProp... | Add default xmls to zip archive . |
19,853 | public function validateUrl ( $ url ) { if ( empty ( $ url ) ) { throw new \ InvalidArgumentException ( 'The field cannot be empty.' ) ; } if ( ! filter_var ( $ url , FILTER_VALIDATE_URL ) ) { throw new \ InvalidArgumentException ( 'The field requires a valid URL.' ) ; } return $ url ; } | Validates if the value is none - empty and a valid URL . |
19,854 | public static function getSizes ( $ noOldApple = false , $ noAndroid = false , $ noMs = false ) { $ result = array_merge ( self :: $ _sizes , array ( ) ) ; if ( $ noOldApple ) { unset ( $ result [ 'apple-touch-icon-57x57.png' ] ) ; unset ( $ result [ 'apple-touch-icon-60x60.png' ] ) ; unset ( $ result [ 'apple-touch-ic... | Return sizes from options |
19,855 | public static function getTileSettings ( $ name ) { if ( ! isset ( self :: $ _tileSettings [ $ name ] ) ) { throw new \ RuntimeException ( 'Invalid image name' ) ; } return self :: $ _tileSettings [ $ name ] ; } | Get the settings for Windows tile image size |
19,856 | public function isGitDir ( $ requireRoot = true ) { $ directory = $ this -> getGitDir ( ) ; if ( '' === $ directory ) { return false ; } if ( $ requireRoot && str_replace ( '\\' , '/' , getcwd ( ) ) !== $ directory ) { return false ; } return true ; } | Returns whether the current working dir is a Git directory . |
19,857 | public function stashBranchName ( ) { $ activeBranch = $ this -> getActiveBranchName ( 'HEAD' ) ; if ( null === $ this -> stashedBranch && 'HEAD' !== $ activeBranch ) { $ this -> stashedBranch = $ activeBranch ; } } | Stashes the active branch - name . |
19,858 | public static function getHomedir ( ) { $ home = ( string ) getenv ( 'GUSH_HOME' ) ; if ( '' === $ home ) { if ( getenv ( 'APPDATA' ) ) { $ home = strtr ( getenv ( 'APPDATA' ) , '\\' , '/' ) . '/Gush' ; } elseif ( getenv ( 'HOME' ) ) { $ home = ( string ) getenv ( 'HOME' ) . '/.gush' ; } } if ( '' === $ home ) { throw ... | Get the home directory of Gush . |
19,859 | public static function createConfig ( $ home = null , $ localHome = null ) { if ( null === $ home ) { $ home = static :: getHomedir ( ) ; } $ localConfig = [ ] ; $ systemConfig = self :: loadFileOrEmpty ( $ home . '/.gush.yml' ) ; if ( null !== $ localHome ) { $ localConfig = self :: loadFileOrEmpty ( $ localHome . '/.... | Create a new Config object using the local filesystem . |
19,860 | public static function dumpToFile ( Config $ config , $ type ) { if ( $ type === Config :: CONFIG_LOCAL ) { $ filename = $ config -> get ( 'local_config' ) ; if ( null === $ filename ) { throw new \ RuntimeException ( 'Local configuration is not loaded and therefore it cannot be dumped.' ) ; } } elseif ( $ type === Con... | Dump configuration to the related config - file . |
19,861 | public function numberedChoice ( $ question , array $ choices , $ default = null ) { $ labelKey = [ ] ; $ labels = [ ] ; foreach ( $ choices as $ key => $ label ) { $ labelKey [ $ label ] = $ key ; $ labels [ ] = $ label ; } if ( null !== $ default ) { $ values = array_flip ( $ labelKey ) ; $ default = isset ( $ values... | NumberedChoice works the same as a normal choice but prompts for a numbered list of options . |
19,862 | public function updateContent ( Meta $ meta , $ header , $ fileContent ) { if ( ! $ this -> isUpdatable ( $ meta , $ fileContent ) ) { return $ fileContent ; } $ startContent = '' ; $ fileContent = ltrim ( $ fileContent ) ; if ( null !== $ meta -> getStartTokenRegex ( ) ) { if ( ! preg_match ( $ meta -> getStartTokenRe... | Update the content with the header . |
19,863 | public function get ( $ keys , $ type = self :: CONFIG_ALL , $ default = null ) { $ this -> guardConfigSlot ( $ type ) ; $ keys = ( array ) $ keys ; if ( count ( $ keys ) === 1 ) { return array_key_exists ( $ keys [ 0 ] , $ this -> config [ $ type ] ) ? $ this -> config [ $ type ] [ $ keys [ 0 ] ] : $ default ; } $ cur... | Returns a config value . |
19,864 | public function getFirstNotNull ( array $ keys , $ type = self :: CONFIG_ALL , $ default = null ) { foreach ( $ keys as $ key ) { $ value = $ this -> get ( $ key , $ type ) ; if ( null !== $ value ) { return $ value ; } } return $ default ; } | Returns the first none - null configuration value . |
19,865 | public function toArray ( $ type = self :: CONFIG_ALL ) { $ this -> guardConfigSlot ( $ type ) ; return $ this -> config [ $ type ] ; } | Get the configuration is as array . |
19,866 | public function has ( $ key , $ type = self :: CONFIG_ALL ) { return null !== $ this -> get ( $ key , $ type ) ; } | Checks whether the config exists . |
19,867 | public function format ( $ value , $ valueCurrency = null , $ decimal = true , $ symbol = true ) { if ( null === $ valueCurrency ) { $ valueCurrency = $ this -> getConverter ( ) -> getDefaultCurrency ( ) ; } return $ this -> getFormatter ( ) -> format ( $ value , $ valueCurrency , $ decimal , $ symbol ) ; } | Format the given value . |
19,868 | public function convertAndFormat ( $ value , $ targetCurrency , $ decimal = true , $ symbol = true , $ valueCurrency = null ) { $ value = $ this -> convert ( $ value , $ targetCurrency , $ decimal , $ valueCurrency ) ; return $ this -> format ( $ value , $ targetCurrency , $ decimal , $ symbol ) ; } | Convert and format the given value . |
19,869 | public function create ( $ adapterClass ) { $ adapter = new $ adapterClass ( ) ; $ adapter -> setDefaultCurrency ( $ this -> currencies [ 'default' ] ) ; $ adapter -> setManagedCurrencies ( $ this -> currencies [ 'managed' ] ) ; $ adapter -> setCurrencyClass ( $ this -> currencyClass ) ; return $ adapter ; } | Create an adaper from the given class . |
19,870 | public function createDoctrineAdapter ( $ adapterClass = null , $ entityManagerName = null ) { if ( null == $ adapterClass ) { $ adapterClass = 'Lexik\Bundle\CurrencyBundle\Adapter\DoctrineCurrencyAdapter' ; } $ adapter = $ this -> create ( $ adapterClass ) ; $ em = $ this -> doctrine -> getManager ( $ entityManagerNam... | Create a DoctrineCurrencyAdapter . |
19,871 | public function addStyle ( Style $ style ) { if ( null === $ style -> getId ( ) ) { $ this -> register ( $ style -> getFont ( ) , $ this -> fonts ) ; $ this -> register ( $ style -> getFill ( ) , $ this -> fills ) ; $ this -> register ( $ style -> getBorder ( ) , $ this -> borders ) ; $ this -> register ( $ style , $ t... | Add a new style if it doesnt exists yet . |
19,872 | public function getStyleSheetXml ( ) { $ fontsXml = $ this -> getComponentXml ( $ this -> fonts ) ; $ fillsXml = $ this -> getComponentXml ( $ this -> fills ) ; $ bordersXml = $ this -> getComponentXml ( $ this -> borders ) ; $ cellXfsXml = $ this -> getComponentXml ( $ this -> styles ) ; return sprintf ( StyleXml :: S... | Return entire xml string for the style sheet . |
19,873 | private function getComponentXml ( array $ components ) { $ componentXml = '' ; foreach ( $ components as $ component ) { $ componentXml .= $ component -> asXml ( ) ; } return $ componentXml ; } | Return fonts fills borders xfs xml strings . |
19,874 | public function append ( $ value ) { if ( ! $ value instanceof $ this -> currencyClass ) { throw new \ InvalidArgumentException ( sprintf ( '$newval must be an instance of Currency, instance of "%s" given' , get_class ( $ value ) ) ) ; } parent :: append ( $ value ) ; } | Append a value |
19,875 | public function listIdentities ( $ identity_type = '' ) { $ this -> _action = 'ListIdentities' ; $ this -> _method = 'GET' ; $ this -> _refreshDate ( ) ; if ( ! preg_match ( '/^(EmailAddress|Domain|)$/' , $ identity_type ) ) { throw new Exception ( 'IdentityType must be EmailAddress or Domain' ) ; return ; } $ paramete... | List all identities your AWS account . |
19,876 | public function verifyEmailIdentity ( $ email ) { $ this -> _action = 'VerifyEmailIdentity' ; $ this -> _method = 'GET' ; $ this -> _refreshDate ( ) ; if ( ! filter_var ( $ email , FILTER_VALIDATE_EMAIL ) ) { throw new Exception ( 'Invalid email' ) ; return ; } $ parameters = array ( 'EmailAddress' => $ email ) ; $ thi... | Send an confirmation email to email address for verification . |
19,877 | public function deleteIdentity ( $ identity ) { $ this -> _action = 'DeleteIdentity' ; $ this -> _method = 'GET' ; $ this -> _refreshDate ( ) ; if ( ! ( filter_var ( $ identity , FILTER_VALIDATE_EMAIL ) || preg_match ( '/^([a-z\d]+(-[a-z\d]+)*\.)+[a-z]{2,}$/' , $ identity ) ) ) { throw new Exception ( 'Identity must be... | Delete an identity from your AWS account . |
19,878 | public function getIdentityVerificationAttributes ( $ identities ) { $ this -> _action = 'GetIdentityVerificationAttributes' ; $ this -> _method = 'GET' ; $ this -> _refreshDate ( ) ; $ parameters = array ( ) ; $ index = 1 ; if ( is_array ( $ identities ) ) { foreach ( $ identities as $ identity ) { if ( ! ( filter_var... | Get verification status . |
19,879 | public function sendEmail ( $ envelope ) { $ validate = $ envelope -> validate ( ) ; if ( is_object ( $ validate ) ) { return $ validate ; } $ parameters = $ envelope -> buildParameters ( ) ; $ this -> _action = $ envelope -> action ; $ this -> _method = 'POST' ; $ this -> _refreshDate ( ) ; $ this -> _generateSignatur... | Send the email to some specified addresses . |
19,880 | public function getSendQuota ( ) { $ this -> _action = 'GetSendQuota' ; $ this -> _method = 'GET' ; $ this -> _refreshDate ( ) ; $ this -> _generateSignature ( ) ; $ res = $ this -> _request ( ) ; if ( $ res [ 'code' ] == 200 ) { $ result = $ res [ 'body' ] -> GetSendQuotaResult ; return array ( 'MaxSendRate' => ( stri... | Get your AWS account s sending limits . |
19,881 | public function getSendStatistics ( ) { $ this -> _action = 'GetSendStatistics' ; $ this -> _method = 'GET' ; $ this -> _refreshDate ( ) ; $ this -> _generateSignature ( ) ; $ res = $ this -> _request ( ) ; if ( $ res [ 'code' ] == 200 ) { $ result = $ res [ 'body' ] -> GetSendStatisticsResult -> SendDataPoints -> memb... | Get SES sending statistics . |
19,882 | private function _generateSignatureKey ( ) { $ date_h = hash_hmac ( 'sha256' , $ this -> _date , 'AWS4' . $ this -> _aws_secret , true ) ; $ region_h = hash_hmac ( 'sha256' , $ this -> _region , $ date_h , true ) ; $ service_h = hash_hmac ( 'sha256' , self :: SERVICE , $ region_h , true ) ; $ signing_h = hash_hmac ( 's... | Create and returns binary hmac sha256 |
19,883 | private function _generateSignature ( $ parameters = array ( ) ) { $ this -> _headers = [ ] ; $ canonical_uri = '/' ; $ parameters [ 'Action' ] = $ this -> _action ; ksort ( $ parameters ) ; $ request_parameters = http_build_query ( $ parameters , '' , '&' , PHP_QUERY_RFC3986 ) ; $ canonical_headers = 'host:' . $ this ... | Signing AWS Requests with Signature Version 4 |
19,884 | private function _request ( ) { $ res = $ this -> _client -> request ( $ this -> _method , $ this -> _endpoint . '?' . $ this -> _query_parameters , [ 'headers' => $ this -> _headers , 'http_errors' => false ] ) ; return array ( 'code' => $ res -> getStatusCode ( ) , 'body' => new SimpleXMLElement ( $ res -> getBody ( ... | Request handler . |
19,885 | private function setUserToBeImpersonated ( $ userId ) { if ( ! empty ( $ userId ) ) { if ( version_compare ( $ this -> laravel -> version ( ) , '5.2.0' , '<' ) ) { $ userModel = config ( 'auth.model' ) ; $ user = $ userModel :: find ( $ userId ) ; $ this -> laravel [ 'auth' ] -> setUser ( $ user ) ; } else { if ( ! con... | Set current user for Api calls |
19,886 | private function _generateIco ( OutputInterface $ output ) { $ filename = $ this -> _outputFolder . "favicon.ico" ; $ output -> writeln ( "Creating: <info>{$filename}</info>" ) ; $ originalImage = $ this -> _imagine -> open ( $ this -> _inputFile ) -> strip ( ) ; $ originalImage -> copy ( ) -> resize ( new \ Imagine \ ... | Generate ICO icon |
19,887 | private function _getImagine ( OutputInterface $ output ) { if ( extension_loaded ( 'imagick' ) && class_exists ( "Imagick" ) ) { $ output -> writeln ( 'Imagick library is used!' ) ; return new \ Imagine \ Imagick \ Imagine ( ) ; } if ( extension_loaded ( 'gd' ) && function_exists ( 'gd_info' ) ) { $ output -> writeln ... | Get the imagine object based on the options . Default will use Imagick extension |
19,888 | public function initialize ( ConsoleEvent $ event ) { $ command = $ event -> getCommand ( ) ; if ( ! $ command instanceof InitCommand ) { return ; } if ( ! $ this -> gitHelper -> isGitDir ( ) ) { throw new UserException ( sprintf ( 'You can only run the "%s" command when you are in a Git directory.' , $ command -> getN... | Use this for detecting the org and repo . |
19,889 | public function toJson ( $ options = 0 ) { $ json = json_encode ( $ this -> jsonSerialize ( ) , $ options ) ; if ( JSON_ERROR_NONE !== json_last_error ( ) ) { throw JsonEncodingException :: forObject ( $ this , json_last_error_msg ( ) ) ; } return $ json ; } | Convert the object instance to JSON . |
19,890 | private function setIssueTrackerDef ( BaseCommand $ command ) { $ issueTracker = $ this -> application -> getConfig ( ) -> get ( 'issue_tracker' , Config :: CONFIG_LOCAL , GitHelper :: UNDEFINED_ADAPTER ) ; $ command -> addOption ( 'issue-adapter' , 'ia' , InputOption :: VALUE_REQUIRED , sprintf ( 'Adapter-name of the ... | Set Issue - tracker configuration . |
19,891 | public function addRows ( $ rows , Style $ style = null ) { if ( ! is_array ( $ rows ) && false === $ rows instanceof \ Traversable ) { throw new \ InvalidArgumentException ( 'Expected array or traversable object as rows' ) ; } foreach ( $ rows as $ row ) { $ this -> addRow ( $ row , $ style ) ; } } | Add multiple rows at once . |
19,892 | public function addRow ( array $ row , Style $ style = null ) { if ( ! empty ( $ row ) ) { $ style = $ style instanceof Style ? $ style : $ this -> styler -> getDefaultStyle ( ) ; $ this -> styler -> addStyle ( $ style ) ; $ this -> sheetFile -> fwrite ( $ this -> sheet -> addRow ( $ row , $ style ) ) ; } } | Add a single new row to the sheet and supply an optional style . |
19,893 | public function writeToFile ( $ fileName = 'report.xlsx' ) { $ this -> output = fopen ( $ fileName , 'w' ) ; $ finalizer = new Finalizer ( $ this -> sheet , $ this -> styler , $ this -> sheetFile ) ; $ finalizer -> finalize ( $ this -> output ) ; } | Wrap things up and write xlsx . |
19,894 | public function writeToBrowser ( $ fileName = 'report.xlsx' ) { $ this -> output = fopen ( 'php://output' , 'w' ) ; $ finalizer = new Finalizer ( $ this -> sheet , $ this -> styler , $ this -> sheetFile ) ; $ this -> sendHeaders ( $ fileName ) ; $ finalizer -> finalize ( $ this -> output ) ; } | Wrap things up and send xlsx to browser . |
19,895 | public function getCellWidth ( $ fontName , $ fontSize , $ value ) { $ width = 1 ; foreach ( $ this -> getSingleCharacterArray ( $ value ) as $ char ) { $ width += $ this -> getCharacterWidth ( $ fontName , $ fontSize , $ char ) ; } return $ width ; } | Get the calculated cell width for a given value . |
19,896 | private function getCharacterWidth ( $ fontName , $ fontSize , $ char ) { if ( ! isset ( $ this -> sizes [ $ fontName ] [ $ fontSize ] [ $ char ] ) ) { $ this -> sizes [ $ fontName ] [ $ fontSize ] [ $ char ] = $ this -> calculateCharacterWith ( $ fontName , $ fontSize , $ char ) ; } return $ this -> sizes [ $ fontName... | Get width of a single character . Calculate & cache if necessary . |
19,897 | private function calculateCharacterWith ( $ fontName , $ fontSize , $ char ) { if ( isset ( $ this -> fonts [ $ fontName ] ) ) { $ box = imageftbbox ( $ fontSize , 0 , $ this -> fonts [ $ fontName ] , str_repeat ( $ char , 100 ) ) ; $ width = abs ( $ box [ 4 ] - $ box [ 0 ] ) / 6.73 / 100 ; return round ( $ width , 3 )... | Calculate the width of a single character for the given fontname and size . Create image that contains the character 100 times to get more accurate results . |
19,898 | private function getSingleCharacterArray ( $ value ) { if ( mb_strlen ( $ value ) == strlen ( $ value ) ) { return str_split ( $ value ) ; } return preg_split ( '~~u' , $ value , - 1 , PREG_SPLIT_NO_EMPTY ) ; } | Split value into individual characters . |
19,899 | public function registerTemplate ( TemplateInterface $ template ) { $ templateName = $ template -> getName ( ) ; $ parts = explode ( '/' , $ templateName ) ; if ( count ( $ parts ) !== 2 ) { throw new \ InvalidArgumentException ( sprintf ( 'Template name "%s" is not formatted properly, should be like "domain/template-n... | Registers a template . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.