idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
59,000 | public static function setBaseDirectory ( $ directory ) { if ( ! is_dir ( $ directory ) ) throw new \ InvalidArgumentException ( 'm\View\GenericView: Given string "' . $ directory . '" is not a valid directory.' ) ; static :: $ _defaultDir = ( string ) rtrim ( $ directory , DIRECTORY_SEPARATOR ) . DIRECTORY_SEPARATOR ;... | Sets the directory for the view files . |
59,001 | public function setFile ( $ file ) { $ path = pathinfo ( ( string ) $ file ) ; if ( ! $ path [ 'extension' ] ) $ file .= '.' . static :: $ _defaultExt ; $ this -> _file = trim ( $ file , DIRECTORY_SEPARATOR ) ; return $ this ; } | Set the view file name . If an extension is provided that extension will be used over the default . |
59,002 | public function clearMany ( $ keys ) { if ( ! is_array ( $ keys ) ) $ keys = func_get_args ( ) ; foreach ( $ keys as $ key ) { unset ( $ this -> _data [ $ key ] ) ; } return $ this ; } | Clear any matching items from the view data . |
59,003 | public function setDevKey ( $ key ) { $ this -> validator -> validateDeveloperKey ( $ key ) ; $ this -> devKey = $ key ; return $ this ; } | Sets the developer key . |
59,004 | public function verify ( ) { $ this -> resetApiParameters ( ) ; $ this -> setCommonApiParameters ( ) ; $ wrongKeys = array ( ) ; foreach ( $ this -> getApiKeys ( ) as $ key ) { $ this -> setApiParameter ( 'apikey' , $ key ) ; try { $ this -> callApi ( self :: API_URL_VERIFY ) ; } catch ( RuntimeException $ e ) { $ wron... | Verifies the given API keys . |
59,005 | public function notify ( $ application , $ event , $ description , $ priority = 0 , $ url = '' , $ html = false ) { $ this -> validator -> validateApplication ( $ application ) -> validateEvent ( $ event ) -> validateDescription ( $ description ) -> validatePriority ( $ priority ) -> validateUrl ( $ url ) ; $ this -> r... | Sends a notification with the given parameters . |
59,006 | protected function setCommonApiParameters ( ) { if ( ! empty ( $ this -> devKey ) ) { $ this -> setApiParameter ( 'developerkey' , $ this -> devKey ) ; } $ this -> validator -> validateApiKeys ( $ this -> apiKeys ) ; $ this -> setApiParameter ( 'apikey' , implode ( ',' , $ this -> apiKeys ) ) ; return $ this ; } | Sets common API request parameters . |
59,007 | protected function callApi ( $ url ) { $ url = $ this -> apiBaseUrl . $ url ; $ options = array ( 'http' => array ( 'method' => 'POST' , 'header' => 'Content-Type: application/x-www-form-urlencoded' , 'ignore_errors' => true , 'content' => http_build_query ( $ this -> parameters , '' , '&' ) ) ) ; $ context = stream_co... | Calls the API with the given parameters . |
59,008 | private function processXmlReturn ( SimpleXMLElement $ xml ) { if ( isset ( $ xml -> error ) ) { if ( isset ( $ xml -> error [ '@attributes' ] ) ) { $ this -> lastStatus = ( int ) $ xml -> error [ '@attributes' ] [ 'code' ] ; if ( isset ( $ xml -> error [ '@attributes' ] [ 'resettimer' ] ) ) { $ this -> apiLimitReset =... | Processes the XML API response . |
59,009 | public function dispatch ( ) { $ this -> lock -> acquire ( ) ; $ this -> guardThatHistoryRepositoryDoesNotHaveMoreUnitsOfWork ( ) ; $ workloadRepository = $ this -> sourceRepository -> diff ( $ this -> historyRepository ) ; foreach ( $ workloadRepository as $ unitOfWork ) { $ this -> executeMigration ( $ unitOfWork ) ;... | Dispatches the migration process |
59,010 | private function guardThatHistoryRepositoryDoesNotHaveMoreUnitsOfWork ( ) { $ historyDiffRepository = $ this -> historyRepository -> diff ( $ this -> sourceRepository ) ; if ( 0 < $ historyDiffRepository -> count ( ) ) { throw new HistoryHasSourceUnknownUnitsOfWorkException ( ) ; } } | Guards the there are no units of work in the history repository that are not also in the source repository |
59,011 | private function executeMigration ( UnitOfWork $ unitOfWork ) { try { $ unitOfWork -> migrate ( $ this -> connection ) ; $ this -> historyRepository -> add ( $ unitOfWork ) ; } catch ( QueryNotSuccessfulException $ e ) { } } | Executes the given migration against the database connection |
59,012 | public static function Tdbtt ( $ tdb1 , $ tdb2 , $ dtr , & $ tt1 , & $ tt2 ) { $ dtrd ; $ dtrd = $ dtr / DAYSEC ; if ( $ tdb1 > $ tdb2 ) { $ tt1 = $ tdb1 ; $ tt2 = $ tdb2 - $ dtrd ; } else { $ tt1 = $ tdb1 - $ dtrd ; $ tt2 = $ tdb2 ; } return 0 ; } | - - - - - - - - - i a u T d b t t - - - - - - - - - |
59,013 | private function getJ2000Day ( \ DateTime $ dateTime ) { $ day = ( integer ) $ dateTime -> format ( 'j' ) ; $ month = ( integer ) $ dateTime -> format ( 'n' ) ; $ year = ( integer ) $ dateTime -> format ( 'Y' ) ; return floor ( 367 * $ year - ( 7 * ( $ year + ( ( $ month + 9 ) / 12 ) ) ) / 4 + ( 275 * $ month ) / 9 + $... | Returns the number of days from J2000 . 0 . |
59,014 | public static function extend ( ) { if ( func_num_args ( ) < 2 ) { throw new BadFunctionCallException ( "Not enough parameters" ) ; } $ args = func_get_args ( ) ; $ merged = array_shift ( $ args ) ; foreach ( $ args as $ source ) { foreach ( $ source as $ key => $ value ) { if ( is_array ( $ value ) && isset ( $ merged... | Extends array parameters recursively . |
59,015 | public static function slice ( $ data , $ keys ) { $ removed = array_intersect_key ( $ data , array_fill_keys ( ( array ) $ keys , true ) ) ; $ data = array_diff_key ( $ data , $ removed ) ; return [ $ data , $ removed ] ; } | Slices an array into two separating them determined by an array of keys . |
59,016 | public static function normalize ( $ data ) { $ result = [ ] ; foreach ( $ data as $ key => $ value ) { if ( ! is_int ( $ key ) ) { $ result [ $ key ] = $ value ; continue ; } if ( ! is_scalar ( $ value ) ) { throw new Exception ( "Invalid array format, a value can't be normalized" ) ; } $ result [ $ value ] = null ; }... | Normalizes an array and converts it to an array of key = > value pairs where keys must be strings . |
59,017 | public function getPanel ( ) { $ app = \ MvcCore \ Application :: GetInstance ( ) ; $ requestCode = \ Tracy \ Dumper :: toHtml ( $ app -> GetRequest ( ) -> InitAll ( ) , [ \ Tracy \ Dumper :: LIVE => TRUE , \ Tracy \ Dumper :: COLLAPSE => 1 , \ Tracy \ Dumper :: DEPTH => 4 , ] ) ; $ responseCode = \ Tracy \ Dumper :: t... | Return rendered debug panel content window HTML code . |
59,018 | public function getData ( $ ip = "" ) { $ this -> ip = $ ip ; if ( empty ( $ this -> ip ) ) { throw new AddressNotFoundException ( json_encode ( [ 'error' => 'No IP found for the user' ] ) ) ; } try { $ request_params = $ this -> generateRequestParams ( ) ; $ res = self :: client ( ) -> get ( self :: api_url ( ) . 'dat... | Main function that return User data |
59,019 | private function validateResponse ( $ res ) { if ( null === $ res ) throw new GeotException ( json_encode ( [ 'error' => 'Null reponse from guzzle' ] ) ) ; $ code = $ res -> getStatusCode ( ) ; switch ( $ code ) { case '404' : throw new AddressNotFoundException ( ( string ) $ res -> getBody ( ) ) ; case '500' : throw n... | Check returned response |
59,020 | public static function getCities ( $ iso_code ) { $ response = self :: client ( ) -> get ( self :: api_url ( ) . 'cities' , [ 'query' => [ 'iso_code' => $ iso_code ] ] ) ; if ( $ response -> getStatusCode ( ) != '200' ) return [ 'error' => 'Something wrong happened' ] ; $ response = ( string ) $ response -> getBody ( )... | Helper function that get cities for given country |
59,021 | public function setMapping ( string $ item , string $ file ) : object { $ this -> mapping [ $ item ] = $ file ; return $ this ; } | Set a specific configuration file to load for a particluar item . |
59,022 | public function load ( string $ item ) : array { if ( empty ( $ this -> dirs ) ) { throw new Exception ( "The array for configuration directories can not be empty." ) ; } $ found = false ; $ config = [ ] ; $ mapping = $ this -> mapping [ $ item ] ?? null ; if ( $ mapping ) { $ config [ "file" ] = $ mapping ; $ config [... | Read configuration from file or directory if a file look though all base dirs and use the first configuration that is found . A configuration item can be combined from a file and a directory when available in the same base directory . |
59,023 | public function getVariable ( $ name ) { $ encodedValue = $ this -> getEnvironmentVariable ( $ name ) ; if ( $ encodedValue === null ) { return null ; } return $ this -> decode ( $ encodedValue ) ; } | Decode and decrypt a previously set environment variable . |
59,024 | public function getAttributeValue ( $ key ) { $ value = $ this -> getAttributeFromArray ( $ key ) ; if ( $ this -> hasGetMutator ( $ key ) ) { $ method = sprintf ( $ this -> methodNameGetMutator , Str :: studly ( $ key ) ) ; return call_user_func_array ( [ $ this , $ method ] , [ $ value ] ) ; } return $ value ; } | Return attribute key value . |
59,025 | public function setAttribute ( $ key , $ value ) { if ( $ this -> hasSetMutator ( $ key ) ) { $ method = sprintf ( $ this -> methodNameSetMutator , Str :: studly ( $ key ) ) ; return $ this -> { $ method } ( $ value ) ; } $ this -> attributes [ $ key ] = $ value ; return $ this ; } | Set attribute key and value . |
59,026 | protected function hasGetMutator ( $ key ) { return method_exists ( $ this , sprintf ( $ this -> methodNameGetMutator , Str :: studly ( $ key ) ) ) ; } | Return if attribute has method get . |
59,027 | protected function hasSetMutator ( $ key ) { return method_exists ( $ this , sprintf ( $ this -> methodNameSetMutator , Str :: studly ( $ key ) ) ) ; } | Return if attribute has method set . |
59,028 | public function span ( $ value , $ attributes = [ ] ) { $ tag = new Tag ( 'span' , $ attributes ) ; $ tag -> setText ( $ value ) ; return $ tag ; } | span tag render |
59,029 | public function getPhrase ( ) : string { return isset ( self :: $ phrases [ $ this -> code ] ) ? self :: $ phrases [ $ this -> code ] : '' ; } | Returns the phrase for the code . |
59,030 | private function filterStatus ( $ code ) : int { if ( ! is_numeric ( $ code ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Status code "%s" is not numeric.' , is_scalar ( $ code ) ? $ code : gettype ( $ code ) ) ) ; } $ result = ( int ) $ code ; if ( ! self :: isValid ( $ result ) ) { throw new \ InvalidArgume... | Validates the given HTTP status code and returns an integer if correct . |
59,031 | protected function getCmd ( $ refresh = false ) { if ( is_null ( $ this -> cmd ) || $ refresh ) { $ this -> cmd = new Command ( ) ; } return $ this -> cmd ; } | Returns the Cmd object |
59,032 | public function input ( $ question , $ default = '' , $ options = [ ] ) { if ( empty ( $ default ) ) { $ this -> write ( $ question . ' ' ) ; } elseif ( empty ( $ options ) ) { $ this -> write ( $ question . ' [' . $ default . '] ' ) ; } else { $ available_options = [ ] ; foreach ( strtolower ( $ options ) as $ option ... | Request user input |
59,033 | public function translate ( $ key , $ param = array ( ) , $ defaultLine = '' ) { $ line = $ this -> replaceParam ( $ this -> getLine ( $ key , $ defaultLine ) , $ param ) ; if ( ! $ line ) { return ( $ this -> isDebugMode ( ) ) ? '{{ ' . $ key . ' }}' : $ line ; } return $ line ; } | Translate a language |
59,034 | public function choice ( $ key , $ count = 1 , $ param = array ( ) ) { $ line = $ this -> getLine ( $ key ) ; $ lines = explode ( '|' , $ line ) ; if ( isset ( $ lines [ $ count - 1 ] ) ) { $ line = $ lines [ $ count - 1 ] ; $ param [ 'count' ] = $ count ; return $ this -> replaceParam ( $ line , $ param ) ; } return (... | Retrieve a translation string that is different depending on a count . |
59,035 | protected function getLine ( $ key , $ default = null ) { $ lang = $ this -> lang ; $ key = $ this -> sanitize ( $ key ) ; if ( ! $ this -> hasLanguage ( $ lang ) ) { $ message = 'Language [' . $ lang . '] is not available' ; throw new LangException ( $ message ) ; } $ line = $ this -> arrayGet ( $ lang . '.' . $ key ,... | Get raw translated line |
59,036 | protected function arrayGet ( $ key , $ default = null ) { if ( isset ( $ this -> list [ $ key ] ) ) { return $ this -> list [ $ key ] ; } foreach ( explode ( '.' , $ key ) as $ segment ) { if ( ! is_array ( $ this -> list ) || ! array_key_exists ( $ segment , $ this -> list ) ) { return ( is_callable ( $ default ) ) ?... | Get line in dot notation |
59,037 | protected function replaceParam ( $ line , array $ param ) { if ( ! empty ( $ param ) and is_array ( $ param ) ) { foreach ( $ param as $ key => $ value ) { $ line = str_replace ( ':' . $ key , $ value , $ line ) ; } } return $ line ; } | Replace word from parameters |
59,038 | public function resetFlashes ( ) { $ newValues = $ this -> get ( $ this -> getFlashKey ( 'new' ) , [ ] ) ; $ this -> set ( $ this -> getFlashKey ( 'old' ) , $ newValues ) ; $ this -> set ( $ this -> getFlashKey ( 'new' ) , [ ] ) ; } | Reset flashes . |
59,039 | public function map ( $ method , $ match , $ callback ) { $ match = $ this -> base . $ match ; $ route = $ this -> routeService -> attach ( $ method , $ match , $ callback ) -> setGroup ( $ this ) ; return $ route ; } | Regist a http route . |
59,040 | public function addLocale ( Locale $ locale ) { $ key = self :: canonicalize ( $ locale -> getCode ( ) ) ; if ( isset ( $ this -> _locales [ $ key ] ) ) { return $ this -> _locales [ $ key ] ; } foreach ( $ this -> getResourcePaths ( ) as $ domain => $ paths ) { $ locale -> addResourcePaths ( $ domain , $ paths ) ; } $... | Sets up the application with the defined locale key ; the key will be formatted to a lowercase dashed URL friendly format . The system will then attempt to load the locale resource bundle and finalize configuration settings . |
59,041 | public static function canonicalize ( $ key , $ format = self :: FORMAT_1 ) { $ parts = explode ( '-' , str_replace ( '_' , '-' , mb_strtolower ( $ key ) ) ) ; $ return = $ parts [ 0 ] ; if ( isset ( $ parts [ 1 ] ) ) { switch ( $ format ) { case self :: FORMAT_1 : $ return .= '-' . $ parts [ 1 ] ; break ; case self ::... | Convert a locale key to 3 possible formats . |
59,042 | public function cascade ( ) { return $ this -> cache ( [ __METHOD__ , $ this -> current ( ) -> getCode ( ) ] , function ( ) { $ cycle = [ ] ; foreach ( [ $ this -> current ( ) , $ this -> getFallback ( ) ] as $ locale ) { while ( $ locale instanceof Locale ) { $ cycle [ ] = $ locale -> getCode ( ) ; $ locale = $ locale... | Get a list of locales and fallback locales in descending order starting from the current locale . |
59,043 | public function getResourcePaths ( $ domain = null ) { return isset ( $ this -> _paths [ $ domain ] ) ? $ this -> _paths [ $ domain ] : $ this -> _paths ; } | Return all resource paths or filtered by domain . |
59,044 | public function initialize ( ) { if ( ! $ this -> isEnabled ( ) ) { return ; } $ current = null ; if ( ! empty ( $ _COOKIE [ 'locale' ] ) && isset ( $ this -> _locales [ $ _COOKIE [ 'locale' ] ] ) ) { $ current = $ _COOKIE [ 'locale' ] ; } else if ( isset ( $ _SERVER [ 'HTTP_ACCEPT_LANGUAGE' ] ) ) { $ header = mb_strto... | Detect which locale to use based on the clients Accept - Language header . |
59,045 | public function is ( $ key ) { $ code = $ this -> current ( ) -> getCode ( ) ; return ( $ code === $ key || $ this -> canonicalize ( $ code ) === $ key ) ; } | Does the current locale matched the passed key? |
59,046 | public function resolveRoute ( Event $ event , Router $ router , $ url ) { if ( PHP_SAPI === 'cli' ) { return ; } $ locales = $ this -> getLocales ( ) ; $ redirect = '/' . $ this -> getFallback ( ) -> getCode ( ) ; $ base = $ router -> base ( ) ; if ( $ base !== '/' ) { $ redirect = $ base . $ redirect ; } if ( ! preg_... | When the Router initializes check for the existence of a locale in the URL . If the locale exists verify it . If either of these fail redirect with the fallback locale . This event must be bound to the Router to work . |
59,047 | public function setFallback ( $ key ) { $ key = $ this -> canonicalize ( $ key ) ; if ( ! isset ( $ this -> _locales [ $ key ] ) ) { throw new MissingLocaleException ( sprintf ( 'Locale %s has not been setup' , $ key ) ) ; } $ this -> _fallback = $ this -> _locales [ $ key ] ; Config :: set ( 'titon.locale.fallback' , ... | Define the fallback locale to use if none can be found or is not supported . |
59,048 | public function unsignedIntId ( Table $ table ) { $ id = new Column ( ) ; $ id -> setIdentity ( true ) -> setType ( 'integer' ) -> setOptions ( [ 'limit' => 11 , 'signed' => false , 'null' => false ] ) ; $ table -> changeColumn ( 'id' , $ id ) ; } | Make the id primary column an unsigned integer . |
59,049 | public function add ( $ index , $ value ) : Utility { if ( is_null ( $ this -> get ( $ index ) ) ) { return $ this -> set ( $ index , $ value ) ; } return $ this ; } | Add a value to an index if it doesn t exit |
59,050 | public function containsAll ( $ needles ) : bool { $ needlesBag = $ this -> transformToBag ( $ needles ) ; return ! array_diff ( $ needlesBag , $ this -> bag ) ; } | Are all the values in the needle bag in the haystack bag |
59,051 | public function containsAny ( $ needles ) : bool { $ needlesBag = $ this -> transformToBag ( $ needles ) ; return ! ! array_intersect ( $ needlesBag , $ this -> bag ) ; } | Are any of the needle values in the haystack bag |
59,052 | public function isAssociative ( ) : bool { if ( count ( $ this -> bag ) === 0 ) { return false ; } return array_keys ( $ this -> bag ) !== range ( 0 , count ( $ this -> bag ) - 1 ) ; } | Is the bag holding associative data key = value opposed to 123 = value |
59,053 | public function isMultiDimensional ( ) : bool { if ( sizeof ( $ this -> bag ) === 0 ) { return false ; } return count ( $ this -> bag ) !== count ( $ this -> bag , COUNT_RECURSIVE ) ; } | Is the bag holding multidimensional data |
59,054 | public function push ( ... $ values ) : Utility { $ newBag = $ this -> toArray ( ) ; foreach ( $ values as $ value ) { array_push ( $ newBag , $ value ) ; } return new self ( $ newBag ) ; } | Push a value onto the end of the bag |
59,055 | public function remove ( $ index ) : Utility { if ( $ this -> exists ( $ index ) ) { $ newBag = $ this -> toArray ( ) ; unset ( $ newBag [ $ index ] ) ; return new self ( $ newBag ) ; } return $ this ; } | Remove an value from the bag via its index |
59,056 | public function removeEmpty ( ) : Utility { $ filteredBag = array_filter ( $ this -> bag , function ( $ value ) { return ! empty ( $ value ) ; } ) ; if ( ! $ this -> isAssociative ( ) ) { $ filteredBag = array_values ( $ filteredBag ) ; } return new static ( $ filteredBag ) ; } | Remove all empty values from the bag An empty value could be null 0 false |
59,057 | public function set ( $ index , $ value ) : Utility { $ newBag = $ this -> toArray ( ) ; $ newBag [ $ index ] = $ value ; return new self ( $ newBag ) ; } | Set an array index with a given value |
59,058 | public function toKeyValueString ( $ glue = ' ' , $ keyPrefix = '' , $ keyPostfix = '' , $ keyJoint = '=' , $ valuePrefix = '\'' , $ valuePostfix = '\'' ) { return implode ( $ glue , array_map ( function ( $ v , $ k ) use ( $ keyPrefix , $ keyPostfix , $ keyJoint , $ valuePrefix , $ valuePostfix ) { return sprintf ( $ ... | Implode the the bag to show a key = value string |
59,059 | private function transformToBag ( $ bag ) : array { if ( is_object ( $ bag ) ) { $ bag = get_object_vars ( $ bag ) ; } $ bag = is_array ( $ bag ) ? $ bag : [ $ bag ] ; $ bag = array_map ( function ( $ e ) { return ( is_object ( $ e ) || is_array ( $ e ) ) ? $ this -> transformToBag ( $ e ) : $ e ; } , $ bag ) ; return ... | Transform the constructor parameter to a usable array for the utility to use |
59,060 | public function byClosure ( Closure $ closure ) { $ this -> controller = new Controller ( ) ; if ( $ this -> hasContainer ( ) && method_exists ( $ this -> controller , 'raikiri' ) ) $ this -> controller -> setContainer ( $ this -> raikiri ( ) ) ; $ this -> action = $ closure -> bindTo ( $ this -> controller ) ; } | initialize by closure |
59,061 | public function byClassMethod ( $ class , $ method ) { $ this -> controller = new $ class ( ) ; $ this -> controller = is_object ( $ class ) ? $ class : new $ class ( ) ; if ( $ this -> hasContainer ( ) && method_exists ( $ this -> controller , 'raikiri' ) ) $ this -> controller -> setContainer ( $ this -> raikiri ( ) ... | initialize by class and method |
59,062 | public function create_global_plugin ( & $ plugin ) { $ GLOBALS [ 'BCA_' . get_class ( $ plugin ) ] = $ plugin ; $ GLOBALS [ 'BCA_' . get_class ( $ plugin ) ] -> boot ( ) ; } | Registra una clase Plugin de forma global |
59,063 | public function getHoursWithUnit ( ) { if ( $ this -> hours == 1 ) { $ postfix = ' hour' ; } else { $ postfix = ' hours' ; } return $ this -> hours . $ postfix . ' on ' . $ this -> log_date . '' ; } | Get hours with unit . |
59,064 | public static function forge ( $ name = 'default' , array $ config = array ( ) ) { if ( $ exists = static :: instance ( $ name ) ) { \ Error :: notice ( 'Asset with this name exists already, cannot be overwritten.' ) ; return $ exists ; } static :: $ _instances [ $ name ] = new \ Asset_Instance ( array_merge ( static :... | Gets a new instance of the Asset class . |
59,065 | public function execute ( ) { $ eventHandler = $ this -> make ( EventHandler :: class ) ; $ eventHandler -> trigger ( BeforeExecute :: class ) ; $ request = $ this -> make ( Request :: class ) ; $ request -> compute ( ) ; } | Executes the Application by loading the requested Controller . |
59,066 | public function loadConfigs ( ... $ names ) { $ config = $ this -> make ( Config :: class ) ; foreach ( $ names as $ name ) { $ config -> load ( $ name ) ; } } | Loads an Array of config files . |
59,067 | public function getCommand ( $ group , $ command ) : string { $ config = $ this -> make ( Config :: class ) ; $ commands = $ config [ 'commands' ] ; if ( isset ( $ commands [ $ group ] ) ) { $ group = $ commands [ $ group ] ; if ( isset ( $ group [ $ command ] ) ) { return $ group [ $ command ] ; } else { throw new Con... | Returns the class name for a registered command . |
59,068 | public function runCommand ( $ command , array $ parameters = [ ] , $ silent = false ) { $ class = $ this -> make ( $ command ) ; if ( $ class instanceof Command ) { if ( $ silent ) { $ class -> setSilent ( true ) ; } $ class -> run ( $ parameters ) ; } else { throw new ConsoleException ( 'Class has to be a instance of... | Executes a registered command . |
59,069 | public static function build ( \ PHPUnit_Framework_TestCase $ testCase , $ config = [ ] ) { $ mock = static :: get ( $ testCase , $ config ) ; return $ mock -> buildMock ( ) ; } | Mock Factory method |
59,070 | public function findByIdentifier ( $ identifier ) { $ accessTokenResult = $ this -> cache -> get ( $ identifier ) ; if ( $ accessTokenResult instanceof AccessToken ) { return $ accessTokenResult ; } return NULL ; } | Find an access token by identifier |
59,071 | public function add ( AccessToken $ accessToken ) { $ lifetime = $ accessToken -> getExpiryTime ( ) - time ( ) ; $ this -> cache -> set ( $ accessToken -> getIdentifier ( ) , $ accessToken , array ( ) , $ lifetime ) ; } | Add the given access token to persistence |
59,072 | public function indexAction ( ) { return $ this -> forward ( ) -> dispatch ( $ this -> params ( ) -> fromRoute ( 'controller' , get_called_class ( ) ) , array ( 'action' => 'list' , 'locale' => ( string ) $ this -> locale ( ) , ) ) ; } | Index displays to list by default |
59,073 | private function getOptionByRegExpr ( string $ pattern ) : array { $ purgedArgs = $ this -> getRawArgs ( true ) ; return preg_grep ( "/" . $ pattern . "/" , $ purgedArgs ) ; } | Get the arguments list and applies and extract data according to the regexpr passed parameter |
59,074 | protected function initializeOtherValues ( ) : ConsoleInputInterface { $ this -> domainName = "" ; $ this -> actionName = "" ; $ this -> options = [ ] ; $ this -> params = [ ] ; $ this -> shortOptionsValued = [ ] ; $ this -> shortOptionsVoid = [ ] ; $ this -> longOptionsValued = [ ] ; $ this -> longOptionsVoid = [ ] ; ... | Set default values to empty for properties before processing command line |
59,075 | protected function process ( ) : void { list ( $ commandName , $ actionName ) = $ this -> checkArguments ( ) ; $ this -> options = array_merge ( $ this -> extractShortOptionsWithParams ( ) , $ this -> extractShortOptionsVoid ( ) , $ this -> extractLongOptionsWithValues ( ) , $ this -> extractLongOptionsVoid ( ) ) ; $ t... | Process the command line and set the environment |
59,076 | public function getEmailByEmailId ( $ emailID ) { $ email = $ this -> model -> where ( 'id' , $ emailID ) -> first ( ) ; return $ email -> title ; } | Get the email title by ID |
59,077 | public function createNewRecord ( $ data ) { $ email = new $ this -> model ; $ email -> email_type_id = $ data [ 'email_type_id' ] ; $ email -> title = $ data [ 'title' ] ; $ email -> description = $ data [ 'description' ] ; $ email -> comments = $ data [ 'comments' ] ; $ email -> created_at = $ data [ 'created_at' ] ;... | INSERT INTO email |
59,078 | function onAfterInit ( ) { foreach ( ( array ) $ this -> owner -> config ( ) -> include_requirements_from_class as $ class => $ method ) { if ( is_numeric ( $ class ) ) { singleton ( $ method ) -> includes ( $ this -> owner ) ; } else { singleton ( $ class ) -> $ method ( $ this -> owner ) ; } } if ( $ this -> owner in... | Add additional requirements from a LeftAndMain specific class and globally |
59,079 | protected function respondWithMessage ( $ success = true , $ message = '' , $ code = 0 ) { if ( ! $ message ) { if ( $ success ) { $ message = rawurlencode ( _t ( 'CMSMain.ACTION_COMPLETE' , 'Done' ) ) ; } else { $ message = rawurlencode ( _t ( 'CMSMain.ACTION_FAILED' , 'Could not complete action' ) ) ; } } if ( ! $ co... | Respond with a message in LeftAndMain |
59,080 | public function EXE ( I_O $ IO ) { return $ IO -> _O ( $ IO -> I_ ( Type :: BOOL ) xor $ IO -> I_ ( Type :: BOOL ) ) ; } | Applies the XOR operator to a couple of booleans . |
59,081 | public function equals ( HostInterface $ host ) : bool { if ( $ this -> getIPAddress ( ) !== null && $ host -> getIPAddress ( ) !== null ) { return $ this -> getIPAddress ( ) -> equals ( $ host -> getIPAddress ( ) ) ; } return $ this -> getHostname ( ) -> equals ( $ host -> getHostname ( ) ) ; } | Returns true if the host equals other host false otherwise . |
59,082 | public function getHostname ( ) : HostnameInterface { if ( $ this -> myHostname !== null ) { return $ this -> myHostname ; } $ ipAddressParts = $ this -> myIpAddress -> getParts ( ) ; return Hostname :: fromParts ( [ strval ( $ ipAddressParts [ 3 ] ) , strval ( $ ipAddressParts [ 2 ] ) , strval ( $ ipAddressParts [ 1 ]... | Returns the hostname of the host . |
59,083 | private static function myParse ( string $ host , ? HostnameInterface & $ hostname = null , ? IPAddressInterface & $ ipAddress = null , ? string & $ error = null ) : bool { if ( $ host === '' ) { $ error = 'Host "' . $ host . '" is empty.' ; return false ; } try { $ hostname = Hostname :: parse ( $ host ) ; } catch ( H... | Tries to parse a host and returns the result or error text . |
59,084 | public function getConnection ( array $ params , $ type ) { if ( $ type == 'S' ) { $ host = ( ! empty ( $ params [ 'num_ip' ] ) ) ? $ params [ 'num_ip' ] : '127.0.0.1' ; $ community = ( ! empty ( $ params [ 'des_snmp_community' ] ) ) ? $ params [ 'des_snmp_community' ] : 'public' ; $ version = ( ! empty ( $ params [ 'd... | Return connection base type device |
59,085 | public function view ( UserPolicy $ user , Portfolio $ portfolio ) { if ( $ user -> canDo ( 'portfolio.portfolio.view' ) && $ user -> isAdmin ( ) ) { return true ; } return $ portfolio -> user_id == user_id ( ) && $ portfolio -> user_type == user_type ( ) ; } | Determine if the given user can view the portfolio . |
59,086 | public function destroy ( UserPolicy $ user , Portfolio $ portfolio ) { return $ portfolio -> user_id == user_id ( ) && $ portfolio -> user_type == user_type ( ) ; } | Determine if the given user can delete the given portfolio . |
59,087 | public function restoreLoginFromCookie ( ) { if ( ! $ this -> cookieIsSet ( ) ) { return false ; } $ fields = $ this -> config ( 'fields' ) ; $ cookieKey = $ this -> config ( 'cookieKey' ) ; $ loginData = [ ] ; foreach ( $ fields as $ field ) { if ( $ this -> Cookie -> check ( "$cookieKey.$field" ) ) { $ loginData [ $ ... | Logs the user in using cookie |
59,088 | public function setCookie ( $ data = [ ] ) { $ controller = $ this -> _registry -> getController ( ) ; if ( empty ( $ data ) ) { $ data = $ controller -> request -> data ; } if ( empty ( $ data ) ) { $ data = $ controller -> Auth -> user ( ) ; } if ( empty ( $ data ) ) { return false ; } $ fields = $ this -> config ( '... | Sets the cookie with the passed data request data or session data |
59,089 | public function addData ( $ mixedData ) { if ( false === isset ( $ this -> cases [ $ this -> currentCaseTitle ] ) ) { throw new \ UnexpectedValueException ( sprintf ( 'You cannot add data - you have to add a case first by using %s->addCase().' , __CLASS__ ) ) ; } $ this -> cases [ $ this -> currentCaseTitle ] [ $ this ... | Add data to current case |
59,090 | public function rule ( $ str_to_change , $ str_new ) { if ( ! is_scalar ( $ str_to_change ) || ! is_scalar ( $ str_new ) ) { throw new \ InvalidArgumentException ( 'New rule to replace character must be two valid string or scalar value.' ) ; } if ( strlen ( $ str_new ) > 0 ) { if ( preg_match ( '/[^a-z0-9-]/' , ( strin... | Adds custom rule to replace some characters . |
59,091 | public function value ( $ str ) { if ( ! is_scalar ( $ str ) ) { throw new \ InvalidArgumentException ( 'Argument for constructor of' . __CLASS__ . ' must be a scalar!' ) ; } if ( ! extension_loaded ( 'mbstring' ) ) { trigger_error ( 'You have not multibyte extension, this may create weird result!' , E_USER_WARNING ) ;... | New value to slugify using current slug object configuration . |
59,092 | public function render ( ) { if ( is_null ( $ this -> str_out ) ) { $ str_prov = $ this -> str ; if ( count ( $ this -> arr_rules ) ) { $ str_prov = strtr ( $ str_prov , $ this -> arr_rules ) ; } $ str_prov = transliterator_transliterate ( "Any-Latin; NFD; [:Nonspacing Mark:] Remove; NFC; Lower();" , $ str_prov ) ; $ ... | Renders original string as a slug . |
59,093 | protected function generateIdentifier ( ) { if ( extension_loaded ( 'mongodb' ) ) { $ newObjectId = new \ MongoDB \ BSON \ ObjectID ( ) ; $ uuid = $ newObjectId -> __toString ( ) ; } else { $ uuid = bin2hex ( openssl_random_pseudo_bytes ( 12 ) ) ; } return $ uuid ; } | Generate a UUID . |
59,094 | public function parse ( ) : array { $ buffer = $ this -> routing_rule ; $ section_list_set = [ ] ; $ current_list = [ ] ; do { $ pos = strpos ( substr ( $ buffer , 1 ) , '/' ) ; $ section = $ pos !== false ? substr ( $ buffer , 1 , $ pos ) : substr ( $ buffer , 1 ) ; $ buffer = $ pos !== false ? substr ( $ buffer , $ p... | Parse routing rule |
59,095 | private static function parseVariablePattern ( string $ patern ) : array { static $ supported_types = [ 'string' , 'integer' , 'int' , 'float' , 'double' , 'boolean' , 'bool' , ] ; $ tmp = explode ( ':' , $ patern ) ; $ varname = $ tmp [ 1 ] ?? null ; $ regex = $ tmp [ 2 ] ?? null ; $ type = $ tmp [ 3 ] ?? null ; if ( ... | Parse variable pattern |
59,096 | public function addMenu ( array $ menu , string $ namespace = null , int $ position = null ) : void { foreach ( $ menu as $ name => $ row ) { if ( ! isset ( $ row [ 'link' ] ) ) { throw new InvalidArgumentException ( 'First level of Menu must have set link' ) ; } else { $ link = new Link ( $ name , $ row [ 'link' ] , i... | Prida do Menu polozky |
59,097 | private function addMenuItems ( Item $ parent , array $ menu ) : void { foreach ( $ menu as $ name => $ item ) { if ( array_key_exists ( 'link' , $ item ) ) { $ link = $ parent -> addLink ( $ name , $ item [ 'link' ] , isset ( $ item [ 'arguments' ] ) ? $ item [ 'arguments' ] : [ ] ) ; if ( ! empty ( $ item [ 'toBlank'... | Prida polozky do Menu |
59,098 | public function setBaseUrl ( string $ name , string $ link ) : void { $ this -> baseUrl = new \ stdClass ; $ this -> baseUrl -> name = $ name ; $ this -> baseUrl -> link = $ link ; } | Nastavi korenovou url |
59,099 | public function isLinkAllowed ( string $ link ) : bool { $ this -> prepareLink ( $ link ) ; return $ this -> links [ $ link ] -> allowed ; } | Je aktualni stranka povolena |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.