Skip to content

PHP library to detect and manipulate indentation of strings and files

License

Notifications You must be signed in to change notification settings

paulredmond/indentation

 
 

Repository files navigation

indentation

Latest Version Total Downloads Software License Build Status Coverage Status Quality Score Psalm Type Coverage Sponsor development of this project

PHP library to detect and manipulate the indentation of files and strings

Installation

composer require --dev colinodell/indentation

Usage

Detecting the indentation of a string or file

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 === '    ');

Changing the indentation of a string or file

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);

About

PHP library to detect and manipulate indentation of strings and files

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%