for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
namespace Maslosoft\Zamm\Helpers;
/**
* Tabs
*
* @author Piotr Maselkowski <pmaselkowski at gmail.com>
class Tabs
{
public static function trim(&$lines)
$string = false;
if(is_string($lines))
$string = true;
$lines = explode(PHP_EOL, $lines);
}
// Trim empty tabs columns
$minTabs = 666;
foreach ($lines as $line)
$matches = [];
preg_match("~^\t+~", $line, $matches);
if (!isset($matches[0]))
continue;
$minTabs = min([$minTabs, strlen($matches[0])]);
if ($minTabs < 666)
foreach ($lines as &$line)
$line = preg_replace("~^\t{{$minTabs}}~", '', $line);
if($string)
$lines = implode(PHP_EOL, $lines);