Method Match Conditions
A match definition specifies the method associated with the value you want to capture as an information point. The match definition must specify the method, but it may also specify the containing class and a refining match condition. The match condition can test the value of a method parameter, return value, or the return value of an invoked object.
Use this template to create a match definition:
{
"probe": {
"phpDefinition": {
"classMatch": {
"type": "MATCHES_CLASS",
"classNameCondition": {
"type": "EQUALS",
"matchStrings": [
"<class name>"
]
}
},
"methodMatch": {
"methodNameCondition": {
"type": "EQUALS",
"matchStrings": [
"<method name>"
]
}
}
}
}
}
Edit the JSON objects in the following way:
classMatch
is optional. If you do not want to specify a class to match, delete theclassMatch
object from thephpDefinition
object.- If you are using the class match, set the value for the
classNameCondition
match string to the class name.- The class must be defined as a separate file from the file in which it is instantiated and invoked.
- If your class names are defined in a namespace, escape the backslashes in the namespace with an escape backslash.
methodMatch
is required. Set the value for themethodNameCondition
match string to the method name.
The following values are required for PHP information points:
classMatch
type:MATCHES_CLASS
classNameCondition
type:EQUALS
methodNameCondition
type:EQUALS
For example, the following JSON creates an information point on a class for which the class
name equals CheckoutManager
and the method name
processPayment
:
{
"probe": {
"phpDefinition": {
"classMatch": {
"type": "MATCHES_CLASS",
"classNameCondition": {
"type": "EQUALS",
"matchStrings": [
"Bundy\\ShoesBundle\\Entity\\CheckoutManager"
]
}
},
"methodMatch": {
"methodNameCondition": {
"type": "EQUALS",
"matchStrings": [
"processPayment"
]
}
}
}
}
}
If creating an information point primarily to capture KPI metrics for the method, it is likely you will define the class for the method. However, if you are creating an information point to implement a code metric, you may only need to specify method name matching.
This example shows a method match that tracks how many times a method is called:
{
"probe": {
"phpDefinition": {
"methodMatch": {
"methodNameCondition": {
"type": "EQUALS",
"matchStrings": [
"deleteCartItems"
]
}
}
}
}
}