From 3608e00fc614e505ad5cc3558065259673d37a9f Mon Sep 17 00:00:00 2001 From: Yulij Andreevich Lesov Date: Tue, 5 Jul 2016 21:38:51 +0800 Subject: [PATCH] switch from 4 spaces to 2 spaces --- .travis.yml | 10 +-- composer.json | 64 ++++++++-------- src/Yalesov/Yaml/Yaml.php | 46 ++++++------ test/Yalesov/Test/Yaml/YamlTest.php | 110 ++++++++++++++-------------- test/phpunit.xml | 10 +-- 5 files changed, 120 insertions(+), 120 deletions(-) diff --git a/.travis.yml b/.travis.yml index d758776..49cfaa9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,10 @@ language: php php: - - "5.3" - - "5.4" + - "5.3" + - "5.4" before_script: composer install script: phpunit --configuration test/phpunit.xml notifications: - email: - on_success: always - on_failure: always + email: + on_success: always + on_failure: always diff --git a/composer.json b/composer.json index 1bb150f..d2ed7fb 100644 --- a/composer.json +++ b/composer.json @@ -1,35 +1,35 @@ { - "name": "yalesov/yaml", - "description": "Wrapper around Symfony's Yaml parser - added __DIR__ support.", - "keywords": ["yaml", "yml"], - "authors": [ - { - "name": "Yulij Andreevich Lesov", - "email": "yalesov@gmail.com" - } - ], - "require": { - "php": ">=5.3.3", - "yalesov/arg-validator": "2.*", - "symfony/yaml": "*" - }, - "require-dev": { - "phpunit/phpunit": "*" - }, - "autoload": { - "psr-0": { - "Yalesov\\Yaml": "src/" - } - }, - "license": "ISC", - "homepage": "https://github.com/yalesov/php-yaml", - "repositories": [ - { - "type": "vcs", - "url": "https://github.com/yalesov/php-yaml" - } - ], - "support": { - "issues": "https://github.com/yalesov/php-yaml/issues" + "name": "yalesov/yaml", + "description": "Wrapper around Symfony's Yaml parser - added __DIR__ support.", + "keywords": ["yaml", "yml"], + "authors": [ + { + "name": "Yulij Andreevich Lesov", + "email": "yalesov@gmail.com" } + ], + "require": { + "php": ">=5.3.3", + "yalesov/arg-validator": "2.*", + "symfony/yaml": "*" + }, + "require-dev": { + "phpunit/phpunit": "*" + }, + "autoload": { + "psr-0": { + "Yalesov\\Yaml": "src/" + } + }, + "license": "ISC", + "homepage": "https://github.com/yalesov/php-yaml", + "repositories": [ + { + "type": "vcs", + "url": "https://github.com/yalesov/php-yaml" + } + ], + "support": { + "issues": "https://github.com/yalesov/php-yaml/issues" + } } diff --git a/src/Yalesov/Yaml/Yaml.php b/src/Yalesov/Yaml/Yaml.php index f5666e4..a4ceb12 100644 --- a/src/Yalesov/Yaml/Yaml.php +++ b/src/Yalesov/Yaml/Yaml.php @@ -6,28 +6,28 @@ class Yaml { - /** - * Yaml parser - * - * __DIR__ support: (only available for Yaml files, of course!) - * - '__DIR__' will behave as expected - * - '___DIR___' (an extra underscore around) will be translated as a literal '__DIR__' - * - * @param mixed $yaml - * @return self - */ - public static function parse($yaml) - { - ArgValidator::assert($yaml, 'string'); - if (is_file($yaml) && is_readable($yaml)) { - $dir = realpath(dirname($yaml)); - $yaml = file_get_contents($yaml); - $yaml = strtr($yaml, array( - '___DIR___' => '__DIR__', - '__DIR__' => $dir, - )); - } - - return SymfonyYaml::parse($yaml); + /** + * Yaml parser + * + * __DIR__ support: (only available for Yaml files, of course!) + * - '__DIR__' will behave as expected + * - '___DIR___' (an extra underscore around) will be translated as a literal '__DIR__' + * + * @param mixed $yaml + * @return self + */ + public static function parse($yaml) + { + ArgValidator::assert($yaml, 'string'); + if (is_file($yaml) && is_readable($yaml)) { + $dir = realpath(dirname($yaml)); + $yaml = file_get_contents($yaml); + $yaml = strtr($yaml, array( + '___DIR___' => '__DIR__', + '__DIR__' => $dir, + )); } + + return SymfonyYaml::parse($yaml); + } } diff --git a/test/Yalesov/Test/Yaml/YamlTest.php b/test/Yalesov/Test/Yaml/YamlTest.php index ea38a27..86740d9 100644 --- a/test/Yalesov/Test/Yaml/YamlTest.php +++ b/test/Yalesov/Test/Yaml/YamlTest.php @@ -5,68 +5,68 @@ class YamlTest extends \PHPUnit_Framework_TestCase { - public function setUp() - { - $this->tmpFile = '.yaml'; - $this->tmpPath = realpath(dirname($this->tmpFile)); - } + public function setUp() + { + $this->tmpFile = '.yaml'; + $this->tmpPath = realpath(dirname($this->tmpFile)); + } - public function tearDown() - { - unlink($this->tmpFile); - } + public function tearDown() + { + unlink($this->tmpFile); + } - public function testParse() - { - // yaml stream - $yaml = 'foo: bar'; - $this->assertSame( - array('foo' => 'bar'), - Yaml::parse($yaml)); + public function testParse() + { + // yaml stream + $yaml = 'foo: bar'; + $this->assertSame( + array('foo' => 'bar'), + Yaml::parse($yaml)); - // yaml file - file_put_contents($this->tmpFile, 'foo: bar'); - $this->assertSame( - array('foo' => 'bar'), - Yaml::parse($this->tmpFile)); + // yaml file + file_put_contents($this->tmpFile, 'foo: bar'); + $this->assertSame( + array('foo' => 'bar'), + Yaml::parse($this->tmpFile)); - // __DIR__ - file_put_contents($this->tmpFile, 'foo: __DIR__/bar'); - $this->assertSame( - array('foo' => "{$this->tmpPath}/bar"), - Yaml::parse($this->tmpFile)); + // __DIR__ + file_put_contents($this->tmpFile, 'foo: __DIR__/bar'); + $this->assertSame( + array('foo' => "{$this->tmpPath}/bar"), + Yaml::parse($this->tmpFile)); - // ___DIR___ - file_put_contents($this->tmpFile, 'foo: ___DIR___/bar'); - $this->assertSame( - array('foo' => '__DIR__/bar'), - Yaml::parse($this->tmpFile)); + // ___DIR___ + file_put_contents($this->tmpFile, 'foo: ___DIR___/bar'); + $this->assertSame( + array('foo' => '__DIR__/bar'), + Yaml::parse($this->tmpFile)); - // multiple __DIR__ - file_put_contents($this->tmpFile, '__DIR__/foo: __DIR__/bar'); - $this->assertSame( - array("{$this->tmpPath}/foo" => "{$this->tmpPath}/bar"), - Yaml::parse($this->tmpFile)); + // multiple __DIR__ + file_put_contents($this->tmpFile, '__DIR__/foo: __DIR__/bar'); + $this->assertSame( + array("{$this->tmpPath}/foo" => "{$this->tmpPath}/bar"), + Yaml::parse($this->tmpFile)); - // multiple ___DIR___ - file_put_contents($this->tmpFile, '___DIR___/foo: ___DIR___/bar'); - $this->assertSame( - array('__DIR__/foo' => '__DIR__/bar'), - Yaml::parse($this->tmpFile)); + // multiple ___DIR___ + file_put_contents($this->tmpFile, '___DIR___/foo: ___DIR___/bar'); + $this->assertSame( + array('__DIR__/foo' => '__DIR__/bar'), + Yaml::parse($this->tmpFile)); - // altogether - file_put_contents($this->tmpFile, "__DIR__/foo: ___DIR___/bar\n___DIR___/bar: __DIR__/foo"); - $this->assertSame( - array( - "{$this->tmpPath}/foo" => '__DIR__/bar', - '__DIR__/bar' => "{$this->tmpPath}/foo", - ), - Yaml::parse($this->tmpFile)); + // altogether + file_put_contents($this->tmpFile, "__DIR__/foo: ___DIR___/bar\n___DIR___/bar: __DIR__/foo"); + $this->assertSame( + array( + "{$this->tmpPath}/foo" => '__DIR__/bar', + '__DIR__/bar' => "{$this->tmpPath}/foo", + ), + Yaml::parse($this->tmpFile)); - // neither available when passed in a string - $yaml = '__DIR__/foo: ___DIR___/bar'; - $this->assertSame( - array('__DIR__/foo' => '___DIR___/bar'), - Yaml::parse($yaml)); - } + // neither available when passed in a string + $yaml = '__DIR__/foo: ___DIR___/bar'; + $this->assertSame( + array('__DIR__/foo' => '___DIR___/bar'), + Yaml::parse($yaml)); + } } diff --git a/test/phpunit.xml b/test/phpunit.xml index 0a86839..89f5b01 100644 --- a/test/phpunit.xml +++ b/test/phpunit.xml @@ -1,7 +1,7 @@ - - - ./ - - + + + ./ + +