idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
26,100 | public function valuesExpr ( $ expression ) { $ args = func_get_args ( ) ; $ this -> expression = array_shift ( $ args ) ; if ( empty ( $ args ) ) return $ this ; try { $ this -> valuesArray ( $ args [ 0 ] ) ; } catch ( \ InvalidArgumentException $ e ) { $ this -> valueList = $ args ; } return $ this ; } | Sets the VALUES clause along with its arguments |
26,101 | public function valuesArray ( $ values ) { if ( $ values instanceof \ ArrayObject ) $ this -> value = $ values -> getArrayCopy ( ) ; elseif ( is_object ( $ values ) ) $ this -> value = get_object_vars ( $ values ) ; elseif ( is_array ( $ values ) ) $ this -> value = $ values ; else throw new \ InvalidArgumentException ( "Method 'valuesArray' expected an object or array value" ) ; if ( is_numeric ( key ( $ this -> value ) ) ) { $ this -> valueList = $ this -> value ; $ this -> value = null ; } return $ this ; } | Sets the value to insert as an associative array |
26,102 | public function columns ( $ columns ) { if ( is_array ( $ columns ) ) $ this -> columnList = $ columns ; else $ this -> columnList = func_get_args ( ) ; return $ this ; } | Sets the column list |
26,103 | protected function translateColumn ( $ column ) { if ( $ column instanceof Column ) return $ column -> getName ( ) ; return preg_match ( '/^(\w+)/' , $ column , $ matches ) ? $ matches [ 1 ] : $ column ; } | Translates a insert column |
26,104 | protected function buildColumnsClause ( ) { if ( empty ( $ this -> columnList ) ) { if ( ! empty ( $ this -> value ) ) $ this -> columnList = array_keys ( $ this -> value ) ; else return '' ; } $ columns = [ ] ; foreach ( $ this -> columnList as $ column ) $ columns [ ] = $ this -> translateColumn ( $ column ) ; return implode ( ',' , $ columns ) ; } | Returns the column list as a string |
26,105 | protected function buildValuesClause ( ) { if ( ! empty ( $ this -> expression ) ) return $ this -> expression ; if ( empty ( $ this -> value ) ) { $ values = [ ] ; for ( $ i = 0 , $ n = count ( $ this -> valueList ) ; $ i < $ n ; $ i ++ ) $ values [ ] = '%{' . $ i . '}' ; return implode ( ',' , $ values ) ; } $ values = [ ] ; foreach ( $ this -> columnList as $ column ) { $ name = $ this -> parseColumn ( $ column ) ; $ values [ ] = '#{' . $ name . '}' ; } return implode ( ',' , $ values ) ; } | Returns the value list expression |
26,106 | public function setUrl ( $ url ) { $ relation = new RelationLink ( ) ; $ relation -> setRelationType ( 'self' ) -> setUrl ( $ url ) ; return $ this -> setRelation ( $ relation ) ; } | Set the feed url . |
26,107 | private function getRelationSilently ( $ rel ) { $ result = null ; try { $ result = $ this -> getRelation ( $ rel ) ; } catch ( \ Exception $ e ) { } return $ result ; } | Get a relation link failing silently . |
26,108 | public static function get ( & $ options = array ( ) , $ key , $ defaultValue = null , $ unsetValue = false , $ emptyStringIsNull = false ) { if ( is_array ( $ key ) ) { return static :: getMany ( $ options , $ key , $ defaultValue , $ unsetValue ) ; } $ _originalKey = $ key ; $ _newValue = $ defaultValue ; $ key = static :: _cleanKey ( $ key ) ; if ( is_array ( $ options ) || $ options instanceof \ ArrayAccess ) { if ( ! isset ( $ options [ $ key ] ) && isset ( $ options [ $ _originalKey ] ) ) { $ key = $ _originalKey ; } if ( isset ( $ options [ $ key ] ) ) { $ _newValue = $ options [ $ key ] ; if ( false !== $ unsetValue ) { unset ( $ options [ $ key ] ) ; } return $ emptyStringIsNull && empty ( $ _newValue ) ? null : $ _newValue ; } } if ( is_object ( $ options ) ) { if ( ! property_exists ( $ options , $ key ) && property_exists ( $ options , $ _originalKey ) ) { $ key = $ _originalKey ; } if ( isset ( $ options -> { $ key } ) ) { $ _newValue = $ options -> { $ key } ; if ( false !== $ unsetValue ) { unset ( $ options -> { $ key } ) ; } return $ emptyStringIsNull && empty ( $ _newValue ) ? null : $ _newValue ; } else if ( method_exists ( $ options , 'get' . $ key ) ) { $ _getter = 'get' . Inflector :: deneutralize ( $ key ) ; $ _setter = 'set' . Inflector :: deneutralize ( $ key ) ; $ _newValue = $ options -> { $ _getter } ( ) ; if ( false !== $ unsetValue && method_exists ( $ options , $ _setter ) ) { $ options -> { $ _setter } ( null ) ; } } } return $ emptyStringIsNull && empty ( $ _newValue ) ? null : $ _newValue ; } | Retrieves an option from the given array . |
26,109 | public static function addTo ( & $ source , $ key , $ subKey , $ value = null ) { $ _target = static :: clean ( static :: get ( $ source , $ key , array ( ) ) ) ; static :: set ( $ _target , $ subKey , $ value ) ; static :: set ( $ source , $ key , $ _target ) ; return $ _target ; } | Adds a value to a property array |
26,110 | public static function removeFrom ( & $ source , $ key , $ subKey ) { $ _target = static :: clean ( static :: get ( $ source , $ key , array ( ) ) ) ; $ _result = static :: remove ( $ _target , $ subKey ) ; static :: set ( $ source , $ key , $ _target ) ; return $ _result ; } | Removes a value from a property array |
26,111 | public static function set ( & $ options = array ( ) , $ key , $ value = null ) { if ( is_array ( $ key ) ) { return static :: setMany ( $ options , $ key ) ; } $ _cleanKey = static :: _cleanKey ( $ key ) ; if ( is_array ( $ options ) ) { if ( ! array_key_exists ( $ key , $ options ) && array_key_exists ( $ _cleanKey , $ options ) ) { $ key = $ _cleanKey ; } $ options [ $ key ] = $ value ; return true ; } if ( is_object ( $ options ) ) { $ _setter = 'set' . Inflector :: deneutralize ( $ key ) ; if ( method_exists ( $ options , $ _setter ) ) { $ options -> { $ _setter } ( $ value ) ; return true ; } if ( property_exists ( $ options , $ key ) ) { $ options -> { $ key } = $ value ; return true ; } if ( property_exists ( $ options , $ _cleanKey ) ) { $ options -> { $ _cleanKey } = $ value ; return true ; } return false ; } return false ; } | Sets an value in the given array at key . |
26,112 | public static function remove ( & $ options = array ( ) , $ key ) { $ _originalValue = null ; if ( static :: contains ( $ options , $ key ) ) { $ _cleanedKey = static :: _cleanKey ( $ key ) ; if ( is_array ( $ options ) ) { if ( ! isset ( $ options [ $ key ] ) && isset ( $ options [ $ _cleanedKey ] ) ) { $ key = $ _cleanedKey ; } if ( isset ( $ options [ $ key ] ) ) { $ _originalValue = $ options [ $ key ] ; unset ( $ options [ $ key ] ) ; } } else { if ( ! isset ( $ options -> { $ key } ) && isset ( $ options -> { $ _cleanedKey } ) ) { $ key = $ _cleanedKey ; } if ( isset ( $ options -> { $ key } ) ) { $ _originalValue = $ options -> { $ key } ; } unset ( $ options -> { $ key } ) ; } } return $ _originalValue ; } | Unsets an option in the given array |
26,113 | public static function clean ( $ array = null , $ callback = null ) { $ _result = ( empty ( $ array ) ? array ( ) : ( ! is_array ( $ array ) ? array ( $ array ) : $ array ) ) ; if ( null === $ callback || ! is_callable ( $ callback ) ) { return $ _result ; } $ _response = array ( ) ; foreach ( $ _result as $ _item ) { $ _response [ ] = call_user_func ( $ callback , $ _item ) ; } return $ _response ; } | Ensures the argument passed in is actually an array with optional iteration callback |
26,114 | public static function merge ( $ target ) { $ _arrays = static :: clean ( func_get_args ( ) ) ; $ _target = static :: clean ( array_shift ( $ _arrays ) ) ; foreach ( $ _arrays as $ _array ) { $ _target = array_merge ( $ _target , static :: clean ( $ _array ) ) ; unset ( $ _array ) ; } unset ( $ _arrays ) ; return $ _target ; } | Merge one or more arrays but ensures each is an array . Basically an idiot - proof array_merge |
26,115 | public static function prefixKeys ( $ prefix , array $ data = array ( ) ) { foreach ( static :: clean ( $ data ) as $ _key => $ _value ) { if ( is_numeric ( $ _key ) ) { continue ; } if ( is_array ( $ _value ) ) { $ _value = static :: prefixKeys ( $ prefix , $ _value ) ; } $ data [ $ prefix . $ _key ] = $ _value ; unset ( $ data [ $ _key ] ) ; } return $ data ; } | Spins through an array and prefixes the keys with a string |
26,116 | protected static function _cleanKey ( $ key , $ opposite = true ) { if ( ! static :: $ _neutralizeKeys ) { $ _cleaned = $ key ; } elseif ( $ key == ( $ _cleaned = Inflector :: neutralize ( $ key ) ) ) { if ( $ opposite ) { return Inflector :: deneutralize ( $ key , true ) ; } } return $ _cleaned ; } | Converts key to a neutral format if not already ... |
26,117 | public function setInput ( $ input ) { $ this -> input = ProcessUtils :: validateInput ( sprintf ( '%s::%s' , __CLASS__ , __FUNCTION__ ) , $ input ) ; return $ this ; } | Sets the input of the process . |
26,118 | public function dump ( $ value ) { if ( is_object ( $ value ) ) { return get_class ( $ value ) ; } if ( is_resource ( $ value ) ) { return get_resource_type ( $ value ) ; } return var_export ( $ value , true ) ; } | Create a string representation of any PHP value . |
26,119 | protected function isDeferred ( $ key ) { $ res = [ ] ; if ( isset ( $ this -> defer [ $ key ] ) ) { $ res [ 'expire' ] = $ this -> defer [ $ key ] -> getExpiration ( ) -> getTimestamp ( ) ; } return $ res ; } | In deferred array ? |
26,120 | public function validate ( FormEvent $ event ) { $ alias = $ event -> getData ( ) -> getNode ( ) -> alias ; if ( $ alias instanceof ValueHolderInterface ) { $ alias = $ alias -> getWrappedValueHolderValue ( ) ; } $ violations = $ this -> validator -> validate ( $ alias ) ; if ( ! $ violations ) { return ; } $ mapper = new ViolationMapper ( ) ; foreach ( $ violations as $ violation ) { $ mapper -> mapViolation ( $ violation , $ event -> getForm ( ) , true ) ; } } | Validate if the Alias is valid and unique . |
26,121 | public function getActivate ( Request $ request , $ token ) { $ user = User :: where ( 'token' , $ token ) -> first ( ) ; if ( ! $ user ) { throw new NotFoundHttpException ; } $ user -> is_activated = true ; $ user -> token = null ; $ user -> save ( ) ; if ( method_exists ( $ this , 'userActivated' ) ) { $ this -> userRegistered ( $ request , $ token , $ user ) ; } return view ( $ this -> getUserActivatingView ( ) , [ 'user' => $ user , 'token' => $ token ] ) ; } | Activate a user by a link |
26,122 | protected function validateCreating ( ) { $ rules = config ( 'taki.validator.create' , [ ] ) ; if ( config ( 'taki.username.required' ) && ! array_get ( $ rules , config ( 'taki.field.username' ) ) ) { $ rules [ config ( 'taki.field.username' ) ] = config ( 'taki.username.validator' , 'required' ) ; } return $ rules ; } | get the validation rules when creating user |
26,123 | public function getUrl ( $ option ) { if ( $ this -> isActive ( $ option ) ) { $ params = $ this -> request -> all ( ) ; unset ( $ params [ $ this -> getKey ( ) ] ) ; return '?' . http_build_query ( $ params ) ; } return '?' . http_build_query ( [ $ this -> key => $ option ] + $ this -> request -> all ( ) ) ; } | Return the URL parameter string to enable this filter . |
26,124 | public function getAccountFeed ( $ uri = self :: ANALYTICS_ACCOUNT_FEED_URI ) { if ( $ uri instanceof Query ) { $ uri = $ uri -> getQueryUrl ( ) ; } return parent :: getFeed ( $ uri , 'Zend_Gdata_Analytics_AccountFeed' ) ; } | Retrieve account feed object |
26,125 | public function getDataFeed ( $ uri = self :: ANALYTICS_FEED_URI ) { if ( $ uri instanceof Query ) { $ uri = $ uri -> getQueryUrl ( ) ; } return parent :: getFeed ( $ uri , 'Zend_Gdata_Analytics_DataFeed' ) ; } | Retrieve data feed object |
26,126 | public static function get ( $ name , $ default = null ) { $ dots = null ; if ( $ pos = strpos ( $ name , '.' ) ) { $ dots = substr ( $ name , $ pos + 1 ) ; $ name = substr ( $ name , 0 , $ pos ) ; } if ( isset ( $ GLOBALS [ ARX_HOOK ] [ $ name ] ) ) { if ( $ dots ) { return Arr :: get ( $ GLOBALS [ ARX_HOOK ] [ $ name ] , $ dots , $ default ) ; } return $ GLOBALS [ ARX_HOOK ] [ $ name ] ; } if ( $ default ) { return $ default ; } return false ; } | Get registered hook |
26,127 | private function parse ( ) { $ handle = fopen ( $ this -> filepath , 'r' ) ; if ( ! $ handle ) throw new \ Exception ( "Can't read file $this->filepath" ) ; $ plugin = null ; while ( ( $ line = fgets ( $ handle ) ) !== false ) { if ( starts_with ( $ line , '#' ) || trim ( $ line ) === '' ) continue ; else if ( starts_with ( $ line , 'description' ) ) $ this -> parseDescription ( $ line ) ; else if ( starts_with ( $ line , 'help' ) ) $ this -> parseHelp ( $ line ) ; else if ( starts_with_whitespace ( $ line ) ) $ plugin -> parseCommand ( $ line ) ; else { $ plugin = $ this -> parseCurrentPlugin ( $ line ) ; } } fclose ( $ handle ) ; $ this -> isParsed = true ; } | Private since files should only be parsed when neccesary |
26,128 | public function render ( $ template = null ) { if ( null === $ template ) { $ template = 'SilvestraAdminBundle:Menu:vertical_admin_menu.html.twig' ; } return $ this -> helper -> render ( $ template , $ this -> builder -> build ( ) ) ; } | Render admin menu . |
26,129 | public function init ( ) { if ( $ this -> initialized ) return $ this ; $ this -> initialized = true ; $ this -> check_tables ( ) ; return $ this ; } | Initialize properties tables etc . |
26,130 | public function deinit ( ) { if ( ! $ this -> initialized ) return $ this ; $ this -> user_token = null ; $ this -> user_data = null ; $ this -> expiration = 3600 * 2 ; $ this -> byway_expiration = 3600 * 24 * 7 ; $ this -> initialized = false ; return $ this ; } | Restore properties to default . |
26,131 | protected function store_check_expiration ( $ expiration = null ) { if ( ! $ expiration ) return 3600 * 2 ; $ expiration = ( int ) $ expiration ; if ( $ expiration < 600 ) $ expiration = 600 ; return $ expiration ; } | Verify expiration . |
26,132 | private function check_tables ( ) { $ tab = new AdminStoreTables ( ) ; $ tab :: init ( $ this ) ; $ force = $ this -> force_create_table ; if ( $ tab :: exists ( $ force ) ) { if ( ! $ force ) $ tab :: upgrade ( ) ; $ tab :: deinit ( ) ; return ; } $ tab :: install ( $ this -> expiration ) ; $ tab :: deinit ( ) ; } | Check tables . |
26,133 | protected function store_match_password ( $ uname , $ upass , $ usalt ) { $ udata = $ this -> store -> query ( "SELECT uid, uname " . "FROM udata WHERE upass=? LIMIT 1" , [ self :: hash_password ( $ uname , $ upass , $ usalt ) ] ) ; if ( ! $ udata ) return false ; return $ udata ; } | Match password and return user data on success . |
26,134 | protected function store_redis_cache_read ( $ token ) { if ( ! $ this -> redis ) return null ; $ key = sprintf ( '%s:%s' , $ this -> token_name , $ token ) ; $ data = $ this -> redis -> get ( $ key ) ; if ( $ data === false ) return null ; $ data = @ json_decode ( $ data , true ) ; if ( ! $ data ) $ data = [ 'uid' => - 2 ] ; $ this -> logger -> debug ( sprintf ( "Zapmin: session read from cache: '%s' <- '%s'." , $ token , json_encode ( $ data ) ) ) ; return $ data ; } | Read session data from cache . |
26,135 | protected function store_redis_cache_write ( $ token , $ data , $ expire_at , $ expire = null ) { if ( ! $ this -> redis ) return ; $ key = sprintf ( '%s:%s' , $ this -> token_name , $ token ) ; $ this -> redis -> set ( $ key , json_encode ( $ data ) ) ; if ( $ expire === null ) { $ expire_at = str_replace ( ' ' , 'T' , $ expire_at ) . 'Z' ; $ expire_at = \ DateTime :: createFromFormat ( \ DateTime :: ATOM , $ expire_at ) -> format ( "U" ) ; $ expire = $ expire_at ; } $ this -> redis -> expire ( $ key , $ expire ) ; $ this -> logger -> debug ( sprintf ( "Zapmin: session written to cache: '%s' <- '%s'." , $ token , json_encode ( $ data ) ) ) ; } | Write session to cache . |
26,136 | protected function store_redis_cache_del ( $ token ) { if ( ! $ this -> redis ) return ; $ key = sprintf ( '%s:%s' , $ this -> token_name , $ token ) ; $ this -> redis -> del ( $ key ) ; $ this -> logger -> debug ( sprintf ( "Zapmin: session removed from cache: '%s'." , $ token ) ) ; } | Remove session cache . |
26,137 | protected function store_get_user_status ( ) { $ this -> init ( ) ; if ( $ this -> user_token === null ) return null ; if ( $ this -> user_data !== null ) return $ this -> user_data ; $ token = $ this -> user_token ; $ cached = $ this -> store_redis_cache_read ( $ token ) ; if ( $ cached !== null ) { if ( $ cached [ 'uid' ] == - 1 ) return null ; return $ this -> user_data = $ cached ; } $ expire = $ this -> store -> stmt_fragment ( 'datetime' ) ; $ session = $ this -> store -> query ( sprintf ( "SELECT * FROM v_usess " . "WHERE token=? AND expire>%s " . "LIMIT 1" , $ expire ) , [ $ token ] ) ; if ( ! $ session ) { $ this -> store_reset_status ( ) ; $ this -> store_redis_cache_write ( $ token , [ 'uid' => - 1 ] , null , 600 ) ; return $ this -> user_data ; } if ( ! $ this -> redis ) return $ this -> user_data = $ session ; $ this -> store_redis_cache_write ( $ token , $ session , $ session [ 'expire' ] ) ; return $ this -> user_data = $ session ; } | Populate session data . |
26,138 | protected function store_is_logged_in ( ) { $ this -> init ( ) ; if ( $ this -> user_data === null ) $ this -> adm_status ( ) ; return $ this -> user_data ; } | Check if current user is signed in . |
26,139 | protected function store_close_session ( $ sid ) { $ now = $ this -> store -> stmt_fragment ( 'datetime' ) ; $ this -> store -> query_raw ( sprintf ( "UPDATE usess SET expire=(%s) WHERE sid='%s'" , $ now , $ sid ) ) ; $ this -> store_redis_cache_del ( $ this -> user_token ) ; } | Close session record in the database . |
26,140 | final protected function existOrFail ( string $ key ) : void { if ( ! isset ( $ this -> env [ $ key ] ) ) { throw new MissingConfigException ( $ key , static :: class ) ; } } | Check if a specific env variable is set or not . If it isn t set throw an exception . |
26,141 | final protected function getBool ( string $ key , bool $ default = false ) : bool { if ( ! isset ( $ this -> env [ $ key ] ) or ! is_string ( $ this -> env [ $ key ] ) ) { return $ default ; } $ t = strtolower ( trim ( $ this -> env [ $ key ] ) ) ; $ allowed = [ 'true' => true , 'on' => true , '1' => true , 'false' => false , 'off' => false , '0' => false , ] ; if ( isset ( $ allowed [ $ t ] ) ) { return $ allowed [ $ t ] ; } if ( is_numeric ( $ t ) ) { return true ; } throw new InvalidConfigException ( $ key , static :: class ) ; } | Get bool value from env variables . |
26,142 | private function round ( $ number ) { if ( null !== $ this -> precision && null !== $ this -> roundingMode ) { $ roundingCoef = pow ( 10 , $ this -> precision ) ; $ number *= $ roundingCoef ; switch ( $ this -> roundingMode ) { case \ NumberFormatter :: ROUND_CEILING : $ number = ceil ( $ number ) ; break ; case \ NumberFormatter :: ROUND_FLOOR : $ number = floor ( $ number ) ; break ; case \ NumberFormatter :: ROUND_UP : $ number = $ number > 0 ? ceil ( $ number ) : floor ( $ number ) ; break ; case \ NumberFormatter :: ROUND_DOWN : $ number = $ number > 0 ? floor ( $ number ) : ceil ( $ number ) ; break ; case \ NumberFormatter :: ROUND_HALFEVEN : $ number = round ( $ number , 0 , PHP_ROUND_HALF_EVEN ) ; break ; case \ NumberFormatter :: ROUND_HALFUP : $ number = round ( $ number , 0 , PHP_ROUND_HALF_UP ) ; break ; case \ NumberFormatter :: ROUND_HALFDOWN : $ number = round ( $ number , 0 , PHP_ROUND_HALF_DOWN ) ; break ; } $ number /= $ roundingCoef ; } return $ number ; } | Rounds a number according to the configured precision and rounding mode . |
26,143 | public function cookie ( $ domain ) { $ this -> bag -> set ( CURLOPT_COOKIEJAR , $ this -> getPath ( $ domain , 'cookie' ) ) ; $ this -> bag -> set ( CURLOPT_COOKIEFILE , $ this -> getPath ( $ domain , 'cookie' ) ) ; return $ this ; } | Enable saving and reading cookies |
26,144 | public function deleteContent ( ) { $ files = glob ( $ this -> folderPath . '*' ) ; foreach ( $ files as $ file ) { if ( is_file ( $ file ) ) { unlink ( $ file ) ; } } } | Supprime le contenu du dossier |
26,145 | public static function findCommonPath ( $ directories ) { while ( count ( $ directories ) !== 1 ) { usort ( $ directories , function ( $ a , $ b ) { return strlen ( $ b ) - strlen ( $ a ) ; } ) ; $ directories [ 0 ] = dirname ( $ directories [ 0 ] ) ; $ directories = array_unique ( $ directories ) ; } return reset ( $ directories ) ; } | Retourne la partie commune des chemins de plusieurs dossiers |
26,146 | public function register ( $ additionalParameters = null ) { if ( $ additionalParameters && ! is_object ( $ additionalParameters ) ) { throw new \ Exception ( 'additionalParameters must be an object' ) ; } if ( isset ( $ this -> settings -> disabled ) && $ this -> settings -> disabled ) { return false ; } $ internalAdapter = \ Phramework \ Database \ Database :: getAdapter ( ) ; if ( ! $ internalAdapter ) { throw new \ Exception ( 'Global database adapter is not initialized' ) ; } $ queryLogAdapter = new QueryLogAdapter ( $ this -> settings , $ internalAdapter , $ additionalParameters ) ; \ Phramework \ Database \ Database :: setAdapter ( $ queryLogAdapter ) ; return true ; } | Activate query - log |
26,147 | public function isHome ( ) : bool { return $ this -> url -> current ( ) == $ this -> url -> to ( $ this -> config -> get ( 'helpers.paths.home' ) ) ; } | Return true if current page is home . |
26,148 | public function isAdmin ( ) : bool { return str_contains ( $ this -> url -> current ( ) , $ this -> request -> root ( ) . '/' . $ this -> config -> get ( 'helpers.paths.admin' ) ) ; } | Return true if current page is an admin page . |
26,149 | public function sectionExists ( string $ section ) : bool { return ( bool ) trim ( $ this -> view -> yieldContent ( $ section ) ) ; } | Check if a view section exists . |
26,150 | public function injectionByClosure ( $ closure , $ method , $ inherentParams = [ ] ) { if ( ! ( $ closure instanceof \ Closure ) ) { throw new \ InvalidArgumentException ( 'Method 0 must be a Closure.' ) ; } $ instances = $ this -> dependentService -> getParams ( $ this -> reflection , $ method , count ( $ inherentParams ) ) ; $ params = array_merge ( $ instances , $ inherentParams ) ; return call_user_func_array ( $ closure , $ params ) ; } | Injection a Closure |
26,151 | public function getGitDirectory ( InputInterface $ input , OutputInterface $ output , $ optionDir = null ) { $ dir = $ optionDir ; if ( ! $ dir ) { $ dir = $ this -> getVcsDirectory ( ) ; } if ( ! $ dir ) { $ dir = $ this -> getCommandDir ( ) ; } $ validator = $ this -> getValidator ( ) ; try { return $ validator ( $ dir ) ; } catch ( \ Exception $ e ) { } return $ this -> askProjectDir ( $ input , $ output , $ dir ) ; } | Get GIT directory |
26,152 | public function askProjectDir ( InputInterface $ input , OutputInterface $ output , $ dir = null , SymfonyStyle $ style = null ) { $ question = $ this -> getSimpleQuestion ( ) -> getQuestion ( 'Please set your root project directory.' , $ dir ) ; $ question -> setValidator ( $ this -> getValidator ( ) ) ; $ style = $ style ? : new SymfonyStyle ( $ input , $ output ) ; $ dir = $ style -> askQuestion ( $ question ) ; return rtrim ( $ dir , '\\/' ) ; } | Ask about GIT project root dir |
26,153 | protected function getValidator ( ) { $ helper = $ this ; return function ( $ dir ) use ( $ helper ) { $ dir = rtrim ( $ dir , '\\/' ) ; if ( ! is_dir ( $ helper -> getDotGitDirectory ( $ dir ) ) ) { throw new LogicException ( 'No information about git directory.' ) ; } return $ dir ; } ; } | Get GIT root directory validator |
26,154 | protected function getSimpleQuestion ( ) { if ( ! $ this -> getHelperSet ( ) -> has ( 'simple_question' ) ) { $ this -> getHelperSet ( ) -> set ( new SimpleQuestionHelper ( ) ) ; } return $ this -> getHelperSet ( ) -> get ( 'simple_question' ) ; } | Get question helper |
26,155 | public function getRawProperty ( $ rawName ) { if ( isset ( $ this -> properties [ $ rawName ] ) ) { return ( object ) $ this -> properties [ $ rawName ] ; } return null ; } | Get raw property |
26,156 | public function setRawProperty ( $ rawName , $ value , $ priority = self :: PRIORITY_NORMAL ) { if ( is_array ( $ value ) ) { $ value = ( object ) $ value ; } if ( is_object ( $ value ) ) { if ( isset ( $ value -> priority ) ) { $ priority = $ value -> priority ; } if ( isset ( $ value -> value ) ) { $ value = $ value -> value ; } else { $ value = null ; } } $ rawName = ( string ) $ rawName ; $ value = ( string ) $ value ; $ priority = ( ( string ) $ priority ) ? : self :: PRIORITY_NORMAL ; if ( '' === $ value ) { return $ this -> removeRawProperty ( $ rawName ) ; } $ this -> properties [ $ rawName ] = array ( 'name' => $ rawName , 'value' => $ value , 'priority' => $ priority , ) ; return $ this ; } | Set raw property |
26,157 | public function getRawPropertyValue ( $ rawName ) { if ( isset ( $ this -> properties [ $ rawName ] [ 'value' ] ) ) { return $ this -> properties [ $ rawName ] [ 'value' ] ; } return null ; } | Get raw property value |
26,158 | public function getRawPropertyPriority ( $ rawName ) { if ( isset ( $ this -> properties [ $ rawName ] [ 'priority' ] ) ) { return $ this -> properties [ $ rawName ] [ 'priority' ] ; } return null ; } | Get raw property priority |
26,159 | public function setRawProperties ( $ properties ) { if ( ! empty ( $ properties ) ) { foreach ( $ properties as $ name => $ value ) { switch ( true ) { case is_array ( $ value ) && array_key_exists ( 'value' , $ value ) : $ value = ( object ) $ value ; case is_object ( $ value ) : if ( ! isset ( $ value -> value ) ) { $ value -> value = null ; } if ( ! isset ( $ value -> priority ) ) { $ value -> priority = null ; } if ( ! isset ( $ value -> name ) ) { $ value -> name = $ name ; } $ this -> setRawProperty ( $ value -> name , $ value -> value , $ value -> priority ) ; break ; case is_array ( $ value ) : if ( count ( $ value ) > 2 ) { list ( $ rawName , $ value , $ priority ) = $ value ; if ( empty ( $ rawName ) ) { $ rawName = $ name ; } } else if ( count ( $ value ) > 1 ) { $ rawName = $ name ; list ( $ value , $ priority ) = $ value ; } else { $ rawName = $ name ; $ priority = null ; $ value = empty ( $ value ) ? null : current ( $ value ) ; } $ this -> setRawProperty ( $ rawName , $ value , $ priority ) ; break ; default : $ this -> setRawProperty ( $ name , $ value ) ; break ; } } } return $ this ; } | Set raw properties |
26,160 | protected function setBackgroundPositionXProperty ( $ value , $ priority = self :: PRIORITY_NORMAL ) { $ x = ( string ) $ value ; $ y = ( string ) $ this -> getRawPropertyValue ( 'background-position-y' ) ; if ( '' !== $ x && '' !== $ y ) { $ this -> setRawProperty ( 'background-position' , $ x . ' ' . $ y , $ priority ? : $ this -> getRawPropertyPriority ( 'background-position-y' ) ) ; } return $ this -> setRawProperty ( 'background-position-x' , $ x , $ priority ) ; } | Set background - position - x |
26,161 | protected function setBackgroundPositionProperty ( $ value , $ priority = self :: PRIORITY_NORMAL ) { $ parts = preg_split ( '/\s+/' , trim ( $ value ) , 2 ) ; $ this -> setRawProperty ( 'background-position' , $ value , $ priority ) ; if ( count ( $ parts ) < 2 ) { return $ this ; } list ( $ x , $ y ) = $ parts ; return $ this -> setRawProperty ( 'background-position-x' , $ x , $ priority ) -> setRawProperty ( 'background-position-y' , $ y , $ priority ) ; } | Set background - position |
26,162 | public function getPropertyNames ( ) { $ result = array ( ) ; foreach ( $ this -> getRawPropertyNames ( ) as $ rawName ) { $ result [ ] = String :: camelize ( $ rawName ) ; } return $ result ; } | Get property names |
26,163 | public static function call ( $ callback , array $ args = null ) { $ callback = Helper :: toNative ( $ callback ) ; if ( $ callback [ 'bind' ] ) { $ native = $ callback [ 'native' ] ; $ first = $ native [ 0 ] ; if ( is_object ( $ first ) ) { $ callback = Helper :: bindInstance ( $ first , $ native [ 1 ] , $ callback [ 'args' ] ) ; } elseif ( is_string ( $ first ) ) { $ callback = Helper :: bindStatic ( $ first , $ native [ 1 ] , $ callback [ 'args' ] ) ; } else { throw new InvalidFormat ( 'Invalid callback for bind context' ) ; } } else { $ args = array_merge ( $ callback [ 'args' ] , $ args ? : [ ] ) ; $ callback = $ callback [ 'native' ] ; if ( ! is_callable ( $ callback , false ) ) { throw new NotCallable ( ) ; } } return call_user_func_array ( $ callback , $ args ? : [ ] ) ; } | Executes a callback |
26,164 | public static function createNative ( $ callback , $ forceObj = false ) { $ callback = Helper :: toNative ( $ callback ) ; if ( empty ( $ callback [ 'args' ] ) && ( ! $ forceObj ) ) { return $ callback [ 'native' ] ; } return new self ( $ callback [ 'native' ] , $ callback [ 'args' ] ) ; } | Creates a native callback |
26,165 | public function isCallable ( ) { if ( $ this -> isCallable === null ) { $ this -> isCallable = is_callable ( $ this -> native , false ) ; } return $ this -> isCallable ; } | Checks if the callback is callable |
26,166 | public function autoload ( $ className ) { $ className = ltrim ( $ className , '\\' ) ; $ fileName = '' ; $ namespace = '' ; if ( $ lastNsPos = strrpos ( $ className , '\\' ) ) { $ namespace = substr ( $ className , 0 , $ lastNsPos ) ; $ className = substr ( $ className , $ lastNsPos + 1 ) ; $ fileName = str_replace ( '\\' , DIRECTORY_SEPARATOR , dirname ( __FILE__ ) . DIRECTORY_SEPARATOR . $ namespace ) . DIRECTORY_SEPARATOR ; } $ fileName .= str_replace ( '_' , DIRECTORY_SEPARATOR , $ className ) . '.php' ; if ( file_exists ( $ fileName ) ) require $ fileName ; } | Sophwork system autoloader |
26,167 | public function thirdPartyAutoload ( $ className ) { $ className = ltrim ( $ className , '\\' ) ; $ fileName = '' ; $ namespace = '' ; if ( $ lastNsPos = strrpos ( $ className , '\\' ) ) { $ namespace = substr ( $ className , 0 , $ lastNsPos ) ; $ className = substr ( $ className , $ lastNsPos + 1 ) ; $ fileName = str_replace ( '\\' , DIRECTORY_SEPARATOR , $ this -> sources . DIRECTORY_SEPARATOR . $ namespace ) . DIRECTORY_SEPARATOR ; } $ fileName .= str_replace ( '_' , DIRECTORY_SEPARATOR , $ className ) . '.php' ; if ( file_exists ( $ fileName ) ) require $ fileName ; } | Third party autoloader |
26,168 | private function createIvSizeAndIvString ( ) { $ ivSize = mcrypt_get_iv_size ( $ this -> algorithm , $ this -> mode ) ; return mcrypt_create_iv ( $ ivSize , $ this -> rand ) ; } | create your special iv value |
26,169 | protected function startConfigPlugin ( $ app ) { $ this -> getVariables [ 'config' ] = function ( ) { return $ this -> app -> make ( 'config' ) ; } ; $ this -> requiresPlugins ( Resources :: class , Paths :: class ) ; $ this -> onRegister ( 'config' , function ( $ app ) { $ this -> registerConfigFiles ( ) ; } ) ; $ this -> onBoot ( 'config' , function ( $ app ) { $ this -> bootConfigFiles ( ) ; } ) ; } | bootConfigPlugin method . |
26,170 | private function getIterator ( $ value ) { if ( $ value instanceof \ Iterator ) { return $ value ; } if ( is_array ( $ value ) ) { return new \ ArrayIterator ( $ value ) ; } return new \ ArrayIterator ( [ $ value ] ) ; } | Returns an iterator for the given value . |
26,171 | public function run ( ) { $ this -> addPending ( ) ; $ this -> ran = true ; while ( count ( $ this -> inProcess ) !== 0 ) { $ this -> monitorPending ( ) ; } $ this -> onSuccess = null ; $ this -> onError = null ; } | Executes the processes . |
26,172 | private function addPending ( ) { while ( count ( $ this -> inProcess ) < $ this -> concurrency ) { $ item = $ this -> getUnprocessed ( ) ; if ( empty ( $ item ) ) { break ; } $ this -> inProcess [ $ item [ 'index' ] ] = $ item [ 'process' ] ; $ item [ 'process' ] -> start ( ) ; if ( count ( $ this -> inProcess ) >= $ this -> concurrency ) { break ; } } } | Adds the pending |
26,173 | private function monitorPending ( ) { foreach ( $ this -> inProcess as $ index => $ process ) { if ( $ process -> isTerminated ( ) ) { if ( $ process -> isSuccessful ( ) ) { call_user_func ( $ this -> onSuccess , $ process -> getOutput ( ) , $ index ) ; } else { call_user_func ( $ this -> onError , $ process -> getErrorOutput ( ) , $ index ) ; } unset ( $ this -> inProcess [ $ index ] ) ; $ this -> addPending ( ) ; } } } | Monitors the pending process . |
26,174 | private function blockNameTrans ( $ name , $ block , & $ opts ) { $ this -> debug -> groupCollapsed ( __CLASS__ . '->' . __FUNCTION__ ) ; $ func = $ opts [ 'name_trans_func' ] [ 0 ] ; $ params = array_slice ( $ opts [ 'name_trans_func' ] , 1 ) ; $ strObj = new Str ( ) ; if ( ! isset ( $ opts [ 'trans_func_params_sub' ] ) ) { $ opts [ 'trans_func_params_sub' ] = array ( ) ; foreach ( $ params as $ k => $ v ) { $ params [ $ k ] = $ strObj -> quickTemp ( $ v , $ block ) ; if ( $ params [ $ k ] != $ v ) { $ opts [ 'trans_func_params_sub' ] [ ] = $ k ; } } } else { foreach ( $ opts [ 'trans_func_params_sub' ] as $ k ) { $ params [ $ k ] = $ strObj -> quickTemp ( $ params [ $ k ] , $ block ) ; } } $ name_new = call_user_func_array ( $ func , $ params ) ; $ this -> debug -> groupEnd ( ) ; return $ name_new ; } | attempt to transform the block name |
26,175 | private function fillText ( $ page , $ block , $ value , $ fillOpts = array ( ) ) { $ this -> debug -> groupCollapsed ( __CLASS__ . '->' . __FUNCTION__ , $ block [ 'Name' ] , $ value ) ; $ p = $ this -> p ; $ opts [ 'fillcolor' ] = $ fillOpts [ 'fillcolor' ] ; if ( ! empty ( $ block [ 'Custom' ] [ 'PDFlib:field:type' ] ) && in_array ( $ block [ 'Custom' ] [ 'PDFlib:field:type' ] , array ( 'checkbox' , 'radiobutton' ) ) ) { $ field_type = $ block [ 'Custom' ] [ 'PDFlib:field:type' ] ; $ value_block = $ block [ 'Custom' ] [ 'PDFlib:field:value' ] ; if ( $ field_type == 'checkbox' ) { $ opts = array_merge ( $ opts , $ fillOpts [ 'checkbox_opts' ] ) ; if ( $ value == $ value_block || is_array ( $ value ) && in_array ( $ value_block , $ value ) ) { $ value = $ fillOpts [ 'checkbox_value' ] ; } } else { $ opts = array_merge ( $ opts , $ fillOpts [ 'radio_opts' ] ) ; if ( $ value == $ value_block ) { $ value = $ fillOpts [ 'radio_value' ] ; } } if ( ! $ value ) { $ opts [ 'textformat' ] = null ; $ value = ' ' ; } } else { $ opts = array_merge ( $ opts , $ fillOpts [ 'text_opts' ] ) ; } $ this -> debug -> log ( $ block [ 'Name' ] , $ value , $ this -> stringifyOpts ( $ opts ) ) ; $ ret = $ p -> fill_textblock ( $ page , $ block [ 'Name' ] , $ value , $ this -> stringifyOpts ( $ opts ) ) ; if ( $ ret == 0 ) { $ opts [ 'fontname' ] = 'Courier' ; $ ret = $ p -> fill_textblock ( $ page , $ block [ 'Name' ] , $ value , $ this -> stringifyOpts ( $ opts ) ) ; } $ this -> debug -> groupEnd ( ) ; } | fill text block |
26,176 | public function getBlocks ( $ pdiNo , $ opts = array ( ) ) { $ this -> debug -> groupCollapsed ( __CLASS__ . '->' . __FUNCTION__ ) ; $ p = $ this -> p ; $ arrayUtil = new ArrayUtil ( ) ; $ opts = array_merge ( array ( 'page' => null , 'props' => array ( ) , ) , $ opts ) ; $ blocks = array ( ) ; try { if ( $ opts [ 'page' ] === null ) { $ this -> debug -> log ( 'get blocks for all pages' ) ; $ page_count = $ p -> pcos_get_number ( $ pdiNo , '/Root/Pages/Count' ) ; $ page_start = 0 ; $ page_end = $ page_count - 1 ; } else { $ page_start = $ opts [ 'page' ] ; $ page_end = $ opts [ 'page' ] ; } if ( ! empty ( $ opts [ 'props' ] ) && ! in_array ( 'ID' , $ opts [ 'props' ] ) ) { $ opts [ 'props' ] [ ] = 'ID' ; } for ( $ pageNo = $ page_start ; $ pageNo <= $ page_end ; $ pageNo ++ ) { $ this -> debug -> log ( 'pageNo' , $ pageNo ) ; $ block_count = $ p -> pcos_get_number ( $ pdiNo , 'length:pages[' . $ pageNo . ']/blocks' ) ; for ( $ i = 0 ; $ i < $ block_count ; $ i ++ ) { $ path = 'pages[' . $ pageNo . ']/blocks[' . $ i . ']' ; $ block = $ this -> getProperties ( $ pdiNo , $ path , $ opts ) ; $ block [ 'page' ] = $ pageNo ; $ blocks [ $ block [ 'Name' ] ] = $ block ; } } } catch ( PDFlibException $ e ) { $ this -> debug -> warn ( 'exception: ' . $ e -> faultcode . ', faultstring: ' . $ e -> faultstring ) ; } $ blocks = $ arrayUtil -> fieldSort ( $ blocks , array ( 'page' , 'ID' ) ) ; $ this -> debug -> log ( 'blocks' , $ blocks ) ; $ this -> debug -> groupEnd ( ) ; return $ blocks ; } | Get PDF blocks |
26,177 | public function getPDFlib ( $ opts = array ( ) ) { $ this -> debug -> groupCollapsed ( __CLASS__ . '->' . __FUNCTION__ ) ; debug ( 'opts' , $ opts ) ; $ optsDefault = array ( 'errorpolicy' => 'return' , 'license' => null , 'textformat' => 'utf8' , 'SearchPath' => $ _SERVER [ 'DOCUMENT_ROOT' ] , ) ; $ opts = array_merge ( $ optsDefault , $ opts ) ; if ( empty ( $ opts [ 'license' ] ) ) { if ( isset ( $ this -> cfg [ 'license' ] ) ) { $ opts [ 'license' ] = $ this -> cfg [ 'license' ] ; } elseif ( file_exists ( $ this -> cfg [ 'licensefile' ] ) ) { $ this -> debug -> info ( 'licensefile found' , $ this -> cfg [ 'licensefile' ] ) ; $ opts [ 'license' ] = trim ( file_get_contents ( $ this -> cfg [ 'licensefile' ] ) ) ; } } $ p = new \ PDFlib ( ) ; $ this -> p = $ p ; $ pdflibVer = $ p -> get_parameter ( 'version' , 0 ) ; $ this -> debug -> info ( 'pdflib version' , $ pdflibVer ) ; $ this -> debug -> log ( 'opts' , $ opts ) ; try { if ( version_compare ( $ pdflibVer , '9.0.0' , '>=' ) ) { $ opt_string = $ this -> stringifyOpts ( $ opts ) ; $ response = $ p -> set_option ( $ opt_string ) ; } else { foreach ( $ opts as $ k => $ v ) { $ response = $ p -> set_parameter ( $ k , $ v ) ; } } } catch ( PDFlibException $ e ) { trigger_error ( 'PDFlib exception [' . $ e -> get_errnum ( ) . '] ' . $ e -> get_apiname ( ) . ' : ' . $ e -> get_errmsg ( ) ) ; } $ this -> debug -> groupEnd ( ) ; return $ p ; } | Create & return PDFlib instance |
26,178 | public function openPdf ( $ pdfTemplate ) { $ this -> debug -> groupCollapsed ( __CLASS__ . '->' . __FUNCTION__ ) ; $ p = $ this -> p ; $ pdiOpts = 'errorpolicy=return' ; if ( is_object ( $ pdfTemplate ) || preg_match ( '/[\\x00-\\x1f]/' , $ pdfTemplate ) ) { if ( is_object ( $ pdfTemplate ) ) { $ this -> debug -> log ( 'pdfTemplate is object' ) ; $ p -> create_pvf ( $ this -> pvf , $ pdfTemplate -> get_buffer ( ) , '' ) ; $ pdfTemplate -> delete ( ) ; } else { $ this -> debug -> log ( 'pdfTemplate is raw pdf data' ) ; $ p -> create_pvf ( $ this -> pvf , $ pdfTemplate , '' ) ; } $ pdfTemplate = null ; $ pdiNo = $ p -> open_pdi_document ( $ this -> pvf , $ pdiOpts ) ; } else { $ this -> debug -> log ( 'pdfTemplate' , $ pdfTemplate ) ; $ this -> debug -> log ( 'file_exists' , file_exists ( $ pdfTemplate ) ) ; try { $ pdiNo = $ p -> open_pdi_document ( $ pdfTemplate , $ pdiOpts ) ; } catch ( PDFlibException $ e ) { trigger_error ( 'PDFlib exception [' . $ e -> get_errnum ( ) . '] ' . $ e -> get_apiname ( ) . ' : ' . $ e -> get_errmsg ( ) ) ; } $ this -> debug -> info ( 'get_errmsg' , $ p -> get_errmsg ( ) ) ; } $ this -> debug -> groupEnd ( ) ; return $ pdiNo ; } | Get PDI document |
26,179 | public function stringifyOpts ( $ opts ) { $ pairs = array ( ) ; foreach ( $ opts as $ k => $ v ) { if ( is_null ( $ v ) ) { continue ; } if ( $ v === true ) { $ pairs [ ] = $ k ; } elseif ( $ v === false ) { $ pairs [ ] = $ k . '=false' ; } else { $ pairs [ ] = $ k . '=' . $ v ; } } return implode ( ' ' , $ pairs ) ; } | Create option string as used by pdflib |
26,180 | public function setViewItem ( string $ name , $ value ) : void { $ this -> viewItems -> set ( $ name , $ value ) ; } | Sets a view item . |
26,181 | protected function getViewPath ( ) : string { $ result = ( new \ ReflectionClass ( $ this ) ) -> getShortName ( ) ; if ( strlen ( $ result ) > 10 && substr ( strtolower ( $ result ) , - 10 ) === 'controller' ) { $ result = substr ( $ result , 0 , - 10 ) ; } return $ result ; } | Returns the path to the view files . |
26,182 | private static function getActionName ( string $ action ) : string { if ( $ action === '' ) { return 'index' ; } if ( in_array ( strtolower ( $ action ) , self :: $ magicActionMethods ) ) { return '_' . $ action ; } return $ action ; } | Returns the action name for a specific action . |
26,183 | public static function zero ( int $ dimension = 0 ) : Vector { if ( $ dimension === 0 ) { return new static ( [ ] ) ; } if ( $ dimension < 0 ) { throw new \ InvalidArgumentException ( 'Expected dimension to be at least 0, got [' . $ dimension . '] instead.' ) ; } return new static ( array_fill ( 0 , $ dimension , 0 ) ) ; } | Creates a zero - length vector of the given dimension . |
26,184 | public function abs ( ) : Vector { $ result = [ ] ; foreach ( $ this -> components as $ i => $ component ) { $ result [ $ i ] = abs ( $ component ) ; } return new static ( $ result ) ; } | Returns the absolute value of this Vector as a new Vector instance . |
26,185 | public function distance ( Vector $ that , int $ type = null ) : float { if ( null === $ type ) { $ type = static :: $ defaultDistanceType ; } switch ( $ type ) { case self :: DISTANCE_CARTESIAN : return $ this -> cartesianDistanceTo ( $ that ) ; case self :: DISTANCE_CHEBYSHEV : case self :: DISTANCE_CHESSBOARD : return $ this -> chebyshevDistanceTo ( $ that ) ; case self :: DISTANCE_TAXICAB : case self :: DISTANCE_MANHATTAN : return $ this -> taxicabDistanceTo ( $ that ) ; } throw new \ InvalidArgumentException ( 'Unsupported distance type [' . $ type . '] given.' ) ; } | Returns the distance of this Vector to the given Vector . |
26,186 | public function cartesianDistanceTo ( Vector $ that ) : float { if ( ! $ this -> isSameDimension ( $ that ) ) { throw new \ DomainException ( 'The given input Vector is not in the same dimension as this Vector.' ) ; } $ result = 0 ; foreach ( $ this -> components as $ i => $ component ) { $ result += pow ( $ component - $ that -> components [ $ i ] , 2 ) ; } return sqrt ( $ result ) ; } | Returns the cartesian distance of this Vector to the given Vector . |
26,187 | public function divide ( float $ scale ) : Vector { if ( $ scale == 0 ) { throw new exceptions \ DivisionByZero ; } return $ this -> multiply ( 1.0 / $ scale ) ; } | Divides the Vector by the given scale and returns the result as a new Vector . |
26,188 | public function length ( ) : float { static $ result ; return null !== $ result ? $ result : $ result = sqrt ( $ this -> lengthSquared ( ) ) ; } | Returns the length of the Vector . |
26,189 | public function lengthSquared ( ) : float { static $ result ; if ( $ result !== null ) { return $ result ; } $ sum = 0 ; foreach ( $ this -> components as $ component ) { $ sum += $ component * $ component ; } return $ result = $ sum ; } | Returns the square of the Vector s length . |
26,190 | public function multiply ( float $ scale ) : Vector { $ result = [ ] ; foreach ( $ this -> components as $ i => $ component ) { $ result [ $ i ] = $ component * $ scale ; } return new static ( $ result ) ; } | Multiplies the Vector by the given scale and returns the result as a new Vector . |
26,191 | public function projectOnto ( Vector $ that ) : Vector { $ that = $ that -> normalize ( ) ; return $ that -> multiply ( $ this -> dotProduct ( $ that ) ) ; } | Projects this Vector onto another Vector . |
26,192 | public function reverse ( ) { $ result = [ ] ; foreach ( $ this -> components as $ i => $ component ) { $ result [ $ i ] = $ component * - 1 ; } return new static ( $ result ) ; } | Reverses the direction of this Vector . |
26,193 | public function bind ( string $ event , callable $ callback ) { if ( ! is_callable ( $ callback ) ) { return false ; } if ( ! isset ( $ this -> bindings [ $ event ] ) || ! is_array ( $ this -> bindings [ $ event ] ) ) { $ this -> bindings [ $ event ] = [ ] ; } $ signature = $ this -> hash ( $ callback ) ; if ( array_key_exists ( $ signature , $ this -> bindings [ $ event ] ) ) { return $ signature ; } $ this -> bindings [ $ event ] [ $ signature ] = $ callback ; return $ signature ; } | Register an event binding |
26,194 | protected function getBindings ( string $ event ) { if ( ! isset ( $ this -> bindings [ $ event ] ) || ! is_array ( $ this -> bindings [ $ event ] ) ) { return [ ] ; } return $ this -> bindings [ $ event ] ; } | Get all bindings for an event |
26,195 | public function unbind ( string $ event , string $ signature ) { if ( ! isset ( $ this -> bindings [ $ event ] ) || ! is_array ( $ this -> bindings [ $ event ] ) || ! array_key_exists ( $ signature , $ this -> bindings [ $ event ] ) ) { return false ; } unset ( $ this -> bindings [ $ event ] [ $ signature ] ) ; return true ; } | Remove an event binding |
26,196 | protected function reflect ( $ reflect , array $ arguments ) { $ pass = [ ] ; foreach ( $ reflect -> getParameters ( ) as $ param ) { if ( isset ( $ arguments [ $ param -> getName ( ) ] ) ) { $ pass [ ] = $ arguments [ $ param -> getName ( ) ] ; } else { $ pass [ ] = $ param -> getDefaultValue ( ) ; } } return $ pass ; } | Reflect on the object or function and format an ordered arguement list |
26,197 | public function enableTicks ( int $ tickFreq = null ) { if ( is_null ( $ tickFreq ) ) { $ tickFreq = self :: $ tickFreq ; } self :: $ tickFreq = $ tickFreq ; self :: $ lastTick = microtime ( true ) ; if ( self :: $ ticking ) { return true ; } register_tick_function ( [ '\Kaecyra\AppCommon\Event' , 'tick' ] ) ; } | Enable periodic tick event |
26,198 | public function get ( $ className , $ ctorArgs = [ ] , $ useCache = true ) { if ( ! $ useCache ) { return $ this -> instantiate ( $ className , $ ctorArgs ) ; } if ( ! array_key_exists ( $ className , $ this -> instances ) ) { $ instance = $ this -> instantiate ( $ className , $ ctorArgs ) ; $ this -> instances [ $ className ] = $ instance ; } return $ this -> instances [ $ className ] ; } | Get the generated class instance for the given lonely class . |
26,199 | protected function createPDO ( $ dsn , $ username , $ password , array $ options ) { return new PDO ( $ dsn , $ username , $ password , $ options ) ; } | Create a new PDO instance . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.