66
77use Idiosyncratic \EditorConfig \EditorConfig ;
88use Rector \Core \ValueObject \Application \File ;
9- use Rector \FileFormatter \Contract \EditorConfig \EditorConfigParserInterface ;
109use Rector \FileFormatter \ValueObject \EditorConfigConfiguration ;
10+ use Rector \FileFormatter \ValueObject \EditorConfigOption ;
1111use Rector \FileFormatter \ValueObjectFactory \EditorConfigConfigurationBuilder ;
1212
1313/**
14- * @see \Rector\Tests\FileFormatter\EditorConfig\EditorConfigIdiosyncraticParser\EditorConfigIdiosyncraticParserTest
14+ * @see \Rector\Tests\FileFormatter\EditorConfig\EditorConfigParser\EditorConfigParserTest
1515 */
16- final class EditorConfigIdiosyncraticParser implements EditorConfigParserInterface
16+ final class EditorConfigParser
1717{
1818 public function __construct (
1919 private EditorConfig $ editorConfig
@@ -27,32 +27,34 @@ public function extractConfigurationForFile(
2727 $ smartFileInfo = $ file ->getSmartFileInfo ();
2828 $ configuration = $ this ->editorConfig ->getConfigForPath ($ smartFileInfo ->getRealPath ());
2929
30- if (array_key_exists (self ::INDENT_STYLE , $ configuration )) {
31- $ indentStyle = (string ) $ configuration [self ::INDENT_STYLE ]->getValue ();
30+ if (array_key_exists (EditorConfigOption ::INDENT_STYLE , $ configuration )) {
31+ $ indentStyle = (string ) $ configuration [EditorConfigOption ::INDENT_STYLE ]->getValue ();
3232
3333 $ editorConfigConfigurationBuilder ->withIndentStyle ($ indentStyle );
3434 }
3535
36- if (array_key_exists (self ::INDENT_SIZE , $ configuration )) {
37- $ indentSize = (int ) $ configuration [self ::INDENT_SIZE ]->getValue ();
36+ if (array_key_exists (EditorConfigOption ::INDENT_SIZE , $ configuration )) {
37+ $ indentSize = (int ) $ configuration [EditorConfigOption ::INDENT_SIZE ]->getValue ();
3838
3939 $ editorConfigConfigurationBuilder ->withIndentSize ($ indentSize );
4040 }
4141
42- if (array_key_exists (self ::END_OF_LINE , $ configuration )) {
43- $ endOfLine = (string ) $ configuration [self ::END_OF_LINE ]->getValue ();
42+ if (array_key_exists (EditorConfigOption ::END_OF_LINE , $ configuration )) {
43+ $ endOfLine = (string ) $ configuration [EditorConfigOption ::END_OF_LINE ]->getValue ();
4444
4545 $ editorConfigConfigurationBuilder ->withEndOfLineFromEditorConfig ($ endOfLine );
4646 }
4747
48- if (array_key_exists (self ::INSERT_FINAL_NEWLINE , $ configuration )) {
49- $ insertFinalNewline = (bool ) $ configuration [self ::INSERT_FINAL_NEWLINE ]->getValue ();
48+ if (array_key_exists (EditorConfigOption ::INSERT_FINAL_NEWLINE , $ configuration )) {
49+ $ insertFinalNewline = (bool ) $ configuration [EditorConfigOption ::INSERT_FINAL_NEWLINE ]->getValue ();
5050
5151 $ editorConfigConfigurationBuilder ->withInsertFinalNewline ($ insertFinalNewline );
5252 }
5353
54- if (array_key_exists (self ::TAB_WIDTH , $ configuration )) {
55- $ editorConfigConfigurationBuilder ->withIndentSize ($ configuration [self ::TAB_WIDTH ]->getValue ());
54+ if (array_key_exists (EditorConfigOption::TAB_WIDTH , $ configuration )) {
55+ $ editorConfigConfigurationBuilder ->withIndentSize (
56+ $ configuration [EditorConfigOption::TAB_WIDTH ]->getValue ()
57+ );
5658 }
5759
5860 return $ editorConfigConfigurationBuilder ->build ();
0 commit comments