PHPackages                             soundways/iso7064 - 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. soundways/iso7064

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

soundways/iso7064
=================

An ISO 7064 check character calculator created for GRid codes

v1.1.0(7y ago)44621MITPHPPHP ^7.1CI failing

Since Nov 5Pushed 6y ago4 watchersCompare

[ Source](https://github.com/Soundways/Iso7064-php)[ Packagist](https://packagist.org/packages/soundways/iso7064)[ Docs](https://github.com/Soundways/Iso7064)[ RSS](/packages/soundways-iso7064/feed)WikiDiscussions master Synced yesterday

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

ISO 7064
========

[](#iso-7064)

[![Build Status](https://camo.githubusercontent.com/a8746f342592acea0551ee5ef33fcd8e7cf1bc106f245a931aa45756e72128cb/68747470733a2f2f7472617669732d63692e636f6d2f736f756e64776179732f49736f373036342d7068702e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/soundways/Iso7064-php) [![PHP from Travis config](https://camo.githubusercontent.com/29f1d7f2bee5c0caf2990a125950c87189d906e176edf0c578dd8c4a9169dc79/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f7068702d762f736f756e64776179732f49736f373036342d706870)](https://camo.githubusercontent.com/29f1d7f2bee5c0caf2990a125950c87189d906e176edf0c578dd8c4a9169dc79/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f7068702d762f736f756e64776179732f49736f373036342d706870) [![codecov](https://camo.githubusercontent.com/f95543568250f34d119155459625b1ad7ad211b747340b422b916069478425e3/68747470733a2f2f636f6465636f762e696f2f67682f736f756e64776179732f49736f373036342d7068702f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/soundways/Iso7064-php)

Soundways Iso7064 provides an implementation of ISO 7064:1983 Mod 37, 36, intended primarily for use in calculating the check character for [GRid standard 2.1](https://ifpi.org/downloads/GRid_Standard_v2_1.pdf).

This requires PHP 7.1

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

[](#installation)

Using [Composer](https://getcomposer.org), require this package in the root directory of your project.

```
$ composer require 'soundways/iso7064'
```

### Dependencies

[](#dependencies)

`ext-mbstring` is required for `mb_strlen`. If `ext-mbstring` is unavailable for any reason, `symfony\polyfill-mbstring` is required in its place.

Iso7064 uses type hinting which requires a PHP version ^7.1

Quickstart
----------

[](#quickstart)

Calculate a check character using a GRid object:

```
use Soundways\Iso7064\GRid;

$grid = new GRid('A1-2425G-ABC1234002');

$grid->encode();

// returns 'A1-2425G-ABC1234002-M'
$grid->getDelimitedGRid();
```

Reference
---------

[](#reference)

The namespace contains the `Mod3736` class for general-purpose encoding within the ISO standard and the `GRid` class which enforces GRid specific requirements and includes some helper functions.

### Mod

[](#mod)

`Mod` is an abstract class providing general functionality for encoding and verifying check characters using ISO 7064, regardless of modulus. Codes will be stripped of non-alphanumeric characters and stored in the object's `$code` attribute.

- `function encode(): string`
    Encode is a helper function for generating and appending a check character for the object's `$code` attribute. When called, the `$code` attribute will be updated with its check character. The result is equivalent to:

```
$mod = new Mod3736();
$code = 'ABCDEFG';
$code .= $mod->generateCheckChar($code);
```

- `function generateCheckChar(?string $code): string`
    Generates and returns a check character for the given code. If a code is not passed as an argument, the function will instead use the object's `$code` attribute.
    To create a class for a specific modulus, this function must be overridden with the algorithm for that modulus.
- `function validateCheckChar(): bool`
    Takes the check character from the object's `$code` attribute and returns whether it matches the string's calculated check character.
- `function setCode(string $code): void`
    Setter for the `$code` attribute. Strips non-alphanumeric characters automatically.
- `function getCode(): string`
    Getter for the `$code` attribute.
- `function format(array $lengths, string $delimiter): string`
    Returns the `$code` attribute delimited with sequences of the given lengths. For example, if the current code is `'ABCDEFGR'` and you pass `[1, 3, 3, 1]` as the lengths array with `'-'` as the delimiter, the function will return `'A-BCD-EFG-R'`.
- `function getCheckChar(): string`
    Helper function for returning the last character of the object's `$code` attribute.

### Mod3736

[](#mod3736)

The `Mod3736` class extends `Mod` with functionality for Mod 37, 36.

- `function generateCheckChar(?string $code): string`
    Generates a check character following Mod 37, 36

### GRid

[](#grid)

The `GRid` class extends `Mod3736` and offers largely the same functionality, but also enforces the GRid standard and includes additional helpers for formatting. If pssed a code in the constructor, the code will be checked for formatting as well as being parsed as in the `Mod3736` constructor.

#### Functions that are directly inherited from Mod3736:

[](#functions-that-are-directly-inherited-from-mod3736)

`getCode()`

`getCheckChar()`

#### Functions that behave like Mod3736 but enforce GRid standards:

[](#functions-that-behave-like-mod3736-but-enforce-grid-standards)

This includes not encoding already-encoded GRids and not validating unencoded GRids.

`encode()`

`generateCheckChar()`

`validateCheckChar()`

`setCode()`

#### GRid function reference

[](#grid-function-reference)

- `function format(): string`
    Returns object's `$code` attribute delimited in the format XX-XXXXX-XXXXXXXXXX-X per GRid standard 2.1. Function will throw GRidException if called while the `$code` attribute is unencoded.
    As this function inherits from `Mod3736::format()`, it can be passed the `$lengths` and `$delimiter` arguments; however, these are ignored in favor of enforcing the GRid format. No arguments need to be passed to this function.
- `static function checkGRid(string $code): bool`
    Static helper function for quickly validating GRid codes without manually creating any instances of the GRid object, like so:

```
// returns true
GRid::checkGRid('A1-2425G-ABC1234002-M');

// returns false
GRid::checkGRid('A1-2425G-ABC1234002-0');
```

Addendum
--------

[](#addendum)

[With respect to André Catita's implementation of ISO 7064 Mod 11, 2](http://andrecatita.com/code-snippets/iso-7064-mod-112-php/).

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50.9% 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 ~147 days

Total

2

Last Release

2597d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/98977678351ec27853659616eebc2191d15e7f0662e85d0e2916dd5c34570f93?d=identicon)[jamekrut](/maintainers/jamekrut)

---

Top Contributors

[![Stardust-Labs](https://avatars.githubusercontent.com/u/22037707?v=4)](https://github.com/Stardust-Labs "Stardust-Labs (29 commits)")[![rpham00](https://avatars.githubusercontent.com/u/49896878?v=4)](https://github.com/rpham00 "rpham00 (28 commits)")

---

Tags

checkisogridcharacter

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/soundways-iso7064/health.svg)

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

###  Alternatives

[desandro/masonry

Cascading grid layout library

16.7k424.4k1](/packages/desandro-masonry)[league/iso3166

ISO 3166-1 PHP Library

69536.3M116](/packages/league-iso3166)[kartik-v/yii2-grid

Yii 2 GridView on steroids. Various enhancements and utilities for the Yii 2.0 GridView widget.

5576.6M179](/packages/kartik-v-yii2-grid)[payum/iso4217

ISO 4217 PHP Library

16312.1M5](/packages/payum-iso4217)[consistence/consistence

Consistence - consistent approach and additions to PHP's functionality

1831.1M18](/packages/consistence-consistence)[matriphe/iso-639

PHP library to convert ISO-639-1 code to language name.

503.3M6](/packages/matriphe-iso-639)

PHPackages © 2026

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