idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
226,100
protected static function compilePatternAsRegex ( $ pattern , $ rules = [ ] , $ extract_params = true ) { return '#^' . preg_replace_callback ( '#:([a-zA-Z]\w*)#' , $ extract_params ? function ( $ g ) use ( & $ rules ) { return '(?<' . $ g [ 1 ] . '>' . ( isset ( $ rules [ $ g [ 1 ] ] ) ? $ rules [ $ g [ 1 ] ] : '[^/]+...
Compile an URL schema to a PREG regular expression .
226,101
protected static function extractVariablesFromURL ( $ pattern , $ URL = null , $ cut = false ) { $ URL = $ URL ? : Request :: URI ( ) ; $ pattern = $ cut ? str_replace ( '$#' , '' , $ pattern ) . '#' : $ pattern ; $ args = [ ] ; if ( ! preg_match ( $ pattern , '/' . trim ( $ URL , '/' ) , $ args ) ) return false ; fore...
Extract the URL schema variables from the passed URL .
226,102
public static function add ( $ route ) { if ( is_a ( $ route , 'Route' ) ) { if ( $ route -> tag ) static :: $ tags [ $ route -> tag ] = & $ route ; if ( Options :: get ( 'core.route.auto_optimize' , true ) ) { $ base = & static :: $ optimized_tree ; foreach ( explode ( '/' , trim ( preg_replace ( '#^(.+?)\(?:.+$#' , '...
Add a route to the internal route repository .
226,103
public static function group ( $ prefix , $ callback ) { $ pre_prefix = rtrim ( implode ( '' , static :: $ prefix ) , '/' ) ; $ URI = Request :: URI ( ) ; $ args = [ ] ; $ group = false ; switch ( true ) { case static :: isDynamic ( $ prefix ) : $ args = static :: extractVariablesFromURL ( $ prx = static :: compilePatt...
Define a route group if not immediately matched internal code will not be invoked .
226,104
public static function dispatch ( $ URL = null , $ method = null , $ return_route = false ) { if ( ! $ URL ) $ URL = Request :: URI ( ) ; if ( ! $ method ) $ method = Request :: method ( ) ; $ __deferred_send = new Deferred ( function ( ) { if ( Options :: get ( 'core.response.autosend' , true ) ) { Response :: send ( ...
Start the route dispatcher and resolve the URL request .
226,105
public static function loadINI ( $ filepath , $ prefix_path = null ) { $ results = parse_ini_file ( $ filepath , true ) ; if ( $ results ) { $ results = static :: filterWith ( [ "load.ini" , "load" ] , $ results ) ; static :: loadArray ( $ results , $ prefix_path ) ; } }
Load an INI configuration file
226,106
public static function loadJSON ( $ filepath , $ prefix_path = null ) { $ data = file_get_contents ( $ filepath ) ; $ results = $ data ? json_decode ( $ data , true ) : [ ] ; if ( $ results ) { $ results = static :: filterWith ( [ "load.json" , "load" ] , $ results ) ; static :: loadArray ( $ results , $ prefix_path ) ...
Load a JSON configuration file
226,107
public static function loadArray ( array $ array , $ prefix_path = null ) { $ array = static :: filterWith ( [ "load.array" , "load" ] , $ array ) ; if ( $ prefix_path ) { static :: set ( $ prefix_path , $ array ) ; } else { static :: merge ( $ array ) ; } self :: trigger ( 'loaded' ) ; }
Load an array to the configuration
226,108
public static function loadENV ( $ dir , $ envname = '.env' , $ prefix_path = null ) { $ dir = rtrim ( $ dir , '/' ) ; $ results = [ ] ; foreach ( file ( "$dir/$envname" , FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES ) as $ line ) { $ line = trim ( $ line ) ; if ( $ line [ 0 ] == '#' || strpos ( $ line , '=' ) === fal...
Load an ENV file
226,109
public static function register ( $ name , $ dsn , $ username = null , $ password = null , $ options = [ ] ) { return self :: $ connections [ $ name ] = new SQLConnection ( $ dsn , $ username , $ password , $ options ) ; }
Register a new datasource
226,110
public static function connect ( $ dsn , $ username = null , $ password = null , $ options = [ ] ) { return self :: register ( 'default' , $ dsn , $ username , $ password , $ options ) ; }
Register the default datasource
226,111
public static function defaultTo ( $ name ) { if ( isset ( self :: $ connections [ $ name ] ) ) { self :: $ current = $ name ; return true ; } else return false ; }
Bind the default datasource to another named connection
226,112
public static function using ( $ name ) { if ( empty ( self :: $ connections [ $ name ] ) ) throw new \ Exception ( "[SQL] Unknown connection named '$name'." ) ; return self :: $ connections [ $ name ] ; }
Datasource connection accessor
226,113
public function prepare ( $ query , $ pdo_params = [ ] ) { if ( ! $ this -> connection ( ) ) return false ; return isset ( $ this -> queries [ $ query ] ) ? $ this -> queries [ $ query ] : ( $ this -> queries [ $ query ] = $ this -> connection ( ) -> prepare ( $ query , $ pdo_params ) ) ; }
Prepares a SQL query string
226,114
public static function load ( $ pk ) { $ table = static :: persistenceOptions ( 'table' ) ; $ cb = static :: persistenceLoad ( ) ; $ op = static :: persistenceOptions ( ) ; return ( false == is_callable ( $ cb ) ) ? static :: persistenceLoadDefault ( $ pk , $ table , $ op ) : $ cb ( $ pk , $ table , $ op ) ; }
Load the model from the persistence layer
226,115
private static function persistenceLoadDefault ( $ pk , $ table , $ options ) { if ( $ data = SQL :: single ( "SELECT * FROM $table WHERE {$options['key']}=? LIMIT 1" , [ $ pk ] ) ) { $ obj = new static ; foreach ( ( array ) $ data as $ key => $ value ) { $ obj -> $ key = $ value ; } if ( is_callable ( ( $ c = get_call...
Private Standard Load Method
226,116
public function save ( ) { $ table = static :: persistenceOptions ( 'table' ) ; $ op = static :: persistenceOptions ( ) ; $ cb = static :: persistenceSave ( ) ; $ cb = $ cb ? Closure :: bind ( $ cb , $ this ) : [ $ this , 'persistenceSaveDefault' ] ; return $ cb ( $ table , $ op ) ; }
Save the model to the persistence layer
226,117
private function persistenceSaveDefault ( $ table , $ options ) { if ( is_callable ( ( $ c = get_called_class ( ) ) . "::trigger" ) ) $ c :: trigger ( "save" , $ this , $ table , $ options [ 'key' ] ) ; $ id = SQL :: insertOrUpdate ( $ table , array_filter ( ( array ) $ this , function ( $ var ) { return ! is_null ( $ ...
Private Standard Save Method
226,118
public static function accept ( $ key = 'type' , $ choices = '' ) { if ( null === static :: $ accepts ) static :: $ accepts = [ 'type' => new Negotiation ( isset ( $ _SERVER [ 'HTTP_ACCEPT' ] ) ? $ _SERVER [ 'HTTP_ACCEPT' ] : '' ) , 'language' => new Negotiation ( isset ( $ _SERVER [ 'HTTP_ACCEPT_LANGUAGE' ] ) ? $ _SER...
Handle Content Negotiation requests
226,119
public static function URI ( ) { switch ( true ) { case ! empty ( $ _SERVER [ 'REQUEST_URI' ] ) : $ serv_uri = $ _SERVER [ 'REQUEST_URI' ] ; break ; case ! empty ( $ _SERVER [ 'ORIG_PATH_INFO' ] ) : $ serv_uri = $ _SERVER [ 'ORIG_PATH_INFO' ] ; break ; case ! empty ( $ _SERVER [ 'PATH_INFO' ] ) : $ serv_uri = $ _SERVER...
Returns the current request URI .
226,120
public static function IP ( ) { switch ( true ) { case ! empty ( $ _SERVER [ 'HTTP_X_FORWARDED_FOR' ] ) : $ ip = trim ( substr ( strrchr ( $ _SERVER [ 'HTTP_X_FORWARDED_FOR' ] , ',' ) , 1 ) ? : $ _SERVER [ 'HTTP_X_FORWARDED_FOR' ] ) ; break ; case ! empty ( $ _SERVER [ 'HTTP_X_FORWARDED_HOST' ] ) : $ ip = trim ( substr...
Returns the remote IP
226,121
public static function verify ( $ password , $ hash ) { if ( ! defined ( 'PASSWORD_DEFAULT' ) || substr ( $ hash , 0 , 4 ) == '$5h$' ) { return '$5h$' . hash ( 'sha1' , $ password ) == $ hash ; } else { return password_verify ( $ password , $ hash ) ; } }
Verify if password match a given hash
226,122
protected function gridFS ( BucketInterface $ bucket ) : Bucket { if ( empty ( $ this -> database ) ) { $ this -> database = new Database ( new Manager ( $ this -> options [ 'connection' ] ) , $ this -> options [ 'database' ] ) ; } return $ this -> database -> selectGridFSBucket ( [ 'bucketName' => $ bucket -> getOptio...
Get valid GridFS collection associated with bucket .
226,123
protected static function install_shutdown ( ) { if ( static :: $ inited_shutdown ) return ; set_time_limit ( 0 ) ; if ( function_exists ( 'register_postsend_function' ) ) { register_postsend_function ( function ( ) { Event :: trigger ( 'core.shutdown' ) ; } ) ; } else if ( function_exists ( 'fastcgi_finish_request' ) ...
Single shot defer handeler install
226,124
protected function createCacheItem ( RequestInterface $ request ) { $ key = sha1 ( $ this -> generator -> generate ( $ request ) ) ; return $ this -> pool -> getItem ( $ key ) ; }
Create a cache item for a request .
226,125
protected function getCacheControlDirective ( ResponseInterface $ response , string $ name ) { foreach ( $ response -> getHeader ( 'Cache-Control' ) as $ header ) { if ( preg_match ( sprintf ( '|%s=?([0-9]+)?|i' , $ name ) , $ header , $ matches ) ) { if ( isset ( $ matches [ 1 ] ) ) { return $ matches [ 1 ] ; } return...
Get the value of a parameter in the cache control header .
226,126
protected function createResponseFromCacheItem ( CacheItemInterface $ cacheItem ) { $ data = $ cacheItem -> get ( ) ; $ response = $ data [ 'response' ] ; $ stream = $ this -> streamFactory -> createStream ( $ data [ 'body' ] ) ; try { $ stream -> rewind ( ) ; } catch ( Exception $ e ) { throw new RewindStreamException...
Create a response from a cache item .
226,127
protected function getETag ( CacheItemInterface $ cacheItem ) { $ data = $ cacheItem -> get ( ) ; foreach ( $ data [ 'etag' ] as $ etag ) { if ( ! empty ( $ etag ) ) { return $ etag ; } } }
Get the ETag from the cached response .
226,128
public function merge ( array $ attributes ) { foreach ( $ attributes as $ name => $ value ) { $ this -> set_attribute ( $ name , $ value ) ; } return $ this ; }
Merges the provided attributes with the provided array .
226,129
public function get_changed_table_attributes ( ) { $ changed = array ( ) ; foreach ( $ this -> get_table_attributes ( ) as $ key => $ value ) { if ( $ value !== $ this -> get_original_attribute ( $ key ) ) { $ changed [ $ key ] = $ value ; } } return $ changed ; }
Retrieve an array of the attributes on the model that have changed compared to the model s original data .
226,130
public function get_underlying_wp_object ( ) { if ( isset ( $ this -> attributes [ self :: OBJECT_KEY ] ) ) { return $ this -> attributes [ self :: OBJECT_KEY ] ; } return false ; }
Get the model s underlying post .
226,131
public function get_changed_wp_object_attributes ( ) { $ changed = array ( ) ; foreach ( $ this -> get_wp_object_keys ( ) as $ key ) { if ( $ this -> get_attribute ( $ key ) !== $ this -> get_original_attribute ( $ key ) ) { $ changed [ $ key ] = $ this -> get_attribute ( $ key ) ; } } return $ changed ; }
Get the model attributes on the WordPress object that have changed compared to the model s original attributes .
226,132
public function set_attribute ( $ name , $ value ) { if ( self :: OBJECT_KEY === $ name ) { return $ this -> override_wp_object ( $ value ) ; } if ( self :: TABLE_KEY === $ name ) { return $ this -> override_table ( $ value ) ; } if ( ! $ this -> is_fillable ( $ name ) ) { throw new GuardedPropertyException ; } if ( $ ...
Sets the model attributes .
226,133
public function get_attribute_keys ( ) { if ( isset ( self :: $ memo [ get_called_class ( ) ] [ __METHOD__ ] ) ) { return self :: $ memo [ get_called_class ( ) ] [ __METHOD__ ] ; } return self :: $ memo [ get_called_class ( ) ] [ __METHOD__ ] = array_merge ( $ this -> fillable , $ this -> guarded , $ this -> get_comput...
Retrieves all the attribute keys for the model .
226,134
public function get_table_keys ( ) { if ( isset ( self :: $ memo [ get_called_class ( ) ] [ __METHOD__ ] ) ) { return self :: $ memo [ get_called_class ( ) ] [ __METHOD__ ] ; } $ keys = array ( ) ; foreach ( $ this -> get_attribute_keys ( ) as $ key ) { if ( ! $ this -> has_map_method ( $ key ) && ! $ this -> has_compu...
Retrieves the attribute keys that aren t mapped to a post .
226,135
public function get_wp_object_keys ( ) { if ( isset ( self :: $ memo [ get_called_class ( ) ] [ __METHOD__ ] ) ) { return self :: $ memo [ get_called_class ( ) ] [ __METHOD__ ] ; } $ keys = array ( ) ; foreach ( $ this -> get_attribute_keys ( ) as $ key ) { if ( $ this -> has_map_method ( $ key ) ) { $ keys [ ] = $ key...
Retrieves the attribute keys that are mapped to a post .
226,136
public function get_computed_keys ( ) { if ( isset ( self :: $ memo [ get_called_class ( ) ] [ __METHOD__ ] ) ) { return self :: $ memo [ get_called_class ( ) ] [ __METHOD__ ] ; } $ keys = array ( ) ; foreach ( $ this -> get_attribute_keys ( ) as $ key ) { if ( $ this -> has_compute_method ( $ key ) ) { $ keys [ ] = $ ...
Returns the model s keys that are computed at call time .
226,137
public function serialize ( ) { $ attributes = array ( ) ; if ( $ this -> visible ) { foreach ( $ this -> visible as $ key ) { $ attributes [ $ key ] = $ this -> get_attribute ( $ key ) ; } } elseif ( $ this -> hidden ) { foreach ( $ this -> get_attribute_keys ( ) as $ key ) { if ( ! in_array ( $ key , $ this -> hidden...
Serializes the model s public data into an array .
226,138
public function sync_original ( ) { $ this -> original = $ this -> attributes ; if ( $ this -> attributes [ self :: OBJECT_KEY ] ) { $ this -> original [ self :: OBJECT_KEY ] = clone $ this -> attributes [ self :: OBJECT_KEY ] ; } foreach ( $ this -> original [ self :: TABLE_KEY ] as $ key => $ item ) { if ( is_object ...
Syncs the current attributes to the model s original .
226,139
private function is_fillable ( $ name ) { if ( ! $ this -> is_guarded ) { return true ; } if ( in_array ( $ name , $ this -> fillable ) ) { return true ; } if ( in_array ( $ name , $ this -> guarded ) ) { return false ; } return ! $ this -> fillable ; }
Checks if a given attribute is mass - fillable .
226,140
private function override_wp_object ( $ value ) { if ( is_object ( $ value ) ) { $ this -> attributes [ self :: OBJECT_KEY ] = $ this -> set_wp_object_constants ( $ value ) ; } else { $ this -> attributes [ self :: OBJECT_KEY ] = null ; if ( $ this -> uses_wp_object ( ) ) { $ this -> create_wp_object ( ) ; } } return $...
Overrides the current WordPress object with a provided one .
226,141
private function create_wp_object ( ) { switch ( true ) { case $ this instanceof UsesWordPressPost : $ object = new WP_Post ( ( object ) array ( ) ) ; break ; case $ this instanceof UsesWordPressTerm : $ object = new WP_Term ( ( object ) array ( ) ) ; break ; default : throw new LogicException ; break ; } $ this -> att...
Create and set with a new blank post .
226,142
protected function set_wp_object_constants ( $ object ) { if ( $ this instanceof UsesWordPressPost ) { $ object -> post_type = static :: get_post_type ( ) ; } if ( $ this instanceof UsesWordPressTerm ) { $ object -> taxonomy = static :: get_taxonomy ( ) ; } return $ object ; }
Enforces values on the post that can t change .
226,143
public function get_attribute ( $ name ) { if ( $ method = $ this -> has_map_method ( $ name ) ) { return $ this -> attributes [ self :: OBJECT_KEY ] -> { $ this -> { $ method } ( ) } ; } if ( $ method = $ this -> has_compute_method ( $ name ) ) { return $ this -> { $ method } ( ) ; } if ( isset ( $ this -> attributes ...
Retrieves the model attribute .
226,144
public function get_original_attribute ( $ name ) { $ original_attributes = $ this -> original ; if ( ! is_object ( $ original_attributes [ static :: OBJECT_KEY ] ) ) { unset ( $ original_attributes [ static :: OBJECT_KEY ] ) ; } $ original = new static ( $ original_attributes ) ; return $ original -> get_attribute ( $...
Retrieve the model s original attribute value .
226,145
public function get_primary_id ( ) { if ( $ this instanceof UsesWordPressPost ) { return $ this -> get_underlying_wp_object ( ) -> ID ; } if ( $ this instanceof UsesWordPressTerm ) { return $ this -> get_underlying_wp_object ( ) -> term_id ; } if ( $ this instanceof UsesCustomTable ) { return $ this -> get_attribute ( ...
Fetches the Model s primary ID depending on the model implementation .
226,146
public function clear ( ) { $ keys = array_merge ( $ this -> get_table_keys ( ) , $ this -> get_wp_object_keys ( ) ) ; foreach ( $ keys as $ key ) { try { $ this -> set_attribute ( $ key , null ) ; } catch ( Exception $ e ) { if ( ! ( $ e instanceof GuardedPropertyException ) ) { throw $ e ; } } } return $ this ; }
Clears all the current attributes from the model .
226,147
protected function get_compute_methods ( ) { $ methods = get_class_methods ( get_called_class ( ) ) ; $ methods = array_filter ( $ methods , function ( $ method ) { return strrpos ( $ method , 'compute_' , - strlen ( $ method ) ) !== false ; } ) ; $ methods = array_map ( function ( $ method ) { return substr ( $ method...
Retrieves all the compute methods on the model .
226,148
protected function enqueue_script ( $ script , $ hook = null ) { if ( $ script [ 'condition' ] ( $ hook ) ) { wp_enqueue_script ( $ script [ 'handle' ] , $ this -> url . $ script [ 'src' ] . $ this -> min . '.js' , isset ( $ script [ 'deps' ] ) ? $ script [ 'deps' ] : array ( ) , $ this -> version , isset ( $ script [ ...
Enqueues an individual script if the style s condition is met .
226,149
protected function enqueue_style ( $ style , $ hook = null ) { if ( $ style [ 'condition' ] ( $ hook ) ) { wp_enqueue_style ( $ style [ 'handle' ] , $ this -> url . $ style [ 'src' ] . $ this -> min . '.css' , isset ( $ style [ 'deps' ] ) ? $ style [ 'deps' ] : array ( ) , $ this -> version , isset ( $ style [ 'media' ...
Enqueues an individual stylesheet if the style s condition is met .
226,150
public function get_config_json ( $ filename ) { if ( isset ( $ this -> loaded [ $ filename ] ) ) { return $ this -> loaded [ $ filename ] ; } $ config = $ this -> path . 'config/' . $ filename . '.json' ; if ( ! file_exists ( $ config ) ) { return null ; } $ contents = file_get_contents ( $ config ) ; if ( false === $...
Load a configuration JSON file from the config folder .
226,151
public function authorized ( ) { if ( 'public' === $ this -> options [ 'rule' ] ) { return true ; } if ( 'callback' === $ this -> options [ 'rule' ] && is_callable ( $ this -> options [ 'callback' ] ) ) { return call_user_func ( $ this -> options [ 'callback' ] ) ; } if ( method_exists ( $ this , $ method = $ this -> o...
Validates whether the current user is authorized .
226,152
private function register_constants ( Config $ config ) { $ this -> share ( 'file' , function ( ) use ( $ config ) { return $ config -> file ; } ) ; $ this -> share ( 'url' , function ( ) use ( $ config ) { return $ config -> url ; } ) ; $ this -> share ( 'path' , function ( ) use ( $ config ) { return $ config -> path...
Sets the plugin s url path and basename .
226,153
private function register_core_services ( Config $ config ) { $ this -> share ( array ( 'config' => 'Intraxia\Jaxion\Core\Config' ) , $ config ) ; $ this -> share ( array ( 'loader' => 'Intraxia\Jaxion\Contract\Core\Loader' ) , function ( ) { return new Loader ; } ) ; $ this -> share ( array ( 'i18n' => 'Intaxia\Jaxion...
Registers the built - in services with the Application container .
226,154
protected function new_from_trusted ( array $ elements , $ type = null ) { $ collection = new static ( null !== $ type ? $ type : $ this -> get_type ( ) ) ; $ collection -> set_from_trusted ( $ elements ) ; return $ collection ; }
Creates a new instance of the Collection from a trusted set of elements .
226,155
protected function count_while_true ( $ condition ) { $ count = 0 ; foreach ( $ this -> elements as $ element ) { if ( ! $ condition ( $ element ) ) { break ; } $ count ++ ; } return $ count ; }
Number of elements true for the condition .
226,156
public function rules ( ) { $ args = array ( ) ; foreach ( $ this -> rules as $ arg => $ validation ) { if ( ! $ validation || ! is_string ( $ validation ) ) { continue ; } $ args [ $ arg ] = $ this -> parse_validation ( $ validation ) ; } return $ args ; }
Generates argument rules .
226,157
protected function parse_validation ( $ validation ) { $ validation = explode ( '|' , $ validation ) ; $ rules = array ( ) ; foreach ( $ validation as $ rule ) { if ( 0 === strpos ( $ rule , 'default' ) ) { $ rule_arr = explode ( ':' , $ rule ) ; $ rules [ 'default' ] = count ( $ rule_arr ) === 2 ? array_pop ( $ rule_a...
Parses a validation string into a WP - API compatible rule .
226,158
private function add_callback ( $ previous , $ next ) { return function ( $ value ) use ( $ previous , $ next ) { if ( call_user_func ( $ previous , $ value ) ) { return call_user_func ( $ next , $ value ) ; } return false ; } ; }
Creates a new callback that connects the previous and next callback .
226,159
protected function add ( $ hooks , $ hook , $ service , $ method , $ priority , $ accepted_args ) { $ hooks [ ] = array ( 'hook' => $ hook , 'service' => $ service , 'method' => $ method , 'priority' => $ priority , 'args' => $ accepted_args , ) ; return $ hooks ; }
Utility to register the actions and hooks into a single collection .
226,160
public function register ( ) { if ( ! $ this -> vendor ) { throw new VendorNotSetException ; } if ( ! $ this -> version ) { throw new VersionNotSetException ; } foreach ( $ this -> endpoints as $ endpoint ) { register_rest_route ( $ this -> get_namespace ( ) , $ endpoint -> get_route ( ) , $ endpoint -> get_options ( )...
Registers all of the routes with the WP - API .
226,161
public function group ( array $ options , $ callback ) { $ router = new static ; call_user_func ( $ callback , $ router ) ; foreach ( $ router -> get_endpoints ( ) as $ endpoint ) { $ this -> endpoints [ ] = $ this -> set_options ( $ endpoint , $ options ) ; } }
Registers a set of routes with a shared set of options .
226,162
protected function set_options ( Endpoint $ endpoint , array $ options ) { if ( isset ( $ options [ 'guard' ] ) ) { $ endpoint -> set_guard ( $ options [ 'guard' ] ) ; } if ( isset ( $ options [ 'filter' ] ) ) { $ endpoint -> set_filter ( $ options [ 'filter' ] ) ; } if ( isset ( $ options [ 'prefix' ] ) ) { $ endpoint...
Sets the passed options on the endpoint .
226,163
public function is_model ( ) { if ( ! class_exists ( $ this -> type ) ) { return false ; } $ reflection = new ReflectionClass ( $ this -> type ) ; return $ reflection -> isSubclassOf ( 'Intraxia\Jaxion\Axolotl\Model' ) ; }
Returns whether the type is an Axolotl model .
226,164
public function validate_element ( $ element ) { $ type = gettype ( $ element ) ; $ callable = $ this -> type === 'callable' ; $ is_object = 'object' === $ type ; $ loose_check = $ this -> type === 'object' ; if ( $ callable && ! is_callable ( $ element ) ) { throw new InvalidArgumentException ( 'Item must be callable'...
Validate whether the
226,165
private function determine ( $ type , $ key_type = false ) { if ( ! $ key_type && $ this -> non_scalar_type_exists ( $ type ) ) { return $ type ; } if ( $ scalar_type = $ this -> determine_scalar ( $ type ) ) { if ( $ key_type && ( in_array ( $ scalar_type , array ( 'double' , 'boolean' ) ) ) ) { throw new InvalidArgum...
Determine the type to validate against .
226,166
private function determine_scalar ( $ type ) { $ synonyms = array ( 'int' => 'integer' , 'float' => 'double' , 'bool' => 'boolean' , ) ; if ( array_key_exists ( $ type , $ synonyms ) ) { $ type = $ synonyms [ $ type ] ; } return in_array ( $ type , array ( 'string' , 'integer' , 'double' , 'boolean' ) ) ? $ type : null...
Returns the type if it s scalar otherwise returns null .
226,167
public function get_options ( ) { $ options = array ( 'methods' => $ this -> method , 'callback' => $ this -> callback , ) ; if ( $ this -> guard ) { $ options [ 'permission_callback' ] = array ( $ this -> guard , 'authorized' ) ; } if ( $ this -> filter ) { $ options [ 'args' ] = $ this -> filter -> rules ( ) ; } retu...
Generates the endpoint s WP - API options array .
226,168
public function set_prefix ( $ prefix ) { if ( ! Str :: starts_with ( $ prefix , '/' ) || Str :: ends_with ( $ prefix , '/' ) ) { throw new MalformedRouteException ; } $ this -> prefix = $ prefix ; return $ this ; }
Sets the endpoint s prefix .
226,169
private function configure ( array $ options = [ ] ) : array { $ defaults = [ 'max_restarts' => 10 , ] ; $ config = array_merge ( $ defaults , $ options ) ; if ( count ( $ config ) !== count ( $ defaults ) ) { throw new LogicException ( sprintf ( 'Valid options to the PluginProviders are: %s' , implode ( ', ' , array_v...
Configure the plugin provider .
226,170
protected function getLocalCustomer ( $ stripeCustomerId ) { $ localCustomer = $ this -> getEntityManager ( ) -> getRepository ( 'SHQStripeBundle:StripeLocalCustomer' ) -> findOneByStripeId ( $ stripeCustomerId ) ; if ( null !== $ localCustomer ) { return $ localCustomer ; } return $ this -> getEntityManager ( ) -> get...
Gets the local customer object searching for it in the database or in the newly created entities persisted but not yet flushed .
226,171
public function beforeSpec ( Spec $ spec ) { parent :: beforeSpec ( $ spec ) ; if ( $ this -> lineLength == self :: $ maxPerLine ) { $ this -> console -> writeLn ( '' ) ; $ this -> lineLength = 0 ; } }
Ran before an individual spec .
226,172
public function afterSpec ( Spec $ spec ) { $ this -> lineLength += 1 ; if ( $ spec -> isFailed ( ) ) { $ this -> failures [ ] = $ spec ; $ failure = $ this -> formatter -> red ( 'F' ) ; $ this -> console -> write ( $ failure ) ; } elseif ( $ spec -> isIncomplete ( ) ) { $ this -> incompleteSpecs [ ] = $ spec ; $ incom...
Ran after an individual spec .
226,173
public function getEventTypes ( ) { $ events = [ ] ; if ( isset ( $ this -> response -> eventTypes ) ) { foreach ( $ this -> response -> eventTypes as $ event ) { $ events [ ] = $ event ; } } else { $ events = array_column ( $ this -> response , 'name' ) ; } return $ events ; }
Gets a response variable from the API response
226,174
private function invokeCustomMatcher ( $ name ) { $ class = self :: $ customMatchers [ $ name ] ; $ args = array_slice ( func_get_args ( ) , 1 ) ; $ matcher = call_user_func_array ( [ new \ ReflectionClass ( $ class ) , 'newInstance' ] , $ args ) ; $ this -> test ( $ matcher ) ; return $ this ; }
Calls a custom matcher . The matcher is expected to implement pho \ Expectation \ Matcher \ MatcherInterface . A new instance is created and its match method is called with a variable number of arguments . If match returns false getFailureMessage is passed as the description to an ExpectationException .
226,175
private function writeMigration ( $ name , $ eventObjectTable , $ actionTiming , $ event ) { $ file = pathinfo ( $ this -> creator -> write ( $ name , $ eventObjectTable , $ actionTiming , $ event , $ this -> getMigrationPath ( ) ) , PATHINFO_FILENAME ) ; $ this -> line ( "<info>Created Migration:</info> {$file}" ) ; }
Write to migration file .
226,176
public function metadataTransformer ( ) { if ( is_string ( $ this -> getMetadata ( ) ) ) { $ this -> setMetadata ( json_decode ( $ this -> getMetadata ( ) , true ) ) ; } }
Transforms metadata from string to array .
226,177
public function getEventTypes ( ) { $ this -> endpoint = 'eventtypes' ; $ this -> url = sprintf ( '%s%s' , $ this -> url , $ this -> endpoint ) ; $ response = $ this -> get ( $ this -> url ) ; return new AuthnetWebhooksResponse ( $ response ) ; }
Gets all of the available event types
226,178
public function createWebhooks ( Array $ webhooks , $ webhookUrl , $ status = 'active' ) { $ this -> endpoint = 'webhooks' ; $ this -> url = sprintf ( '%s%s' , $ this -> url , $ this -> endpoint ) ; $ request = [ 'url' => $ webhookUrl , 'eventTypes' => $ webhooks , 'status' => $ status ] ; $ this -> requestJson = json_...
Creates a new webhook
226,179
public function getWebhooks ( ) { $ this -> endpoint = 'webhooks' ; $ this -> url = sprintf ( '%s%s' , $ this -> url , $ this -> endpoint ) ; $ response = $ this -> get ( $ this -> url ) ; return new AuthnetWebhooksResponse ( $ response ) ; }
List all of your webhooks
226,180
public function getWebhook ( $ webhookId ) { $ this -> endpoint = 'webhooks' ; $ this -> url = sprintf ( '%s%s/%s' , $ this -> url , $ this -> endpoint , $ webhookId ) ; $ response = $ this -> get ( $ this -> url ) ; return new AuthnetWebhooksResponse ( $ response ) ; }
Get a webhook
226,181
public function updateWebhook ( $ webhookId , $ webhookUrl , Array $ eventTypes , $ status = 'active' ) { $ this -> endpoint = 'webhooks' ; $ this -> url = sprintf ( '%s%s/%s' , $ this -> url , $ this -> endpoint , $ webhookId ) ; $ request = [ 'url' => $ webhookUrl , 'eventTypes' => $ eventTypes , 'status' => $ status...
Updates webhook event types
226,182
public function deleteWebhook ( $ webhookId ) { $ this -> endpoint = 'webhooks' ; $ this -> url = sprintf ( '%s%s/%s' , $ this -> url , $ this -> endpoint , $ webhookId ) ; $ this -> delete ( $ this -> url ) ; }
Delete a webhook
226,183
public function getNotificationHistory ( $ limit = 1000 , $ offset = 0 ) { $ this -> endpoint = 'notifications' ; $ this -> url = sprintf ( '%s%s' , $ this -> url , $ this -> endpoint ) ; $ response = $ this -> get ( $ this -> url , [ 'offset' => $ offset , 'limit' => $ limit ] ) ; return new AuthnetWebhooksResponse ( ...
Retrieve Notification History
226,184
private function get ( $ url , Array $ params = [ ] ) { $ this -> processor -> get ( $ url , $ params ) ; return $ this -> handleResponse ( ) ; }
Make GET request via Curl
226,185
private function post ( $ url , $ request ) { $ this -> processor -> post ( $ url , $ request ) ; return $ this -> handleResponse ( ) ; }
Make POST request via Curl
226,186
private function put ( $ url , $ request ) { $ this -> processor -> put ( $ url , $ request , true ) ; return $ this -> handleResponse ( ) ; }
Make PUT request via Curl
226,187
public function setValue ( $ value ) { if ( $ this -> acceptsArguments ( ) ) { $ this -> value = $ value ; } else { $ this -> value = ( boolean ) $ value ; } }
Sets the value of the option . If the option accepts arguments the supplied value can be of any type . Otherwise the value is cast as a boolean .
226,188
public function describe ( $ title , \ Closure $ closure ) { $ previous = $ this -> current ; $ suite = new Suite ( $ title , $ closure , $ previous ) ; if ( $ this -> current === $ this -> root ) { $ this -> suites [ ] = $ suite ; } else { $ this -> current -> addSuite ( $ suite ) ; } $ this -> current = $ suite ; $ s...
Constructs a test Suite assigning it the given title and anonymous function . If it s a child of another suite a reference to the parent suite is stored . This is done by tracking the current and previously defined suites .
226,189
public function xdescribe ( $ title , \ Closure $ closure ) { $ previous = $ this -> current ; $ suite = new Suite ( $ title , $ closure , $ previous ) ; $ suite -> setPending ( ) ; if ( $ this -> current === null ) { $ this -> suites [ ] = $ suite ; } else { $ this -> current -> addSuite ( $ suite ) ; } $ this -> curr...
Creates a suite and marks it as pending .
226,190
public function it ( $ title , \ Closure $ closure = null ) { $ spec = new Spec ( $ title , $ closure , $ this -> current ) ; $ this -> current -> addSpec ( $ spec ) ; }
Constructs a new Spec adding it to the list of specs in the current suite .
226,191
public function xit ( $ title , \ Closure $ closure = null ) { $ spec = new Spec ( $ title , $ closure , $ this -> current ) ; $ spec -> setPending ( ) ; $ this -> current -> addSpec ( $ spec ) ; }
Constructs a new Spec adding it to the list of specs in the current suite and mark it as pending .
226,192
public function before ( \ Closure $ closure ) { $ key = 'before' ; $ before = new Hook ( $ key , $ closure , $ this -> current ) ; $ this -> current -> setHook ( $ key , $ before ) ; }
Constructs a new Hook defining a closure to be ran prior to the parent suite s closure .
226,193
public function after ( \ Closure $ closure ) { $ key = 'after' ; $ after = new Hook ( $ key , $ closure , $ this -> current ) ; $ this -> current -> setHook ( $ key , $ after ) ; }
Constructs a new Hook defining a closure to be ran after the parent suite s closure .
226,194
public function watch ( ) { $ watcher = new Watcher ( ) ; $ watcher -> watchPath ( getcwd ( ) ) ; $ watcher -> addListener ( function ( ) { $ paths = implode ( ' ' , self :: $ console -> getPaths ( ) ) ; $ descriptor = [ 0 => [ 'pipe' , 'r' ] , 1 => [ 'pipe' , 'w' ] ] ; $ optionString = '' ; foreach ( self :: $ console...
Monitors the the current working directory for modifications and reruns the specs in another process on change .
226,195
private function runSuite ( Suite $ suite ) { $ this -> runRunnable ( $ suite -> getHook ( 'before' ) ) ; $ this -> reporter -> beforeSuite ( $ suite ) ; $ this -> runSpecs ( $ suite ) ; foreach ( $ suite -> getSuites ( ) as $ nestedSuite ) { $ this -> runSuite ( $ nestedSuite ) ; } $ this -> reporter -> afterSuite ( $...
Runs a particular suite by running the associated hooks and reporter methods iterating over its child suites and recursively calling itself followed by running its specs .
226,196
private function runSpecs ( Suite $ suite ) { foreach ( $ suite -> getSpecs ( ) as $ spec ) { $ pattern = self :: $ console -> options [ 'filter' ] ; if ( $ pattern && ! preg_match ( $ pattern , $ spec ) ) { continue ; } $ this -> reporter -> beforeSpec ( $ spec ) ; $ this -> runBeforeEachHooks ( $ suite , $ spec ) ; $...
Runs the specs associated with the provided test suite . It iterates over and runs each spec calling the reporter s beforeSpec and afterSpec methods as well as the suite s beforeEach and aferEach hooks . If the filter option is used only specs containing a pattern are ran . And if the stop flag is used it quits when an...
226,197
private function runBeforeEachHooks ( Suite $ suite , Spec $ spec ) { if ( $ suite -> getParent ( ) ) { $ this -> runBeforeEachHooks ( $ suite -> getParent ( ) , $ spec ) ; } $ hook = $ suite -> getHook ( 'beforeEach' ) ; $ this -> runRunnable ( $ hook ) ; if ( ! $ spec -> getException ( ) && $ hook ) { $ spec -> setEx...
Runs the beforeEach hooks of the given suite and its parent suites recursively . They are ran in the order in which they were defined from outer suite to inner suites .
226,198
public function match ( $ actual ) { $ this -> actual = gettype ( $ actual ) ; return ( $ this -> actual === $ this -> expected ) ; }
Compares the type of the passed argument to the expected type . Returns true if the two values are of the same type false otherwise .
226,199
public function match ( $ callable ) { ob_start ( ) ; $ callable ( ) ; $ this -> actual = ob_get_contents ( ) ; ob_end_clean ( ) ; return ( $ this -> actual == $ this -> expected ) ; }
Compares the output printed by the callable to the expected output . Returns true if the two strings are equal false otherwise .