PHPackages                             kellegous/codeowners - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. kellegous/codeowners

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

kellegous/codeowners
====================

Parsing and matching of Github's CODEOWNERS file format

1.1.0(1y ago)3122MITPHPPHP &gt;=7.4

Since Oct 21Pushed 11mo ago1 watchersCompare

[ Source](https://github.com/kellegous/codeowners)[ Packagist](https://packagist.org/packages/kellegous/codeowners)[ RSS](/packages/kellegous-codeowners/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (3)Versions (5)Used By (0)

CODEOWNERS
==========

[](#codeowners)

This provides a parser and a set of matchers for the [CODEOWNERS file format](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners).

Installation
------------

[](#installation)

via [Composer](https://getcomposer.org/)

```
composer require kellegous/codeowners
```

Usage
-----

[](#usage)

### SimpleMatcher

[](#simplematcher)

The [SimpleMatcher](src/SimpleMatcher.php) is a straight-forward implementation of a [RuleMatcher](src/RuleMatcher.php)that can find the relevant pattern for a file path in `O(N)` time relative to the number of rules in the `CODEOWNERS`file.

```
$owners = Owners::fromFile('.github/CODEOWNERS');
$matcher = new SimpleMatcher($owners->getRules());
$rule = $matcher->match($relative_path);
```

### AutomataMatcher

[](#automatamatcher)

The [AutomataMatcher](src/AutomataMatcher.php) is a more complex implementation of a [RuleMatcher](src/RuleMatcher.php)that requires a bit more memory that the `SimpleMatcher` but is able to do matching in `O(log N)` time relative to the number of rules in the `CODEOWNERS` file.

```
$owners = Owners::fromFile('.github/CODEOWNERS');
$matcher = AutomataMatcher::build($owners->getRules());
$rule = $matcher->match($relative_path);
```

#### What does the AutomataMatcher do?

[](#what-does-the-automatamatcher-do)

Each of the patterns in a `CODEOWNERS` rule is a simplified regular expression and, thus, it could be represented as a fininte automata. In fact, the `SimpleMatcher` turns each of the patterns into a regular expression and then iteratively matches the path against those regular expressions. In other words, the `SimpleMatcher` executes the finite automata of each rule independently. The `AutomataMatcher`, on the other hand, combines all of the patterns into a single finite automata. For example, here is the state machine for Github's [exmaple CODEOWNERS](tests/CODEOWNERS.example).

[![Automata for CODEOWNERS.example](tests/CODEOWNERS.example.png)](tests/CODEOWNERS.example.png)

The image was rendered with the following command:

```
bin/render-nfa tests/CODEOWNERS.example | dot -Tpng -o tests/CODEOWNERS.example.png
```

Acknowledgements
----------------

[](#acknowledgements)

The code in `SimpleMatcher` that converts patterns to regular expressions owes a debt of gratitude to .

Author(s)
---------

[](#authors)

- [Kelly Norton](https://github.com/kellegous)

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance43

Moderate activity, may be stable

Popularity10

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 87.8% 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 ~4 days

Total

3

Last Release

610d ago

Major Versions

0.1.0 → 1.0.02024-10-30

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/54528?v=4)[Kelly Norton](/maintainers/kellegous)[@kellegous](https://github.com/kellegous)

---

Top Contributors

[![kellegous](https://avatars.githubusercontent.com/u/54528?v=4)](https://github.com/kellegous "kellegous (43 commits)")[![stevegrunwell](https://avatars.githubusercontent.com/u/233836?v=4)](https://github.com/stevegrunwell "stevegrunwell (6 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/kellegous-codeowners/health.svg)

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

###  Alternatives

[composer/composer

Composer helps you declare, manage and install dependencies of PHP projects. It ensures you have the right stack everywhere.

29.5k196.2M3.1k](/packages/composer-composer)[friendsofphp/php-cs-fixer

A tool to automatically fix PHP code style

13.5k251.2M25.2k](/packages/friendsofphp-php-cs-fixer)[league/commonmark

Highly-extensible PHP Markdown parser which fully supports the CommonMark spec and GitHub-Flavored Markdown (GFM)

3.0k437.5M1.0k](/packages/league-commonmark)[helsingborg-stad/municipio

A bootstrap theme for creating municipality sites.

4028.5k10](/packages/helsingborg-stad-municipio)[guzzlehttp/uri-template

A polyfill class for uri\_template of PHP

196250.8M101](/packages/guzzlehttp-uri-template)[ssch/typo3-rector

Instant fixes for your TYPO3 PHP code by using Rector.

2603.2M435](/packages/ssch-typo3-rector)

PHPackages © 2026

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