1
0
mirror of https://github.com/jupeter/clean-code-php.git synced 2025-09-25 13:39:04 +02:00

Merge pull request #166 from peter-gribanov/js_to_php

Rename function parseBetterJSAlternative()
This commit is contained in:
Tomáš Votruba
2019-09-12 10:31:03 +02:00
committed by GitHub

View File

@@ -629,7 +629,7 @@ testing.
**Bad:** **Bad:**
```php ```php
function parseBetterJSAlternative(string $code): void function parseBetterPHPAlternative(string $code): void
{ {
$regexes = [ $regexes = [
// ... // ...
@@ -656,7 +656,7 @@ function parseBetterJSAlternative(string $code): void
**Bad too:** **Bad too:**
We have carried out some of the functionality, but the `parseBetterJSAlternative()` function is still very complex and not testable. We have carried out some of the functionality, but the `parseBetterPHPAlternative()` function is still very complex and not testable.
```php ```php
function tokenize(string $code): array function tokenize(string $code): array
@@ -686,7 +686,7 @@ function lexer(array $tokens): array
return $ast; return $ast;
} }
function parseBetterJSAlternative(string $code): void function parseBetterPHPAlternative(string $code): void
{ {
$tokens = tokenize($code); $tokens = tokenize($code);
$ast = lexer($tokens); $ast = lexer($tokens);
@@ -698,7 +698,7 @@ function parseBetterJSAlternative(string $code): void
**Good:** **Good:**
The best solution is move out the dependencies of `parseBetterJSAlternative()` function. The best solution is move out the dependencies of `parseBetterPHPAlternative()` function.
```php ```php
class Tokenizer class Tokenizer
@@ -734,7 +734,7 @@ class Lexer
} }
} }
class BetterJSAlternative class BetterPHPAlternative
{ {
private $tokenizer; private $tokenizer;
private $lexer; private $lexer;