# canon4o/periods architecture

> Architecture diagram of the GitHub repository canon4o/periods, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/canon4o/periods
- Repository: https://github.com/canon4o/periods

## Overview

Periods is a small PHP date-period library. Callers create a validated period directly or through PeriodFactory, then use it to iterate dates, measure length, compare periods, and check dates and boundaries. PeriodInterval selects the step used for iteration and gap measurement. The graph stays at the runtime-library level; tests and development tooling are excluded.

Main entry points: [`src/Period.php`](https://github.com/canon4o/periods/blob/main/src/Period.php) (Period operations), [`src/PeriodFactory.php`](https://github.com/canon4o/periods/blob/main/src/PeriodFactory.php) (Period factory), [`src/PeriodInterval.php`](https://github.com/canon4o/periods/blob/main/src/PeriodInterval.php) (Interval units), [`src/PeriodException.php`](https://github.com/canon4o/periods/blob/main/src/PeriodException.php) (Period exception)

## Diagram (Mermaid)

```mermaid
flowchart TD

node_caller(("Library caller"))
node_factory["Period factory<br/>[PeriodFactory.php]"]
node_period["Period operations<br/>[Period.php]"]
node_interval["Interval units<br/>[PeriodInterval.php]"]
node_exception["Period exception"]
node_php_dates["PHP date APIs"]

node_caller -->|"creates periods"| node_factory
node_caller -->|"constructs directly"| node_period
node_factory -->|"creates"| node_period
node_period -->|"throws on invalid range"| node_exception
node_period -->|"uses interval"| node_interval
node_period -->|"iterates with DatePeriod"| node_php_dates
node_interval -->|"creates DateInterval"| node_php_dates

click node_factory "https://github.com/canon4o/periods/blob/main/src/PeriodFactory.php"
click node_period "https://github.com/canon4o/periods/blob/main/src/Period.php"
click node_interval "https://github.com/canon4o/periods/blob/main/src/PeriodInterval.php"
click node_exception "https://github.com/canon4o/periods/blob/main/src/PeriodException.php"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_caller toneIndigo
class node_factory,node_period,node_interval,node_exception toneTeal
class node_php_dates toneMint
```

## Components

### Other components

- **Library caller**
- [Period factory](https://github.com/canon4o/periods/blob/main/src/PeriodFactory.php): `src/PeriodFactory.php`
- [Period operations](https://github.com/canon4o/periods/blob/main/src/Period.php): `src/Period.php`
- [Interval units](https://github.com/canon4o/periods/blob/main/src/PeriodInterval.php): `src/PeriodInterval.php`
- [Period exception](https://github.com/canon4o/periods/blob/main/src/PeriodException.php): `src/PeriodException.php`
- **PHP date APIs**

## Connections

- Library caller → Period factory: creates periods (evidence: `README.md`)
- Library caller → Period operations: constructs directly (evidence: `README.md`)
- Period factory → Period operations: creates (evidence: `src/PeriodFactory.php`)
- Period operations → Period exception: throws on invalid range (evidence: `src/Period.php`)
- Period operations → Interval units: uses interval (evidence: `src/Period.php`)
- Period operations → PHP date APIs: iterates with DatePeriod (evidence: `src/Period.php`)
- Interval units → PHP date APIs: creates DateInterval (evidence: `src/PeriodInterval.php`)
