How best to implement the next task?
There are 10+ .php files that perform different functions and it is required to keep statistics on their activity, for example, which file has been executed a number of times .. prior to this, by itself getting data from the database. It seems to be a simple task, and on the move you can come up with some kind of crutch, but I thought a lot about the correctness of its implementation.
ps: All scripts are executed by a direct call from the main index.php
For example, this option is a crutch or has the right to life, but still I would like to know how to make the most beautiful
class stat { protected $statistic = array(); public function __construct () { $result = db_get_statistic(); foreach ($result as $k => $v) { $this->statistic[$k] = $v; } } function refresh($key, $value) { $tmp = $this->statistic[$key] + $value; $this->statistic[$key] = $tmp; } function write() { db_write_statistic($this->statistic); } }