Hoa central
Public Member Functions | Protected Attributes | List of all members
Hoa\Devtools\Bin\Cs Class Reference
Inheritance diagram for Hoa\Devtools\Bin\Cs:

Public Member Functions

 main ()
 
 usage ()
 
- Public Member Functions inherited from Hoa\Console\Dispatcher\Kit
 __construct (Router $router, Dispatcher $dispatcher, View\Viewable $view=null)
 
 getOption (&$optionValue, $short=null)
 
 setOptions (Array $options)
 
 makeUsageOptionsList (Array $definitions=[])
 
 resolveOptionAmbiguity (Array $solutions)
 
 status ($text, $status)
 
 readLine ($prefix=null)
 
 readPassword ($prefix=null)
 
- Public Member Functions inherited from Hoa\Dispatcher\Kit
 __construct (Router $router, Dispatcher $dispatcher, View\Viewable $view=null)
 
 construct ()
 

Protected Attributes

 $options
 
- Protected Attributes inherited from Hoa\Console\Dispatcher\Kit
 $options = null
 
 $_options = null
 

Additional Inherited Members

- Public Attributes inherited from Hoa\Console\Dispatcher\Kit
 $parser = null
 
- Public Attributes inherited from Hoa\Dispatcher\Kit
 $router = null
 
 $dispatcher = null
 
 $view = null
 
 $data = null
 

Detailed Description

Class .

Wrapper around php-cs-fixer.

Definition at line 50 of file Cs.php.

Member Function Documentation

Hoa\Devtools\Bin\Cs::main ( )

The entry method.

Returns
int

Definition at line 71 of file Cs.php.

72  {
73  $dryRun = false;
74  $diff = false;
75 
76  while (false !== $c = $this->getOption($v)) {
77  switch ($c) {
78  case '__ambiguous':
79  $this->resolveOptionAmbiguity($v);
80 
81  break;
82 
83  case 'd':
84  $dryRun = true;
85 
86  break;
87 
88  case 'D':
89  $diff = true;
90 
91  break;
92 
93  case 'h':
94  case '?':
95  default:
96  return $this->usage();
97  }
98  }
99 
100  $this->parser->listInputs($path);
101 
102  if (empty($path)) {
103  return $this->usage();
104  }
105 
106  $phpCsFixer = Console\Processus::locate('php-cs-fixer');
107  $configurationFile = resolve(
108  'hoa://Library/Devtools/Resource/PHPCSFixer/ConfigurationFile.php'
109  );
110 
111  if (empty($phpCsFixer)) {
112  throw new Console\Exception('php-cs-fixer binary is not found.', 0);
113  }
114 
115  $arguments = ['fix', '--config-file' => $configurationFile];
116 
117  if (true === $dryRun) {
118  $arguments[] = '--dry-run';
119  }
120 
121  if (true === $diff) {
122  $arguments[] = '--diff';
123  }
124 
125  $arguments[] = $path;
126 
127  $processus = new Console\Processus($phpCsFixer, $arguments);
128  $processus->on('input', function () {
129  return false;
130  });
131  $processus->on('output', function (Core\Event\Bucket $bucket) {
132  echo $bucket->getData()['line'], "\n";
133 
134  return;
135  });
136  $processus->run();
137 
138  return;
139  }
static locate($binary)
Definition: Processus.php:1133
getOption(&$optionValue, $short=null)
Definition: Kit.php:104
resolveOptionAmbiguity(Array $solutions)
Definition: Kit.php:190

Here is the call graph for this function:

Hoa\Devtools\Bin\Cs::usage ( )

The command usage.

Returns
int

Definition at line 146 of file Cs.php.

147  {
148  echo
149  'Usage : devtools:cs <options> path', "\n",
150  'Options :', "\n",
151  $this->makeUsageOptionsList([
152  'd' => 'Only shows which files would have been modified.',
153  'D' => 'Produce diff for each file.',
154  'help' => 'This help.'
155  ]), "\n";
156 
157  return;
158  }
makeUsageOptionsList(Array $definitions=[])
Definition: Kit.php:149

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

Hoa\Devtools\Bin\Cs::$options
protected
Initial value:

Definition at line 57 of file Cs.php.


The documentation for this class was generated from the following file: