From a59f009a015d16fe50f81aec81d206242066fd37 Mon Sep 17 00:00:00 2001 From: Rochdi Bazine Date: Tue, 30 Apr 2019 09:01:31 +0000 Subject: [PATCH 1/5] Add removeSection() method to remove a whole section --- src/ComposerReader.php | 14 ++++++++++++++ src/ComposerReaderInterface.php | 9 +++++++++ tests/ComposerReaderTest.php | 9 +++++++++ 3 files changed, 32 insertions(+) mode change 100644 => 100755 src/ComposerReader.php mode change 100644 => 100755 src/ComposerReaderInterface.php mode change 100644 => 100755 tests/ComposerReaderTest.php diff --git a/src/ComposerReader.php b/src/ComposerReader.php old mode 100644 new mode 100755 index eefe7fb..7aebb0f --- a/src/ComposerReader.php +++ b/src/ComposerReader.php @@ -134,6 +134,20 @@ public function updateSection($section, $data) $this->_content = $content; } + + /** + * @inheritdoc + */ + public function removeSection($section) + { + $content = $this->getContent(); + + if(isset($content[$section])) { + unset ($content[$section]); + } + + $this->_content = $content; + } /** * Run a composer command in the given composer.json. diff --git a/src/ComposerReaderInterface.php b/src/ComposerReaderInterface.php old mode 100644 new mode 100755 index 70f53d7..0a697be --- a/src/ComposerReaderInterface.php +++ b/src/ComposerReaderInterface.php @@ -28,6 +28,15 @@ public function contentSection($section, $defaultValue); */ public function updateSection($section, $data); + /** + * Remove a given section. + * + * This will remove the whole section! + * + * @param string $section + */ + public function removeSection($section); + /** * Save the current Data. * diff --git a/tests/ComposerReaderTest.php b/tests/ComposerReaderTest.php old mode 100644 new mode 100755 index 19ad4ad..b061188 --- a/tests/ComposerReaderTest.php +++ b/tests/ComposerReaderTest.php @@ -106,4 +106,13 @@ public function testRunCommand() $this->assertTrue($r); } + + public function testRemove() + { + $reader = new ComposerReader($this->getValidJson()); + + $reader->removeSection('autoload'); + + $this->assertArrayNotHasKey('autoload', $reader->getContent()); + } } From 74e1f6ba750b3cf1938689afd67936de70e5586e Mon Sep 17 00:00:00 2001 From: Rochdi Bazine Date: Tue, 30 Apr 2019 12:51:14 +0000 Subject: [PATCH 2/5] Add phpdoc since tag --- src/ComposerReaderInterface.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ComposerReaderInterface.php b/src/ComposerReaderInterface.php index 0a697be..4374550 100755 --- a/src/ComposerReaderInterface.php +++ b/src/ComposerReaderInterface.php @@ -34,6 +34,7 @@ public function updateSection($section, $data); * This will remove the whole section! * * @param string $section + * @since 1.2.0 */ public function removeSection($section); From ab25cdddb9c42b2a238ea1cb25e848dd490758f2 Mon Sep 17 00:00:00 2001 From: Rochdi Bazine Date: Tue, 30 Apr 2019 12:55:47 +0000 Subject: [PATCH 3/5] Add CHANGELOG.md entry for version 1.2. --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) mode change 100644 => 100755 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md old mode 100644 new mode 100755 index 8ecab03..d7ecc7f --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,9 @@ This project adheres to [Semantic Versioning](http://semver.org/). + Added tests for php 7.3 +## 1.2.0 (30. April 2019) ++ Added feature for whole section removal + ## 1.1.0 (21. December 2018) + Add version constraint compare function. From 936f74517e0846587f297b546834414226a8ecd5 Mon Sep 17 00:00:00 2001 From: Basil Date: Tue, 30 Apr 2019 14:56:18 +0200 Subject: [PATCH 4/5] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d7ecc7f..fe39076 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). -## in progress +## 1.3.0 (in progress) + Added tests for php 7.3 From 6df2d6be73b603f963200ca9aade88eed2452b43 Mon Sep 17 00:00:00 2001 From: Basil Date: Tue, 30 Apr 2019 14:57:12 +0200 Subject: [PATCH 5/5] Update CHANGELOG.md --- CHANGELOG.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe39076..05c4d35 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,12 +4,10 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). -## 1.3.0 (in progress) - -+ Added tests for php 7.3 - ## 1.2.0 (30. April 2019) + + Added feature for whole section removal ++ Added tests for php 7.3 ## 1.1.0 (21. December 2018)