The indentation package by Colin O'Dell is a PHP library to detect and manipulate indentation of strings and files:
This package is brand-new and I am not sure what the author's plans are long-term. I thought it was interesting enough to share if you need a package to detect (or change) the indentation type of a string or file:
1use ColinODell\Indentation\Indentation;2 3$indentation = Indentation::detect(file_get_contents('composer.json'));4 5$indentation->getAmount() === 4; // true6$indentation->getType() === Indentation::TYPE_SPACE; // true7(string)$indentation === ' '; // true
You can also change indentation using this package for file:
1use ColinODell\Indentation\Indentation;2 3$composerJson = file_get_contents('composer.json');4$composerJson = Indentation::change($composerJson, new Indentation(1, Indentation::TYPE_TAB));5file_put_contents('composer.json', $composerJson);
You can check out this package on GitHub at colinodell/indentation to learn more and experiment with it.
0 comments:
Post a Comment
Thanks