danielz / music-codes
Music Codes PHP 库为音乐行业的代码提供方便的工具
v1.3.1
2022-05-13 14:18 UTC
Requires
- php: >=7.2.0
Requires (Dev)
- phpunit/phpunit: ^8.3
README
Music Codes
Music Codes PHP 库为音乐行业的代码提供方便的工具
Isrc
注意 1:对于 ISRC 的国家代码部分,库仅检查它是否由 2 个字母字符组成
注意 2:ID 为 0 的 ISRC 不可视为有效;例如: 更新注意 2:现在可以通过在类一般使用之前调用静态方法将 ID 为 0 的 ISRC 视为有效GB-A1B-11-00000
设置 ISRC 部分
$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;
不同的格式化选项
$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;
上下导航
$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 对象
$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');
上下导航
$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();
格式化
$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'
标签代码
有各种方式可以实例化 LabelCode 对象
$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');
上下导航
$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();
格式化
$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'
变更日志
v1.3.1
- 在 Isrc 类中添加方法
treatZeroIdsAsValid
以启用 ID 为 0 的 ISRC 代码的验证 - 在 Isrc 类中的
isValid
方法中添加参数以启用按需重新验证
许可
MIT 许可证
查看 COPYING 以查看完整文本。