PHP code example of imanaging-document / check-format-bundle

1. Go to this page and download the library: Download imanaging-document/check-format-bundle 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/ */

    

imanaging-document / check-format-bundle example snippets


use Imanaging\CheckFormatBundle\CheckFormatFile;

class MyBeautifulService
{  
  /**
   * ...
   */
  public function myBeautifulFunction(...){
    ...
    $result = CheckFormatFile::checkFormatLine($structureDescription, $myLineToCheckFormat));
    ...
  }
  ...
}

$structure = [
  // Type, Column Name, Nullable
  new FieldCheckFormat("string", "Name", false),
  new FieldCheckFormat("integer", "Age", true),
  new FieldCheckFormat("integer", "Height", true),
  new FieldCheckFormat("string", "City", true),
];

$myLine = ['Rémi', '26', '170', 'San Francisco'];
$result = CheckFormatFile::checkFormatLine($structure, $myLine));

// In this case, error equals false and the errors list is empty because there is no error
// $result['error'] = false;
// $result['errors_list'] = [];

$structure = [
  // Type, Column Name, Nullable
  new FieldCheckFormat("string", "Name", false),
  new FieldCheckFormat("integer", "Age", true),
  new FieldCheckFormat("integer", "Height", true),
  new FieldCheckFormat("string", "City", true),
];

$lines = [
  ['Rémi', '26', '170', 'San Francisco'],
  ['Antonin', '26', '181', 'Miami'],
];
$result = CheckFormatFile::checkFormatFile($structure, $lines));

// In this case, error equals false and the errors list is empty because there is no error
// $result['error'] = false;
// $result['errors_list'] = [];