define('COUNT_CREATED', 'COUNT_CREATED');
define('COUNT_EXISTING', 'COUNT_EXISTING');
define('COUNT_NEXT_PASS', 'COUNT_NEXT_PASS');
define('LOGGING_CHANNEL', 'pass1');
define('LOGGING_LEVEL', 'DEBUG');
define('LOGGING_FORK_TO_STDOUT', true);
define('DRY_RUN', true);
require __DIR__ . '/bootstrap.php';
use RuntimeException;
use SObject;
use DaybreakStudios\Common\IO\CsvFileReader;
use DaybreakStudios\Common\IO\IOException;
use DaybreakStudios\Common\Utility\Counter;
use DaybreakStudios\Salesforce\Client;
$logger = getActiveLogger();
$client = new Client($config['sf.username'], $config['sf.token'], SYSTEM_WSDL_FILE);
if (!file_exists(SYSTEM_INVALIDS_FILE)) {
    throw new IOException(sprintf(MSG_FILE_MISSING, SYSTEM_INVALIDS_FILE));
}
$f = fopen(SYSTEM_INVALIDS_FILE, 'r');
if ($f === false) {
    throw new IOException(sprintf(MSG_FILE_NOT_READABLE, SYSTEM_INVALIDS_FILE));
}
$reader = new CsvFileReader($f);
$reader->addField('phone', 'cleanPhone');
$invalids = [];
while (!$reader->eof()) {
    $invalids[$reader->read()->phone] = null;
}
$logger->info(sprintf(MSG_INVALIDS_READ, sizeof($invalids), sizeof($invalids) !== 1 ? 's' : ''));
$reader->close();