PHPackages                             danielz/music-codes - 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. danielz/music-codes

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

danielz/music-codes
===================

Music Codes PHP library provides handy tools for codes in the music industry

v1.3.1(4y ago)38.8k↓90.7%MITPHPPHP &gt;=7.2.0CI failing

Since Aug 30Pushed 4y ago1 watchersCompare

[ Source](https://github.com/daniel-zahariev/music-codes)[ Packagist](https://packagist.org/packages/danielz/music-codes)[ RSS](/packages/danielz-music-codes/feed)WikiDiscussions master Synced 3w ago

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

[![License](https://camo.githubusercontent.com/074b89bca64d3edc93a1db6c7e3b1636b874540ba91d66367c0e5e354c56d0ea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e737667)](https://github.com/daniel-zahariev/music-codes/blob/master/COPYING)[![Build Status](https://camo.githubusercontent.com/83e5af7c886bc55276e9c6184aecb2ea43b0955390e07179a03b53226d67c818/68747470733a2f2f6170702e7472617669732d63692e636f6d2f64616e69656c2d7a616861726965762f6d757369632d636f6465732e7376673f6272616e63683d6d6173746572)](https://app.travis-ci.com/github/daniel-zahariev/music-codes)[![Coverage Status](https://camo.githubusercontent.com/08ed3b4b5b95f4c3b2726b83d7af1db13856d481bc67b5779c68ed9c32f84f9a/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f64616e69656c2d7a616861726965762f6d757369632d636f6465732f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/daniel-zahariev/music-codes?branch=master)

Music Codes
===========

[](#music-codes)

Music Codes PHP library provides handy tools for codes in the music industry

Isrc
====

[](#isrc)

**Note 1: for the country code portion of the ISRC the library only checks if it is comprised of 2 alphabetical characters**

**Note 2: ISRC with id 0 are not considered valid; example: `GB-A1B-11-00000`****Updated Note2: ISRCs with id 0 can now be treated as valid by calling a static method on the class prior it's general use**

Setting ISRC parts:

```
$isrc = new Isrc();
$isrc->setCountryCode('GB');
$isrc->setIssuerCode('A1B');
$isrc->setYear(11);
$isrc->setId(3);

// Prefix is the combination of country code and issuer code
// and is now adopted as standard wording in ISRC specification
// in order to allow allocation of ranges of ISRCs
$isrc->setPrefix('GB-A1B'); // can be used with or without the dash

// will output 'Valid'
echo ($isrc->isValid() ? 'Valid' : 'Not valid') . PHP_EOL;

// By default, the ids equal to zero are not considered as valid
// so to enable this globally you should call the following method:
Isrc::treatZeroIdsAsValid(true);

$isrc = new Isrc('GB-A1B-11-00000')
// will output 'Valid'
echo ($isrc->isValid() ? 'Valid' : 'Not valid') . PHP_EOL;
```

Different formatting options:

```
$isrc = new Isrc('GB-A1B-11-00003');

// outputs dashed ISRC: 'GB-A1B-11-00003'
echo $isrc->getIsrc(true) . PHP_EOL;

// outputs ISRC without dashes:'GBA1B1100003'
echo $isrc->getIsrc(false) . PHP_EOL;

// outputs ISRC withot dashes and prefixed: 'ISRC GBA1B1100003'
echo $isrc->getIsrc(false, true) . PHP_EOL;
```

Navigating up &amp; down:

```
$isrc = new Isrc('GB-A1B-11-00003');

// go one down and if it's valid output it
// outputs 'GB-A1B-11-00002'
if ($isrc->previous()) {
	echo $isrc->getIsrc(true) . PHP_EOL;
}

// reset
$isrc->load('GB-A1B-11-00003');

// go one up
$isrc->next();

// go one up and if it's valid output it
// outputs 'GB-A1B-11-00004'
if ($isrc->next()) {
	echo $isrc->getIsrc(true) . PHP_EOL;
}
```

ISWC
====

[](#iswc)

There are various ways to instantiate an ISWC object:

```
$iswc = new Iswc('T-034.524.680-1'); // use either all separators
$iswc = new Iswc('T0345246801'); // or none

$iswc = Iswc::fromId('034.524.680');
$iswc = Iswc::fromId('034524680');
```

Navigating up &amp; down:

```
$iswc = new Iswc('T-034.524.680-1');

// Bumps up the id and auto-calculates the check digit
// the ISWC is now: T-034.524.681-2
$iswc->next();

// reset
$iswc->load('T-034.524.680-1');

// the ISWC is now: T-034.524.679-8
$iswc->previous();
```

Formatting:

```
$iswc = new Iswc('T-034.524.680-1');

echo $iswc; // outputs 'T-034.524.680-1'

echo $iswc->getIswc(true); // outputs 'T-034.524.680-1'
echo $iswc->getIswc(false); // outputs 'T0345246801'
```

Label Code
==========

[](#label-code)

There are various ways to instantiate an LabelCode object:

```
$label_code = new LabelCode('LC-1234'); // dashes will be stripped by default
$label_code = new LabelCode('LC1234');

$label_code = LabelCode::fromParts('LC', 1234);
$label_code = LabelCode::fromParts('LC-', '1234');
```

Navigating up &amp; down:

```
$label_code = new LabelCode('LC-1234');

// Bumps up the id
// the Label Code is now: LC-1235
$label_code->next();

// reset
$label_code->load('LC-1234');

// the Label Code is now: LC-1233
$label_code->previous();
```

Formatting:

```
$label_code = new LabelCode('LC-1234');

echo $label_code; // outputs 'LC1234'

echo $label_code->gecLabelCode(true); // outputs 'LC-1234'
echo $label_code->gecLabelCode(false); // outputs 'LC1234'
```

Changelog
=========

[](#changelog)

**v1.3.1**

- add method `treatZeroIdsAsValid` to Isrc class to enable validation of ISRC codes where the id is 0
- add param to `isValid` method in Isrc class to enable revalidation on demand

License
=======

[](#license)

MIT License

See [COPYING](COPYING) to see the full text.

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 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 ~197 days

Recently: every ~235 days

Total

6

Last Release

1502d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1534eb273040a078e7d6f0705aafbf243eaae555b04724c0834c36235d9286c3?d=identicon)[danielz](/maintainers/danielz)

---

Top Contributors

[![daniel-zahariev](https://avatars.githubusercontent.com/u/263063?v=4)](https://github.com/daniel-zahariev "daniel-zahariev (16 commits)")

---

Tags

codeisrciswcmusiccodemusicisrc

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/danielz-music-codes/health.svg)

```
[![Health](https://phpackages.com/badges/danielz-music-codes/health.svg)](https://phpackages.com/packages/danielz-music-codes)
```

###  Alternatives

[endroid/qr-code

Endroid QR Code

4.8k71.8M438](/packages/endroid-qr-code)[laminas/laminas-code

Extensions to the PHP Reflection API, static code scanning, and code generation

1.9k192.9M204](/packages/laminas-laminas-code)[nette/php-generator

🐘 Nette PHP Generator: generates neat PHP code for you. Supports new PHP 8.5 features.

2.3k69.7M716](/packages/nette-php-generator)[jetbrains/phpstorm-stubs

PHP runtime &amp; extensions header files for PhpStorm

1.4k30.9M80](/packages/jetbrains-phpstorm-stubs)[scrivo/highlight.php

Server side syntax highlighter that supports 185 languages. It's a PHP port of highlight.js

71344.2M101](/packages/scrivo-highlightphp)[riimu/kit-phpencoder

Highly customizable alternative to var\_export for PHP code generation

718.1M35](/packages/riimu-kit-phpencoder)

PHPackages © 2026

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