PHP library to detect and manipulate the indentation of files and strings
composer require --dev colinodell/indentation
use ColinODell\Indentation\Indentation;
$indentation = Indentation::detect(file_get_contents('composer.json'));
assert($indentation->getAmount() === 4);
assert($indentation->getType() === Indentation::TYPE_SPACE);
assert((string)$indentation === ' ');
use ColinODell\Indentation\Indentation;
$composerJson = file_get_contents('composer.json');
$composerJson = Indentation::change($composerJson, new Indentation(Indentation::TYPE_TAB, 1));
file_put_contents('composer.json', $composerJson);