idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
3,600 | public function randomPrime ( $ min = false , $ max = false , $ timeout = false ) { if ( $ min === false ) { $ min = new BigInteger ( 0 ) ; } if ( $ max === false ) { $ max = new BigInteger ( 0x7FFFFFFF ) ; } $ compare = $ max -> compare ( $ min ) ; if ( ! $ compare ) { return $ min -> isPrime ( ) ? $ min : false ; } e... | Generate a random prime number . |
3,601 | public function bust ( $ file , $ manifest = null ) { if ( ! $ manifest ) { $ manifest = $ this -> getDefaultManifest ( ) ; } $ dir = str_replace ( static :: $ public , '' , dirname ( $ manifest ) ) ; $ manifest = $ this -> loadManifest ( $ manifest ) ; if ( isset ( $ manifest -> $ file ) ) { return "/{$dir}/{$manifest... | get a versioned file name based on file name |
3,602 | public function loadManifest ( $ file ) { if ( ! isset ( static :: $ manifests [ $ file ] ) ) { $ path = realpath ( static :: $ public . "/{$file}" ) ; if ( ! $ path ) { throw new InvalidArgumentException ( "Manifest {$file} does not exist" ) ; } static :: $ manifests [ $ file ] = json_decode ( file_get_contents ( $ pa... | loads a manifest from json file |
3,603 | public function showAction ( ProductItemField $ productitemfield ) { $ editForm = $ this -> createForm ( $ this -> get ( "amulen.shop.form.product.item.field" ) , $ productitemfield , array ( 'action' => $ this -> generateUrl ( 'admin_productitemfield_update' , array ( 'id' => $ productitemfield -> getid ( ) ) ) , 'met... | Finds and displays a ProductItemField entity . |
3,604 | public function newAction ( ) { $ productitemfield = new ProductItemField ( ) ; $ form = $ this -> createForm ( $ this -> get ( "amulen.shop.form.product.item.field" ) , $ productitemfield ) ; return array ( 'productitemfield' => $ productitemfield , 'form' => $ form -> createView ( ) , ) ; } | Displays a form to create a new ProductItemField entity . |
3,605 | public function createAction ( Request $ request ) { $ productitemfield = new ProductItemField ( ) ; $ form = $ this -> createForm ( $ this -> get ( "amulen.shop.form.product.item.field" ) , $ productitemfield ) ; if ( $ form -> handleRequest ( $ request ) -> isValid ( ) ) { $ productitemSrv = $ this -> get ( 'amulen.s... | Creates a new ProductItemField entity . |
3,606 | public function updateAction ( ProductItemField $ productitemfield , Request $ request ) { $ editForm = $ this -> createForm ( $ this -> get ( "amulen.shop.form.product.item.field" ) , $ productitemfield , array ( 'action' => $ this -> generateUrl ( 'admin_productitemfield_update' , array ( 'id' => $ productitemfield -... | Edits an existing ProductItemField entity . |
3,607 | public function assertContainsOnly ( $ type , $ isNativeType = null , $ message = '' ) { Assert :: assertContainsOnly ( $ type , $ this -> getData ( ) , $ isNativeType , $ message ) ; return $ this ; } | Asserts that a haystack contains only values of a given type . |
3,608 | public function assertContainsOnlyInstancesOf ( $ classname , $ message = '' ) { Assert :: assertContainsOnlyInstancesOf ( $ classname , $ this -> getData ( ) , $ message ) ; return $ this ; } | Asserts that a haystack contains only instances of a given classname |
3,609 | public function assertNotContainsOnly ( $ type , $ isNativeType = null , $ message = '' ) { Assert :: assertNotContainsOnly ( $ type , $ this -> getData ( ) , $ isNativeType , $ message ) ; return $ this ; } | Asserts that a haystack does not contain only values of a given type . |
3,610 | public function assertGreaterThan ( $ expected , $ message = '' ) { Assert :: assertGreaterThan ( $ expected , $ this -> getData ( ) , $ message ) ; return $ this ; } | Asserts that a value is greater than another value . |
3,611 | public function assertGreaterThanOrEqual ( $ expected , $ message = '' ) { Assert :: assertGreaterThanOrEqual ( $ expected , $ this -> getData ( ) , $ message ) ; return $ this ; } | Asserts that a value is greater than or equal to another value . |
3,612 | public function assertLessThan ( $ expected , $ message = '' ) { Assert :: assertLessThan ( $ expected , $ this -> getData ( ) , $ message ) ; return $ this ; } | Asserts that a value is smaller than another value . |
3,613 | public function assertLessThanOrEqual ( $ expected , $ message = '' ) { Assert :: assertLessThanOrEqual ( $ expected , $ this -> getData ( ) , $ message ) ; return $ this ; } | Asserts that a value is smaller than or equal to another value . |
3,614 | public function assertSame ( $ expected , $ message = '' ) { Assert :: assertSame ( $ expected , $ this -> getData ( ) , $ message ) ; return $ this ; } | Asserts that two variables have the same type and value . Used on objects it asserts that two variables reference the same object . |
3,615 | public function assertNotSame ( $ expected , $ message = '' ) { Assert :: assertNotSame ( $ expected , $ this -> getData ( ) , $ message ) ; return $ this ; } | Asserts that two variables do not have the same type and value . Used on objects it asserts that two variables do not reference the same object . |
3,616 | public function assertRegExp ( $ pattern , $ message = '' ) { Assert :: assertRegExp ( $ pattern , $ this -> getData ( ) , $ message ) ; return $ this ; } | Asserts that a string matches a given regular expression . |
3,617 | public function assertNotRegExp ( $ pattern , $ message = '' ) { Assert :: assertNotRegExp ( $ pattern , $ this -> getData ( ) , $ message ) ; return $ this ; } | Asserts that a string does not match a given regular expression . |
3,618 | public function assertStringMatchesFormat ( $ format , $ message = '' ) { Assert :: assertStringMatchesFormat ( $ format , $ this -> getData ( ) , $ message ) ; return $ this ; } | Asserts that a string matches a given format string . |
3,619 | public function assertStringNotMatchesFormat ( $ format , $ message = '' ) { Assert :: assertStringNotMatchesFormat ( $ format , $ this -> getData ( ) , $ message ) ; return $ this ; } | Asserts that a string does not match a given format string . |
3,620 | public function assertStringStartsWith ( $ prefix , $ message = '' ) { Assert :: assertStringStartsWith ( $ prefix , $ this -> getData ( ) , $ message ) ; return $ this ; } | Asserts that a string starts with a given prefix . |
3,621 | public function assertStringStartsNotWith ( $ prefix , $ message = '' ) { Assert :: assertStringStartsNotWith ( $ prefix , $ this -> getData ( ) , $ message ) ; return $ this ; } | Asserts that a string starts not with a given prefix . |
3,622 | public function assertStringEndsWith ( $ suffix , $ message = '' ) { Assert :: assertStringEndsWith ( $ suffix , $ this -> getData ( ) , $ message ) ; return $ this ; } | Asserts that a string ends with a given suffix . |
3,623 | public function assertStringEndsNotWith ( $ suffix , $ message = '' ) { Assert :: assertStringEndsNotWith ( $ suffix , $ this -> getData ( ) , $ message ) ; return $ this ; } | Asserts that a string ends not with a given suffix . |
3,624 | public function assertJsonStringEqualsJsonString ( $ expectedJson , $ message = '' ) { Assert :: assertJsonStringEqualsJsonString ( $ expectedJson , $ this -> getData ( ) , $ message ) ; return $ this ; } | Asserts that two given JSON encoded objects or arrays are equal . |
3,625 | public function assertJsonStringNotEqualsJsonString ( $ expectedJson , $ message = '' ) { Assert :: assertJsonStringNotEqualsJsonString ( $ expectedJson , $ this -> getData ( ) , $ message ) ; return $ this ; } | Asserts that two given JSON encoded objects or arrays are not equal . |
3,626 | protected function executeSelect ( Select $ select ) { $ selectState = $ select -> getRawState ( ) ; if ( $ selectState [ 'table' ] != $ this -> table ) { throw new \ RuntimeException ( 'The table name of the provided select object must match that of the table' ) ; } $ this -> featureSet -> apply ( 'preSelect' , array ... | We don t want use default table columns as default select state |
3,627 | private function validateList ( array $ list ) { foreach ( $ list as $ rule ) { if ( ! $ this -> validateRule ( $ rule ) ) { return false ; } } return true ; } | Validate list of firewall rules . |
3,628 | private function validateRule ( $ rule ) { if ( strpos ( $ rule , '/' ) ) { list ( $ rule , $ mask ) = explode ( '/' , $ rule ) ; } if ( filter_var ( $ rule , FILTER_VALIDATE_IP , FILTER_FLAG_IPV4 ) ) { if ( isset ( $ mask ) && ( $ mask < 1 || $ mask > 30 ) ) { return false ; } return true ; } elseif ( filter_var ( $ r... | Validate filtering rule . |
3,629 | protected function add_soft_filter ( ) { if ( $ this -> _col_name !== null ) { $ current_where = $ this -> where ; if ( ! empty ( $ current_where ) ) { $ this -> where = array ( ) ; $ this -> and_where_open ( ) ; $ this -> where = array_merge ( $ this -> where , $ current_where ) ; $ this -> and_where_close ( ) ; } $ t... | Add an additional where clause if needed to execute the soft - filter |
3,630 | public function column ( $ columnKey , $ indexKey = null ) { $ value = array_column ( $ this -> value ( ) , $ columnKey , $ indexKey ) ; return Variables :: from ( $ value ) ; } | Returns the values from a single column of the array identified by the column_key . Optionally you may provide an index_key to index the values in the returned array by the values from the index_key column in the input array . |
3,631 | public function indexByColumn ( $ columnKey ) { $ keys = array_column ( $ this -> value ( ) , $ columnKey ) ; $ value = array_combine ( $ keys , $ this -> values ( ) ) ; return $ this -> setValue ( $ value ) ; } | Uses the values from a single column of the array as collection keys . |
3,632 | public static function download ( $ folder = "" , $ mysql = false , $ czech = false , $ verbose = false ) { $ url = "https://www.adminer.org/latest" ; if ( $ mysql == true ) { $ url .= "-mysql" ; } if ( $ czech == true ) { $ url .= "-cs" ; } $ url .= ".php" ; Transfer :: download ( $ url , $ folder . "/adminer-location... | Downloads latest version of Adminer . |
3,633 | public static function buildCondition ( $ content , $ condition = 'if IE' , $ operator = 'OR' , $ global = false ) { if ( empty ( $ condition ) ) { return $ content ; } $ condition_str = '' ; if ( is_array ( $ condition ) ) { $ count = 0 ; foreach ( $ condition as $ _cond ) { if ( $ count === 0 ) { $ condition_str .= s... | Build an HTML condition string for Internet Explorer around content |
3,634 | public static function writeCondition ( $ content , $ condition = null , $ global = false ) { if ( empty ( $ condition ) ) { return $ content ; } return '<!--[' . $ condition . ']>' . ( $ global ? '<! : '' ) . ' ' . $ content . ' ' . ( $ global ? '<!--' : '' ) . '<![endif] ; } | Write an HTML condition for Internet Explorer around content |
3,635 | public static function parseSingleCondition ( $ condition ) { $ add_ie = strpos ( $ condition , self :: $ internet_explorer ) === false ; foreach ( self :: $ condition_shortcuts as $ key => $ val ) { if ( strpos ( $ condition , $ key ) !== false ) { $ condition = str_replace ( $ key , $ val . ' ' . ( $ add_ie ? self ::... | Parse a single condition item replacing shortcuts |
3,636 | public function getLocale ( ) { if ( ! $ this -> locale ) { $ locale = self :: getStaticLocale ( ) ; if ( ! $ locale ) { $ locale = StdLocale :: getDefault ( ) ; } $ this -> setLocale ( $ locale ) ; } return $ this -> locale ; } | Get Current locale |
3,637 | public function setTranslationTable ( AbstractTableGateway $ tableGateway ) { if ( ! $ tableGateway -> getAdapter ( ) && $ tableGateway instanceof \ Zend \ Db \ Adapter \ AdapterAwareInterface ) { $ tableGateway -> setAdapter ( $ this -> tableGateway -> adapter ) ; } $ this -> i18nTable = $ tableGateway ; return $ this... | Set Translation TableGateway |
3,638 | public function addTranslationRow ( $ column , $ value , $ foreignID ) { $ tableGateway = $ this -> tableGateway ; $ trData = array ( 'model' => get_class ( $ tableGateway ) , 'foreign_key' => $ foreignID , 'field' => $ column , 'locale' => $ this -> getLocale ( ) , 'content' => $ value ) ; $ transTable = $ this -> get... | Add translation data for a row with specific primary key |
3,639 | protected function setProperty ( $ object , $ name ) { $ this -> loadPropertyTypes ( ) ; if ( empty ( $ this -> restrictedProperties ) && $ this -> frozen ) { $ this -> restrictedProperties = $ this -> getRestrictedProperties ( get_class ( ) ) ; } if ( $ name ) { $ this -> assignProperty ( $ name , $ object ) ; } else ... | Add the property to the object |
3,640 | protected function getPropertyTypes ( $ class ) { $ class = new \ ReflectionClass ( $ class ) ; $ properties = $ class -> getDefaultProperties ( ) ; $ propertyTypes = [ ] ; foreach ( $ properties as $ propName => $ property ) { if ( is_string ( $ property ) && ( class_exists ( $ property ) || interface_exists ( $ prope... | Return an array of hinted type for class properties If they don t have a type we ignore it |
3,641 | protected function assignProperty ( $ name , $ value ) { if ( ! empty ( $ this -> propertyTypes [ $ name ] ) && $ value !== null ) { if ( ! ( $ value instanceof $ this -> propertyTypes [ $ name ] ) ) { throw new Exception ( sprintf ( "You can't put an instance of %s in the parameter $%s of type %s" , get_class ( $ valu... | Assing the property while checking if the type matches |
3,642 | public static function Apio ( $ sp , $ theta , $ elong , $ phi , $ hm , $ xp , $ yp , $ refa , $ refb , iauASTROM & $ astrom ) { $ sl ; $ cl ; $ pv = [ ] ; $ astrom -> along = $ elong + $ sp ; $ sl = sin ( $ astrom -> along ) ; $ cl = cos ( $ astrom -> along ) ; $ astrom -> xpl = $ xp * $ cl - $ yp * $ sl ; $ astrom ->... | - - - - - - - - i a u A p i o - - - - - - - - |
3,643 | public function getInputSpecification ( ) { $ spec = [ 'name' => $ this -> getName ( ) , 'required' => false , ] ; if ( $ validator = $ this -> getValidator ( ) ) { $ spec [ 'validators' ] = [ $ validator , ] ; } return $ spec ; } | This is not a required element so we override parent method . |
3,644 | public function get ( string $ name ) { self :: doInit ( ) ; if ( ! isset ( $ _SESSION [ $ name ] ) ) { return null ; } return $ _SESSION [ $ name ] ; } | Returns the session item value by session item name if it exists null otherwise . |
3,645 | public function set ( string $ name , $ value ) : void { self :: doInit ( ) ; $ _SESSION [ $ name ] = $ value ; } | Sets a session item value by session item name . |
3,646 | public function processLogIn ( $ ticket ) { $ file = file_get_contents ( $ this -> casPaths [ 'urls' ] [ 'check' ] . "&ticket={$ticket}" ) ; if ( ! $ file ) { die ( "The authentication process failed to validate through CAS." ) ; } if ( ! empty ( $ file ) ) { $ casXml = simplexml_load_string ( $ file , null , 0 , 'cas'... | Processes the result of a CAS authentication request associating an application user with their corresponding CAS record and logging them into the application |
3,647 | private function retrievePattern ( $ locale , $ key ) { $ resBundle = $ this -> getResourceBundle ( $ locale ) ; $ pattern = $ resBundle -> get ( $ key ) ; if ( $ pattern === null ) { throw new \ IntlException ( $ resBundle -> getErrorMessage ( ) , $ resBundle -> getErrorCode ( ) ) ; } return $ pattern ; } | Retrieve the pattern from the resource bundle |
3,648 | public function process ( ) { list ( $ action , $ ids ) = $ this -> Process -> getRequestVars ( $ this -> name ) ; return $ this -> Process -> make ( $ this -> Groups , $ action , $ ids ) ; } | Process action . |
3,649 | public function set_value ( $ value , $ repopulate = false ) { if ( $ repopulate ) { if ( ( $ this -> type == 'radio' or $ this -> type == 'checkbox' ) and empty ( $ this -> options ) ) { if ( $ this -> value == $ value ) { $ this -> set_attribute ( 'checked' , 'checked' ) ; } return $ this ; } } $ this -> value = $ va... | Change the field s current or default value |
3,650 | public function set_error_message ( $ rule , $ msg ) { empty ( $ rule ) and $ rule = 0 ; $ this -> error_messages [ $ rule ] = strval ( $ msg ) ; return $ this ; } | Overwrite a default error message |
3,651 | public function get_error_message ( $ rule ) { if ( isset ( $ this -> error_messages [ $ rule ] ) ) { return $ this -> error_messages [ $ rule ] ; } elseif ( isset ( $ this -> error_messages [ 0 ] ) ) { return $ this -> error_messages [ 0 ] ; } return null ; } | Check if a rule has an error message overwrite |
3,652 | public function add_rule ( $ callback ) { $ args = array_slice ( func_get_args ( ) , 1 ) ; $ this -> rules [ ] = array ( $ callback , $ args ) ; if ( $ callback === 'required' ) { $ this -> set_attribute ( 'required' , 'required' ) ; } return $ this ; } | Add a validation rule any further arguements after the callback will be used as arguements for the callback |
3,653 | public function delete_rule ( $ callback , $ set_attr = true ) { foreach ( $ this -> rules as $ index => $ rule ) { if ( $ rule [ 0 ] === $ callback ) { unset ( $ this -> rules [ $ index ] ) ; break ; } } if ( $ callback === 'required' and $ set_attr ) { unset ( $ this -> attributes [ $ callback ] ) ; } return $ this ;... | Delete a validation rule |
3,654 | public function set_attribute ( $ attr , $ value = null ) { $ attr = is_array ( $ attr ) ? $ attr : array ( $ attr => $ value ) ; foreach ( $ attr as $ key => $ value ) { if ( $ value === null ) { unset ( $ this -> attributes [ $ key ] ) ; } else { $ this -> attributes [ $ key ] = $ value ; } } return $ this ; } | Sets an attribute on the field |
3,655 | public function get_attribute ( $ key = null , $ default = null ) { if ( $ key === null ) { return $ this -> attributes ; } if ( is_array ( $ key ) ) { $ output = array ( ) ; foreach ( $ key as $ k ) { $ output [ $ k ] = array_key_exists ( $ k , $ this -> attributes ) ? $ this -> attributes [ $ k ] : $ default ; } retu... | Get a single or multiple attributes by key |
3,656 | public function set_options ( $ value , $ label = null , $ replace_options = false ) { if ( ! is_array ( $ value ) ) { \ Arr :: set ( $ this -> options , $ value , $ label ) ; return $ this ; } $ merge = function ( & $ array , $ new , $ merge ) { foreach ( $ new as $ k => $ v ) { if ( isset ( $ array [ $ k ] ) and is_a... | Add an option value with label |
3,657 | function setProtocol ( $ protocol ) { $ protocol = ( string ) $ protocol ; $ protocol = strtolower ( $ protocol ) ; if ( $ protocol !== 'http' && $ protocol !== 'https' ) throw new \ InvalidArgumentException ( sprintf ( 'Protocol (%s) not supported; using "http" or "https".' , $ protocol ) ) ; $ this -> protocol = $ pr... | Set Protocol Scheme |
3,658 | function setTarget ( $ target = null , $ preserveHost = true ) { $ target = ( string ) $ target ; if ( empty ( $ target ) && $ target !== "0" ) $ target = '/' ; if ( parse_url ( $ target ) === false ) { $ target = rawurlencode ( $ target ) ; } $ this -> target_uri = ( string ) $ target ; return $ this ; } | Set Uri Target |
3,659 | public static function createWithBuilder ( HandlerBuilderInterface $ builder , FormatterRegistryInterface $ formatterRegistry , $ debug = false ) { $ handler = $ builder -> buildHandler ( ) ; $ docGenerator = new DocGenerator ( $ builder -> buildDocExtractor ( ) , $ formatterRegistry ) ; return new static ( $ handler ,... | Create server via handler builder |
3,660 | public function load ( $ source ) { if ( $ this -> isFile ( $ source ) ) { return $ this -> loadFile ( $ source ) ; } else { return $ this -> loadString ( $ source ) ; } } | load YAML file or string . |
3,661 | public function loadFile ( $ file ) { if ( $ this -> enableSpyc ( ) ) { if ( ! file_exists ( $ file ) ) return [ ] ; $ content = file_get_contents ( $ file ) ; $ content = $ this -> parseEnvironmentVariables ( $ content ) ; return $ this -> loadBySpyc ( $ content ) ; } else { throw new NotFoundException ( 'Not found YA... | load by file . |
3,662 | public function parseEnvironmentVariables ( $ content ) { $ func = function ( $ matches ) { $ value = getenv ( $ matches [ 1 ] ) ; return $ value === false ? 'null' : $ value ; } ; $ content = preg_replace_callback ( '/%([\w_]+?)%/' , $ func , $ content ) ; return $ content ; } | parse environment variables |
3,663 | function getListSQL ( $ query , $ class ) { $ connection = $ this -> getConnection ( ) ; $ result = mysql_query ( $ query , $ connection ) ; if ( ! $ result ) { die ( 'Error: ' . mysql_error ( ) ) ; } $ list = array ( ) ; while ( $ row = mysql_fetch_array ( $ result ) ) { $ instance = new $ class ; $ instance -> hidrat... | Retorna una lista de la entidad pasada por parametro de acuerdo a la consulta recibida . |
3,664 | static function load ( $ name ) { $ lang = Config :: read ( 'App.Base.language' ) ; $ prop = Loader :: getName ( $ name , 'locale' . DS . $ lang ) ; if ( isset ( self :: $ language [ $ prop -> app ] ) ) { return self :: $ language [ $ prop -> app ] ; } if ( ! file_exists ( $ prop -> path ) ) { user_error ( 'Language No... | Load file language |
3,665 | static function item ( $ name , $ replace = [ ] ) { $ prop = self :: engineName ( $ name ) ; $ lang = $ prop -> key ; if ( isset ( self :: $ language [ $ prop -> app ] [ $ prop -> key ] ) ) { $ lang = self :: $ language [ $ prop -> app ] [ $ prop -> key ] ; } $ map_replace = [ 'today' => date ( Config :: read ( 'App.Ba... | get Item Language and replace string language |
3,666 | static function engineName ( $ name ) { $ segments = explode ( '.' , $ name ) ; $ app = 'App' ; if ( count ( $ segments ) == 2 ) { $ app = current ( $ segments ) ; } return ( object ) [ 'app' => $ app , 'key' => end ( $ segments ) ] ; } | parse name app and key item language |
3,667 | public function getService ( $ service_name , \ Google_Client $ client ) { $ this -> library -> load ( 'gapi' ) ; $ class = "Google_Service_$service_name" ; if ( ! class_exists ( $ class ) ) { throw new LogicException ( "Class $class not found" ) ; } return new $ class ( $ client ) ; } | Returns a Google service class instance |
3,668 | public function getServiceNames ( ) { $ dir = __DIR__ . '/../vendor/google/apiclient-services/src/Google/Service' ; if ( ! is_dir ( $ dir ) || ! is_readable ( $ dir ) ) { throw new RuntimeException ( "Cannot read directory $dir" ) ; } $ this -> library -> load ( 'gapi' ) ; $ names = array ( ) ; foreach ( glob ( "$dir/*... | Returns an array of Google service names supported by the library |
3,669 | private function matchesRequest ( $ route ) { $ requestURL = $ this -> requestURL ; if ( isset ( $ route [ 'fullDomainMatch' ] ) && $ route [ 'fullDomainMatch' ] == true ) { $ requestURL = $ this -> fullRequestURL ; } if ( isset ( $ route [ 'method' ] ) && $ route [ 'method' ] != $ this -> requestMethod ) { return fals... | Checks if route matches the request URL |
3,670 | public function beforeGenerate ( ) { $ this -> writeln ( '<?php' ) ; $ this -> writeln ( '# Generated by mfn/php-reflection-gen ' . Reflector :: VERSION ) ; $ this -> writeln ( '# PHP Version ' . phpversion ( ) ) ; } | Called before generating starts |
3,671 | public function hasOption ( $ strOption , $ boolAllowNull = false ) { if ( $ this -> options ( ) ) { if ( $ boolAllowNull || ! is_null ( $ this -> options ( ) -> { $ strOption } ) ) { return true ; } } return false ; } | Has Option Method |
3,672 | public static function varInfo ( $ var , $ type = NULL ) { if ( $ var === NULL ) return 'NULL' ; $ type = self :: getType ( $ var ) ; if ( $ type == 'string' ) { return sprintf ( 'string(%d) "%s"' , mb_strlen ( $ var ) , ( string ) $ var ) ; } elseif ( $ type == 'array' ) { return sprintf ( 'array(%s)' , A :: implode (... | Verbose as much as possible for this var |
3,673 | public function add ( Parameter $ parameter ) { $ this -> parametersByName [ $ parameter -> getName ( ) ] = $ parameter ; $ this -> parametersByPosition [ count ( $ this -> parametersByPosition ) ] = $ parameter ; return $ this ; } | Add paramter to list |
3,674 | public function getByName ( $ name ) { $ name = ( string ) $ name ; if ( substr ( $ name , 0 , 1 ) !== ':' ) { $ name = ':' . $ name ; } if ( ! isset ( $ this -> parametersByName [ $ name ] ) ) { throw new \ Exception ( 'Parameter is not defined !' ) ; } return $ this -> parametersByName [ $ name ] ; } | Get parameter by his name . |
3,675 | public function getByPosition ( $ position ) { $ position = ( int ) $ position ; if ( ! isset ( $ this -> parametersByPosition [ $ position ] ) ) { throw new \ Exception ( 'Parameter is not defined !' ) ; } return $ this -> parametersByPosition [ $ position ] ; } | Get parameter by his position . |
3,676 | protected function setupHttpClientSettings ( ) { $ this -> httpClient -> setDefaultOption ( 'exceptions' , false ) ; $ this -> httpClient -> setDefaultOption ( 'timeout' , $ this -> options [ 'timeout' ] ) ; $ this -> httpClient -> setDefaultOption ( 'connect_timeout' , $ this -> options [ 'connect_timeout' ] ) ; $ thi... | Setup HTTP Client settings . |
3,677 | protected function setRequestFullPath ( ) { $ fullPath = sprintf ( '%s/%s/%s/%s' , $ this -> path , $ this -> version , $ this -> resource , $ this -> param ) ; $ this -> request -> setPath ( str_replace ( '//' , '' , rtrim ( $ fullPath , '/' ) ) ) ; } | Set URL Request Paths |
3,678 | protected function setRequestQueryString ( ) { $ query = $ this -> request -> getQuery ( ) ; foreach ( $ this -> queryStrings as $ key => $ value ) { $ query -> set ( $ key , $ value ) ; } } | Set URL Request Query String |
3,679 | protected function createRequest ( $ method , $ payload = [ ] ) { $ this -> setMockResponses ( ) ; $ this -> setupHttpClientSettings ( ) ; $ this -> request = $ this -> httpClient -> createRequest ( $ method , $ this -> environment , [ 'json' => $ payload ] ) ; $ this -> setRequestFullPath ( ) ; $ this -> setRequestQue... | Create a request to Moip API |
3,680 | protected function send ( ) { $ response = $ this -> httpClient -> send ( $ this -> request ) ; return $ this -> response = new MoipResponse ( $ response , $ this -> resource ) ; } | Send a request to Moip API |
3,681 | protected function setMockResponses ( ) { if ( $ this -> mocks ) { $ this -> httpClient -> getEmitter ( ) -> attach ( new Mock ( $ this -> mocks ) ) ; } } | Set Mocks Responses |
3,682 | public function put ( $ route , array $ binds = [ ] , $ payload = [ ] ) { $ this -> setParam ( $ route , $ binds ) ; return $ this -> createRequest ( 'PUT' , $ payload ) ; } | HTTP method PUT |
3,683 | public function post ( $ route , array $ binds = [ ] , $ payload = [ ] ) { $ this -> setParam ( $ route , $ binds ) ; return $ this -> createRequest ( 'POST' , $ payload ) ; } | HTTP method POST |
3,684 | public function setParam ( $ param , array $ binds = [ ] ) { $ this -> param = preg_replace_callback ( '/\{\w+\}/' , function ( ) use ( & $ binds ) { return array_shift ( $ binds ) ; } , trim ( $ param , '/' ) ) ; return $ this ; } | Set request param |
3,685 | public function addQueryString ( $ key , $ value ) { if ( is_bool ( $ value ) ) { $ value = $ value ? 'true' : 'false' ; } $ item [ $ key ] = ( string ) $ value ; $ this -> queryStrings [ ] = $ item ; return $ this ; } | Add Query String to Request |
3,686 | public function setDefaultOption ( $ option , $ value ) { if ( ! array_key_exists ( $ option , $ this -> options ) ) { throw new UnexpectedValueException ( "Unexpected MoipClient {$option} option" ) ; } $ this -> options [ $ option ] = $ value ; } | Set default option |
3,687 | public static function make ( $ action , $ url , array $ attributes = [ ] , $ disabled = false ) { return new static ( $ action , $ url , $ attributes , $ disabled ) ; } | Make link instance . |
3,688 | public function isOpen ( $ key ) { return isset ( $ this -> states [ $ key ] ) and $ this -> states [ $ key ] -> isOpen ( ) ; } | Whether a state document is open . |
3,689 | public function isMutable ( $ key ) { return isset ( $ this -> states [ $ key ] ) and $ this -> states [ $ key ] -> isMutable ( ) ; } | Whether a state document is open and mutable . |
3,690 | public function close ( $ key ) { if ( isset ( $ this -> states [ $ key ] ) and $ this -> states [ $ key ] -> isOpen ( ) ) { $ this -> states [ $ key ] -> close ( ) ; } } | Close a state document . |
3,691 | public function closeAll ( ) { $ open = array ( ) ; foreach ( $ this -> states as $ key => $ state ) { if ( $ state -> isOpen ( ) ) { $ state -> close ( ) ; $ open [ ] = $ key ; } } return $ open ; } | Close all open state documents . |
3,692 | public function success ( ) { if ( ! $ this -> isClosed ( ) ) { $ this -> fireEvent ( self :: OPEN , self :: CLOSED ) ; } $ this -> failures = [ ] ; return $ this -> write ( ) ; } | If the operation succeeds call this function to tell the breaker everything went well . |
3,693 | public function failure ( ) { $ this -> failures [ ] = time ( ) ; $ now = time ( ) ; $ cooldownBound = $ now - $ this -> cooldown ; foreach ( $ this -> failures as $ i => $ time ) { if ( $ time < $ cooldownBound ) { unset ( $ this -> failures [ $ i ] ) ; } } if ( $ this -> isOpen ( ) ) { $ this -> fireEvent ( self :: C... | If the operation fails call this function to tell the breaker something went wrong . |
3,694 | public function isClosed ( ) { $ validFails = 0 ; $ now = time ( ) ; $ cooldownBound = $ now - $ this -> cooldown ; foreach ( $ this -> failures as $ i => $ time ) { if ( $ time >= $ cooldownBound ) { $ validFails ++ ; } } return $ validFails < $ this -> threshold ; } | If the breaker is CLOSED you CAN perform the operation as everything is ok . |
3,695 | public function determineOutputType ( ) : string { $ contentType = $ this -> getContentType ( ) ; $ type = self :: TYPE_HTML ; if ( is_string ( $ contentType ) && trim ( $ contentType ) !== '' && preg_match ( '` (?P<' . self :: TYPE_JSON . '>\/ja?son|js) | (?P<' . self :: TYPE_PLAI... | Determine Output Type |
3,696 | public function import ( $ file ) { if ( ! file_exists ( $ file ) ) return ; $ settings = $ this -> yaml -> load ( $ file ) ; foreach ( $ settings as $ alias => $ setting ) { $ database = new Database ( $ setting ) ; $ database -> database_dir = $ this -> config -> getDataDir ( ) ; $ this -> _databases [ $ alias ] = $ ... | import database configurations |
3,697 | public function getDatabase ( $ alias , $ target = Database :: TARGET_MASTER ) { $ database = isset ( $ this -> _databases [ $ alias ] ) ? $ this -> _databases [ $ alias ] : null ; if ( $ target === Database :: TARGET_SLAVE ) { $ database = $ database -> pickSlave ( ) ; } return $ database ; } | get database configuration . |
3,698 | public function getTable ( $ alias ) { if ( isset ( $ this -> _table_factory [ $ alias ] ) ) return $ this -> _table_factory [ $ alias ] ; $ class_name = $ this -> config -> getNamingStrategy ( ) -> aliasToTableClassName ( $ alias ) ; foreach ( $ this -> config -> getModelDirs ( ) as $ dir ) { $ class_full_name = sprin... | get model instance |
3,699 | public function getTableSchema ( $ table , $ database = 'base' ) { $ cacher = $ this -> config -> getSchemaCacher ( ) ; if ( $ cacher -> has ( $ table ) ) return $ cacher -> get ( $ table ) ; $ driver = $ this -> getDatabase ( $ database ) -> getDriver ( ) ; $ connection = $ this -> establishConnection ( $ database , D... | get table schema instance |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.