PHP code example of dprmc / cusip

1. Go to this page and download the library: Download dprmc/cusip library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

dprmc / cusip example snippets




use DPRMC\CUSIP;

A2');      // true
CUSIP::isCUSIP('notacusip');      // false
CUSIP::isISIN('US9311421039');    // true
CUSIP::isSEDOL('7TT6737');        // true

use DPRMC\CUSIP;

$isValid = CUSIP::isCUSIP('222386AA2');

CUSIP::isCUSIP(' 222386AA2 '); // true

CUSIP::isCUSIP('00800*AA0'); // true
CUSIP::isCUSIP('00800@AA8'); // true
CUSIP::isCUSIP('00800#AA6'); // true

CUSIP::isCUSIP('31397JYY5'); // false

use DPRMC\CUSIP;

$input = "
3137A96Y7,
3136A45X3

31397NCJ2,
31397JYY4
";

$cusips = CUSIP::getValidCusipsFromString($input);

// [
//     '3137A96Y7',
//     '3136A45X3',
//     '31397NCJ2',
//     '31397JYY4',
// ]

$input = "
3137A96Y7,
31397NCJ2
31397NCJ2
3137A96Y7
";

$cusips = CUSIP::getUniqueValidCusipsFromString($input);

// [
//     '3137A96Y7',
//     '31397NCJ2',
// ]

$cusips = CUSIP::removeInvalidCusips([
    '222386AA2',
    'notValidCusip',
    '31397JYY5',
]);

// [
//     '222386AA2',
// ]

$checkDigit = CUSIP::getChecksumDigit('222386AA');

// 2

CUSIP::getChecksumDigit('12345678987654321'); // false

use DPRMC\CUSIP;
use DPRMC\UnfixableCusipException;

try {
    $cusip = CUSIP::fixCusip('61765XAYO');

    // Returns a valid CUSIP if replacing I/O with 1/0 fixes the value.
} catch (UnfixableCusipException $exception) {
    $originalValue = $exception->unfixableCusip;
}

CUSIP::isISIN('US9311421039'); // true
CUSIP::isISIN('US9311421038'); // false

CUSIP::isSEDOL('7TT6737'); // true
CUSIP::isSEDOL('CCCBDD4'); // false

use DPRMC\CUSIP;
use DPRMC\UnknownSymbolException;

try {
    $type = CUSIP::getSymbolType('US9311421039');

    // 'CUSIP', 'ISIN', or 'SEDOL'
} catch (UnknownSymbolException $exception) {
    $unknownValue = $exception->unknownSymbol;
}

DPRMC\CUSIP::$cusipsToIgnore;

$exception->unfixableCusip;

$exception->unknownSymbol;
bash
composer dump-autoload