classes which have dependencies other other classes

I’m looking for some direction regarding the following, I’m new to OOP and getting there but think either my lack of understanding is causing me to get stuck in a rabbit hole or I’m just over thinking things too much and being anal.

basically i have a main class called “CurlRequest” which sole purpose is to perform curl requests, providing a url and params it returns me some html. This class works and functions as intended and I’m happy with that.

I use this class for a few projects but for one I then wanted to track the performance of my requests made. attempted, failed, passed etc, so i created a static class for this which manages all my counters. I place counter references like the following at different areas in my CurlRequest class.


I have around 10 or so of these with my class tracking all kinds of things during the curl request and i also use my PerformanceTracker class in other classes i made.

However like mentioned i only wanted to do this for one of my projects, so find my self in the situation of having my original CurlRequest class and an altered one with performance counters in it.

My question is, is their a way i can use the same class for any project and choose to use the PerformanceTracker class or not. The obvious way i thought of was to pass an $option argument into the class and then have if statements around all the counters, but can’t help think its messy.

            if ($this->options['perfCounter'] == true ) {

                PerformanceTracker::Increment($this->owner . '.CurlRequest.Failed');


this also adds a lot of extra code to the class.

Source: stackoverflow-php