# Passing argument to a constructor and using it only in some class methods

I've created some controller for handling clicked links statistics. Does this class meet Single Responsibility Principle?

class StatisticsController
{
protected $statisticsQuery; public function __construct(StatisticsQuery$statisticsQuery)
{
$this->statisticsQuery =$statisticsQuery;
}

public function recordClickedLink(array $request) { (...) if ($this->canRecordClick()) {
}
(...)
}

public function getStatistics(array $request) { (...)$someRequestParam = $request['id'];$statistics = $this->statisticsQuery->get($someRequestParam);
(...)
}

protected function canRecordClick()
{
// returns true of false
}
}


If has two public methods. The first is responsible for saving clicked link to a database by delegating it to a model class. The second public method is responsible for getting statistics and it is the only method which use \$statisticsQuery object passed to a class' constructor. Is it OK that recordClickedLink method doesn't need constructor's argument?

I wonder also if it is OK that my class contain canRecordClick method with logic for checking if link click can be saved during particular request.

If this class doesn't meet SRP, how can I refactor it?

As far as I can see in the code example you've provided, it seems that the getStatistics and recordClickedLink methods are independent of each other. So it seems intuitive to have in this case two controllers: a StatisticsController and a something like a RecordController where the two methods recordClickedLink and canRecordClick live. In that way the StatisticsController is responsible for statisics and the RecordController for the record.
It is ok that the class contains canRecordClick, but protected means that any class extending the StatisticsController will be able to call this method too. If it will only be used in the StatisticsController, private would be better.