Skip to content

Commit

Permalink
Removed adding extra space when dumping as I don't believe this is pa…
Browse files Browse the repository at this point in the history
…rt of specification.
  • Loading branch information
jamielsharief committed Jul 26, 2020
1 parent 138940a commit cb00812
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- Fixed issue with parsing parent e.g. `data:` which had trailing spaces
- Fixed issue with parsing parent e.g. `data:` which have trailing spaces

### Changed

- Changed dump to not include trailing space after parent

## [1.1.1] - 2020-05-26

Expand Down
2 changes: 1 addition & 1 deletion src/Yaml.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ protected static function dump(array $array, int $indent = 0, $isList = false)
if (is_int($key)) {
$output .= self::dump($value, $indent, true);
} else {
$output .= str_repeat(' ', $indent) . "{$key}: \n";
$output .= str_repeat(' ', $indent) . "{$key}:\n";
$output .= self::dump($value, $indent + self::$indent);
}
} else {
Expand Down
18 changes: 9 additions & 9 deletions tests/YamlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function testFromArrayYaml()

$expected = <<< EOT
id: 1234
address:
address:
line: | 458 Some Road
Somewhere, Something
city: london
Expand All @@ -78,10 +78,10 @@ public function testFromChildList()
$Yaml = Yaml::fromArray($students);
$expected = <<< EOT
- name: tony
phones:
phones:
- 1234-456
- name: nick
phones:
phones:
- 1234-456
- 456-4334
EOT;
Expand All @@ -103,7 +103,7 @@ public function testFromArrayMultiYamls()
$expected = <<< EOT
id: 1234
name: tony
addresess:
addresess:
- street: 1234 some road
city: london
- street: 546 some avenue
Expand Down Expand Up @@ -145,14 +145,14 @@ public function testFromArrayMultiLevel()
];
$Yaml = Yaml::fromArray($data);
$expected = <<< EOT
services:
app:
services:
app:
build: .
depends_on:
depends_on:
- db
memcached:
memcached:
image: memcached
volumes:
volumes:
mysql: abc
EOT;
$this->assertStringContainsString($expected, $Yaml);
Expand Down

0 comments on commit cb00812

Please sign in to comment.