idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
45,200
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 .
45,201
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 .
45,202
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 .
45,203
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 .
45,204
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 .
45,205
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 .
45,206
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 .
45,207
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 .
45,208
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 .
45,209
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 .
45,210
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 .
45,211
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 .
45,212
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 .
45,213
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 .
45,214
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 .
45,215
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 .
45,216
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 .
45,217
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 .
45,218
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 .
45,219
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 .
45,220
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 .
45,221
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 .
45,222
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 .
45,223
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 .
45,224
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 .
45,225
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 .
45,226
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 .
45,227
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 .
45,228
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 .
45,229
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 .
45,230
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 .
45,231
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 .
45,232
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 .
45,233
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 .
45,234
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
45,235
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 .
45,236
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 .
45,237
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 .
45,238
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 .
45,239
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 .
45,240
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 .
45,241
public function beforeSpec ( Spec $ spec ) { parent :: beforeSpec ( $ spec ) ; if ( $ this -> lineLength == self :: $ maxPerLine ) { $ this -> console -> writeLn ( '' ) ; $ this -> lineLength = 0 ; } }
Ran before an individual spec .
45,242
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 .
45,243
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
45,244
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 .
45,245
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 .
45,246
public function metadataTransformer ( ) { if ( is_string ( $ this -> getMetadata ( ) ) ) { $ this -> setMetadata ( json_decode ( $ this -> getMetadata ( ) , true ) ) ; } }
Transforms metadata from string to array .
45,247
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
45,248
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
45,249
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
45,250
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
45,251
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
45,252
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
45,253
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
45,254
private function get ( $ url , Array $ params = [ ] ) { $ this -> processor -> get ( $ url , $ params ) ; return $ this -> handleResponse ( ) ; }
Make GET request via Curl
45,255
private function post ( $ url , $ request ) { $ this -> processor -> post ( $ url , $ request ) ; return $ this -> handleResponse ( ) ; }
Make POST request via Curl
45,256
private function put ( $ url , $ request ) { $ this -> processor -> put ( $ url , $ request , true ) ; return $ this -> handleResponse ( ) ; }
Make PUT request via Curl
45,257
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 .
45,258
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 .
45,259
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 .
45,260
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 .
45,261
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 .
45,262
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 .
45,263
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 .
45,264
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 .
45,265
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 .
45,266
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...
45,267
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 .
45,268
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 .
45,269
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 .
45,270
public function isValid ( ) { $ hashedBody = strtoupper ( hash_hmac ( 'sha512' , $ this -> webhookJson , $ this -> signature ) ) ; return ( isset ( $ this -> headers [ 'X-ANET-SIGNATURE' ] ) && strtoupper ( explode ( '=' , $ this -> headers [ 'X-ANET-SIGNATURE' ] ) [ 1 ] ) === $ hashedBody ) ; }
Validates a webhook signature to determine if the webhook is valid
45,271
protected function getAllHeaders ( ) { if ( function_exists ( 'apache_request_headers' ) ) { $ headers = apache_request_headers ( ) ; } else { $ headers = array_filter ( $ _SERVER , function ( $ key ) { return strpos ( $ key , 'HTTP_' ) === 0 ; } , ARRAY_FILTER_USE_KEY ) ; } return $ headers ; }
Retrieves all HTTP headers of a given request
45,272
public function callStripeApi ( string $ endpoint , string $ action , array $ arguments ) { try { switch ( count ( $ arguments ) ) { case 1 : $ options = empty ( $ arguments [ 'options' ] ) ? null : $ arguments [ 'options' ] ; $ return = $ endpoint :: $ action ( $ options ) ; break ; case 2 : if ( isset ( $ arguments [...
Method to call the Stripe PHP SDK s static methods .
45,273
public function callStripeObject ( ApiResource $ object , string $ method , array $ arguments = [ ] ) { try { switch ( count ( $ arguments ) ) { case 0 : $ return = $ object -> $ method ( ) ; break ; case 1 : $ return = $ object -> $ method ( $ arguments [ 0 ] ) ; break ; case 2 : $ params = empty ( $ arguments [ 'para...
Method to call the Stripe PHP SDK s NON static methods .
45,274
public function match ( $ actual ) { if ( is_string ( $ actual ) ) { $ this -> type = 'string' ; $ this -> actual = strlen ( $ actual ) ; } elseif ( is_array ( $ actual ) ) { $ this -> type = 'array' ; $ this -> actual = count ( $ actual ) ; } else { throw new \ Exception ( 'LengthMatcher::match() requires an array or ...
Compares the length of the given array or string to the expected value . Returns true if the value is of the expected length else false .
45,275
protected function checkTransactionStatus ( $ status ) { if ( $ this -> transactionInfo instanceof TransactionResponse ) { $ match = ( int ) $ this -> transactionInfo -> getTransactionResponseField ( 'ResponseCode' ) === ( int ) $ status ; } else { $ match = ( int ) $ this -> transactionResponse -> responseCode === $ s...
Check to see if the ResponseCode matches the expected value
45,276
public function getTransactionResponseField ( $ field ) { if ( $ this -> transactionInfo instanceof TransactionResponse ) { return $ this -> transactionInfo -> getTransactionResponseField ( $ field ) ; } throw new AuthnetTransactionResponseCallException ( 'This API call does not have any transaction response data' ) ; ...
Gets the transaction response field for AIM and CIM transactions .
45,277
protected function getStringValue ( $ value ) { if ( $ value === true ) { return 'true' ; } elseif ( $ value === false ) { return 'false' ; } elseif ( $ value === null ) { return 'null' ; } elseif ( is_string ( $ value ) ) { return "\"$value\"" ; } return rtrim ( print_r ( $ value , true ) ) ; }
Returns a string representation of the given value used for printing the failure message .
45,278
public function asArray ( ) : array { $ theArray = [ static :: KEY_STATUS => $ this -> status ] ; if ( $ this -> data ) { $ theArray [ static :: KEY_DATA ] = $ this -> data ; } if ( ! $ this -> data && ! $ this -> isError ( ) ) { $ theArray [ static :: KEY_DATA ] = null ; } if ( $ this -> isError ( ) ) { $ theArray [ s...
Serializes the class into an array
45,279
public function setException ( \ Exception $ exception = null ) { $ this -> exception = $ exception ; $ this -> result = self :: FAILED ; }
Sets the spec exception also marking it as failed .
45,280
public function getHook ( $ key ) { if ( isset ( $ this -> hooks [ $ key ] ) ) { return $ this -> hooks [ $ key ] ; } return null ; }
Returns the hook found at the specified key . Usually one of before after beforeEach or afterEach .
45,281
public function addSuite ( $ suite ) { if ( true === $ this -> pending ) { $ suite -> setPending ( ) ; } $ this -> suites [ ] = $ suite ; }
Adds a suite to the list of nested suites .
45,282
public function setAmount ( MoneyInterface $ amount ) : self { if ( null === $ this -> amount ) { $ this -> amount = $ amount ; } return $ this ; }
This sets the amount only if it is null .
45,283
public function getFingerprint ( $ amount ) { if ( ! filter_var ( $ amount , FILTER_VALIDATE_FLOAT , FILTER_FLAG_ALLOW_THOUSAND ) ) { throw new AuthnetInvalidAmountException ( 'You must enter a valid amount greater than zero.' ) ; } return strtoupper ( hash_hmac ( 'sha512' , sprintf ( '%s^%s^%s^%s^' , $ this -> login ,...
Returns the hash for the SIM transaction
45,284
private function sourceExists ( StripeLocalCard $ card , Collection $ sources ) { foreach ( $ sources -> data as $ source ) { if ( $ card -> getId ( ) === $ source -> id ) { return true ; } } return false ; }
Checks if the given card is set source in the StripeCustomer object .
45,285
public function hasTrigger ( $ trigger ) { return count ( $ this -> connection -> select ( $ this -> grammar -> compileTriggerExists ( ) , [ $ trigger ] ) ) > 0 ; }
Determine if the given trigger exists .
45,286
public function dropIfExists ( $ trigger ) { $ this -> build ( tap ( $ this -> createBlueprint ( $ trigger ) , function ( $ blueprint ) { $ blueprint -> dropIfExists ( ) ; } ) ) ; }
Drop trigger .
45,287
public function callBuild ( ) { $ eventObjectTable = $ this -> getEventObjectTable ( ) ; $ callback = $ this -> getStatement ( ) ; $ actionTiming = $ this -> getActionTiming ( ) ; $ event = $ this -> getEvent ( ) ; $ this -> build ( tap ( $ this -> createBlueprint ( $ this -> trigger ) , function ( Blueprint $ blueprin...
Call build to execute blueprint to build trigger .
45,288
public function getReporterClass ( ) { $ reporter = $ this -> options [ 'reporter' ] ; if ( $ reporter === false ) { return self :: DEFAULT_REPORTER ; } $ reporterClass = ucfirst ( $ reporter ) . 'Reporter' ; $ reporterClass = "pho\\Reporter\\$reporterClass" ; try { $ reflection = new ReflectionClass ( $ reporterClass ...
Returns the namespaced name of the reporter class requested via the command line arguments defaulting to DotReporter if not specified .
45,289
public function afterSuite ( Suite $ suite ) { $ hook = $ suite -> getHook ( 'after' ) ; if ( $ hook && $ hook -> getException ( ) ) { $ this -> handleHookFailure ( $ hook ) ; } }
Ran after the containing test suite is invoked .
45,290
public function afterRun ( ) { if ( count ( $ this -> failures ) ) { $ this -> console -> writeLn ( "\nFailures:" ) ; } foreach ( $ this -> failures as $ spec ) { $ failedText = $ this -> formatter -> red ( "\n\"$spec\" FAILED" ) ; $ this -> console -> writeLn ( $ failedText ) ; $ this -> console -> writeLn ( $ spec ->...
Invoked after the test suite has ran allowing for the display of test results and related statistics .
45,291
public function alignText ( $ array , $ delimiter = '' ) { $ widths = [ ] ; foreach ( $ array as $ row ) { $ lengths = array_map ( 'strlen' , $ row ) ; for ( $ i = 0 ; $ i < count ( $ lengths ) ; $ i ++ ) { if ( isset ( $ widths [ $ i ] ) ) { $ widths [ $ i ] = max ( $ widths [ $ i ] , $ lengths [ $ i ] ) ; } else { $ ...
Given a multidimensional array formats the text such that each entry is left aligned with all other entries in the given column . The method also takes an optional delimiter for specifying a sequence of characters to separate each column .
45,292
public function watchPath ( $ path ) { if ( ! $ this -> inotify ) { $ this -> paths [ ] = $ path ; $ this -> addModifiedTimes ( $ path ) ; return ; } $ mask = IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE | IN_MOVE | IN_CREATE | IN_DELETE | IN_DELETE_SELF | IN_MOVE_SELF ; $ directoryIterator = new \ RecursiveDirectoryIterator...
Adds the path to the list of files and folders to monitor for changes . If the path is a file its modification time is stored for comparison . If a directory the modification times for each sub - directory and file are recursively stored .
45,293
private function addModifiedTimes ( $ path ) { if ( is_file ( $ path ) ) { $ stat = stat ( $ path ) ; $ this -> modifiedTimes [ realpath ( $ path ) ] = $ stat [ 'mtime' ] ; return ; } $ directoryIterator = new \ RecursiveDirectoryIterator ( realpath ( $ path ) ) ; $ files = new \ RecursiveIteratorIterator ( $ directory...
Given the path to a file or directory recursively adds the modified times of any nested folders to the modifiedTimes property .
45,294
public function match ( $ subject ) { $ this -> subject = $ subject ; $ suffixLength = strlen ( $ this -> suffix ) ; if ( ! $ suffixLength ) { return true ; } return ( substr ( $ subject , - $ suffixLength ) === $ this -> suffix ) ; }
Returns true if the subject ends with the given suffix false otherwise .
45,295
protected function populate ( $ name , $ eventObjectTable , $ actionTiming , $ event , $ stub ) { $ stub = str_replace ( 'DummyClass' , $ this -> getClassName ( $ name ) , $ stub ) ; $ stub = str_replace ( 'DummyName' , $ name , $ stub ) ; $ stub = str_replace ( 'DummyEventObjectTable' , $ eventObjectTable , $ stub ) ;...
Populate migration stub .
45,296
public function getConsoleOption ( $ name ) { if ( isset ( $ this -> options [ $ name ] ) ) { return $ this -> options [ $ name ] ; } foreach ( $ this -> options as $ option ) { $ longName = $ option -> getLongName ( ) ; $ shortName = $ option -> getShortName ( ) ; if ( $ name == $ longName || $ name == $ shortName ) {...
Returns the ConsoleOption object either found at the key with the supplied name or whose short name or long name matches .
45,297
public function getOptions ( ) { $ options = [ ] ; foreach ( $ this -> options as $ name => $ option ) { $ options [ $ name ] = $ option -> getValue ( ) ; } return $ options ; }
Returns an associative array consisting of the names of the ConsoleOptions added to the parser and their values .
45,298
public function getOptionNames ( ) { $ names = [ ] ; foreach ( $ this -> options as $ option ) { $ names [ ] = $ option -> getLongName ( ) ; $ names [ ] = $ option -> getShortName ( ) ; } return $ names ; }
Returns an array containing the long and short names of all options .
45,299
public function match ( $ callable ) { try { $ callable ( ) ; } catch ( \ Exception $ exception ) { $ this -> thrown = $ exception ; } return ( $ this -> thrown instanceof $ this -> expected ) ; }
Compares the exception thrown by the callable if any to the expected exception . Returns true if an exception of the expected class is thrown false otherwise .