diff --git a/src/lib/Herrera/Box/StubGenerator.php b/src/lib/Herrera/Box/StubGenerator.php index 6ea3db8..cad4cda 100644 --- a/src/lib/Herrera/Box/StubGenerator.php +++ b/src/lib/Herrera/Box/StubGenerator.php @@ -30,6 +30,15 @@ class StubGenerator */ private $alias; + /** + * The top header comment banner text. + * + * @var string. + */ + private $banner = 'Generated by Box. + +@link https://github.com/herrera-io/php-box/'; + /** * The location within the Phar of index script. * @@ -93,6 +102,20 @@ public function alias($alias) return $this; } + /** + * Sets the top header comment banner text. + * + * @param string $banner The banner text. + * + * @return StubGenerator The stub generator. + */ + public function banner($banner) + { + $this->banner = $banner; + + return $this; + } + /** * Creates a new instance of the stub generator. * @@ -146,13 +169,15 @@ public function generate() #!/usr/bin/env php banner !== null) { + $stub .= ' /** - * Generated by Box. - * - * @link https://github.com/herrera-io/php-box/ + * ' . str_replace(" \n", "\n", str_replace("\n", "\n * ", $this->banner)) . ' */ - -STUB; +'; + } if ($this->alias) { if ($this->web) { diff --git a/src/tests/Herrera/Box/Tests/StubGeneratorTest.php b/src/tests/Herrera/Box/Tests/StubGeneratorTest.php index f1a5b6c..11362c8 100644 --- a/src/tests/Herrera/Box/Tests/StubGeneratorTest.php +++ b/src/tests/Herrera/Box/Tests/StubGeneratorTest.php @@ -23,6 +23,45 @@ public function testAlias() ); } + public function testBanner() + { + $this->generator->banner('Phar creation + +does work + + + indented'); + + $this->assertEquals( + 'Phar creation + +does work + + + indented', + $this->getPropertyValue($this->generator, 'banner') + ); + + $this->assertEquals( + <<generator->generate() + ); + } + public function testCreate() { $this->assertInstanceOf(