PHP Classes

File: index.php

Recommend this page to a friend!
  Classes of András Zoltán-Gyárfás   IrisSG Technical Test   index.php   Download  
File: index.php
Role: Example script
Content type: text/plain
Description: Example script
Class: IrisSG Technical Test
Convert spreadsheet column letters to numbers
Author: By
Last change:
Date: 7 days ago
Size: 723 bytes
 

Contents

Class file image Download
<?php
require_once "vendor/autoload.php";

use
IrisSG\Test\ExcelConverter;
use
IrisSG\Test\DisplayExcelColumns;

// Check if at least one command-line argument is provided
if (count($argv) < 2) {
    echo
"Please provide at least one value to be converted as argument.\n";
    exit(
1);
}


$arguments = $argv;
// lets remove the caller file
array_shift($arguments);

$converter = new ExcelConverter();
$convertedExcelColumnToConsole = new DisplayExcelColumns();

foreach(
$arguments as $argument) {
    echo
$convertedExcelColumnToConsole->format(
       
columnToBeConverted: $argument,
       
conversionResult: (is_numeric($argument) ? $converter->numberToTitle($argument) : $converter->titleToNumber($argument))
    );
}