PHPackages                             karelwintersky/arris.drcalculus - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. karelwintersky/arris.drcalculus

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

karelwintersky/arris.drcalculus
===============================

Dr. Calculus statistics engine

1.3.1(3y ago)0864MITPHPPHP &gt;=7

Since Apr 17Pushed 3y ago1 watchersCompare

[ Source](https://github.com/ajur-media/DrCalculus)[ Packagist](https://packagist.org/packages/karelwintersky/arris.drcalculus)[ RSS](/packages/karelwintersky-arrisdrcalculus/feed)WikiDiscussions master Synced yesterday

READMEChangelog (6)DependenciesVersions (9)Used By (0)

Создаем таблицу для статистики
==============================

[](#создаем-таблицу-для-статистики)

```
-- создание таблицы
CREATE TABLE `stat_nviews` (
    `item_id` int(11) DEFAULT NULL,
    `item_type` enum('article','report','page') NOT NULL,
    `event_count` int(11) DEFAULT NULL,
    `event_date` date DEFAULT NULL,
    UNIQUE KEY `id_type_eventdate` (`item_id`,`item_type`,`event_date`) USING BTREE
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

```

Инициализируем
==============

[](#инициализируем)

```
use \Arris\DrCalculus\DrCalculus;

$pdo_connection = DB::C(); // or other PDO connector

DrCalculus::init($pdo_connection, ['article','report','page'] );

```

Записываем статистику:
======================

[](#записываем-статистику)

```
DrCalculus::updateVisitCount($article['id'], 'article');

```

Сигнатуры методов
=================

[](#сигнатуры-методов)

```
/**
 * Инициализирует движок DrCalculus
 *
 * @param PDO $pdo_connection       -- PDO connection
 * @param array $allowed_item_types -- словарь-список допустимых значений для поля item_type
 * @param string $stat_table        -- таблица для хранения статистики (stat_nviews по умолчанию)
 * @param bool $is_engine_disabled  -- разрешено ли DrCalculus заполнять статистику. Рекомендуется передавать сюда что-то вроде `getenv('DEBUG.DISABLE_DRCALCULUS_STATS_ENGINE')` )
 *
 */
public static function init(PDO $pdo_connection, array $allowed_item_types = [], $is_engine_disabled = false, $stat_table = 'stat_nviews')

```

```
/**
 * Обновляет таблицу статистики.
 *
 * @param $item_id   - id сущности
 * @param $item_type - тип сущности (значение из словаря, заданного при инициализации)
 *
 * @return array     - [ 'state' => статус, 'lid' => id вставленного/обновленного элемента ]
 *@throws Exception
 */
public static function updateVisitCount($item_id, $item_type)

```

```
/**
 * Удаляет статистические записи из таблицы по ITEM_ID + ITEM_TYPE
 *
 * @param $item_id
 * @param $item_type
 * @return array
 */
public static function removeVisitData($item_id, $item_type)

```

```
/**
 * Возвращает записи в статистике по элементу указанного типа за последние N дней
 *
 * @param int $id
 * @param string $type
 * @param null $last_days_interval
 * @return array
 */
public static function getItemViewCount(int $id, string $type, $last_days_interval = null)

```

```
/**
 * Возвращает количество посещений для указанного элемента указанного типа сегодня (это важно, TODAY, а не за последние сутки)
 *
 * @param $item_id
 * @param $item_type
 * @return mixed
 */
public static function getVisitCountToday($item_id, $item_type)

```

```
/**
 * Возвращает количество посещений для указанного элемента указанного типа всего
 *
 * @param $item_id
 * @param $item_type
 * @return mixed
 */
public static function getVisitCountTotal($item_id, $item_type)

```

```
/**
 * Функция-хелпер: посещений сущности суммарно: всего и сегодня
 *
 * @param $item_id
 * @param $item_type
 * @return array array ['total', 'today']
 * @throws Exception
 */
public static function getVisitCountTodaySummary($item_id, $item_type)

```

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~140 days

Recently: every ~246 days

Total

8

Last Release

1233d ago

Major Versions

0.12 → 1.02020-04-20

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2164874?v=4)[Karel Wintersky](/maintainers/KarelWintersky)[@KarelWintersky](https://github.com/KarelWintersky)

---

Top Contributors

[![KarelWintersky](https://avatars.githubusercontent.com/u/2164874?v=4)](https://github.com/KarelWintersky "KarelWintersky (12 commits)")

---

Tags

arrisphpstatistics

### Embed Badge

![Health badge](/badges/karelwintersky-arrisdrcalculus/health.svg)

```
[![Health](https://phpackages.com/badges/karelwintersky-arrisdrcalculus/health.svg)](https://phpackages.com/packages/karelwintersky-arrisdrcalculus)
```

###  Alternatives

[jalle19/php-yui-compressor

A modern PHP wrapper for the YUI compressor

17972.2k3](/packages/jalle19-php-yui-compressor)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
