PHP code example of rechtlogisch / wirtschafts-id

1. Go to this page and download the library: Download rechtlogisch/wirtschafts-id 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/ */

    

rechtlogisch / wirtschafts-id example snippets


isWirtschaftsIdValid('DE123456788'); // => true

use Rechtlogisch\WirtschaftsId\WirtschaftsId;

(new WirtschaftsId('DE123456788'))
    ->validate() // ValidationResult::class
    ->isValid(); // => true

isWirtschaftsIdValid('DE123456788-00001'); // => true

use Rechtlogisch\WirtschaftsId\WirtschaftsId;

(new WirtschaftsId('DE123456788-00001'))
    ->validate() // ValidationResult::class
    ->isValid(); // => true

validateWirtschaftsId('DE12345678')->getErrors();
// [
//   'Rechtlogisch\WirtschaftsId\Exceptions\InvalidWirtschaftsIdWithoutUnterscheidungsmerkmalLength'
//    => 'Wirtschafts-ID must be 11 characters long. Provided Wirtschafts-ID is: 10 characters long.',
// ]

use Rechtlogisch\WirtschaftsId\WirtschaftsId;

(new WirtschaftsId('DE12345678'))
    ->validate()
    ->getErrors();
// [
//   'Rechtlogisch\WirtschaftsId\Exceptions\InvalidWirtschaftsIdWithoutUnterscheidungsmerkmalLength'
//    => 'Wirtschafts-ID must be 11 characters long. Provided Wirtschafts-ID is: 10 characters long.',
// ]

validateWirtschaftsId('DE123456788-00002')->getHints();
// [
//   'Rechtlogisch\WirtschaftsId\Exceptions\UnterscheidungsmerkmalShouldBe00001BeforeYear2027'
//    => 'Unterscheidungsmerkmal (after -) is typically "00001" before year 2027.',
// ]