Skip to content

Commit

Permalink
Improved code climate
Browse files Browse the repository at this point in the history
  • Loading branch information
jkphl committed May 16, 2016
1 parent 68a0316 commit dc2a840
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 23 deletions.
3 changes: 2 additions & 1 deletion src/Resource/Ports/Tools.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ public static function delete($src, ...$parameters)
*
* @return InvalidArgumentException If the reader stream wrapper is invalid
*/
protected static function failInvalidReader() {
protected static function failInvalidReader()
{
return new InvalidArgumentException(
'Invalid reader stream wrapper',
InvalidArgumentException::INVALID_READER_STREAM_WRAPPER
Expand Down
38 changes: 19 additions & 19 deletions src/Resource/Tests/FactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,41 +102,41 @@ class FactoryTest extends AbstractTest
*
* @var string
*/
const TXT_FILE = __DIR__ . DIRECTORY_SEPARATOR . 'Fixture' . DIRECTORY_SEPARATOR . 'cc0.txt';
const TXT_FILE = __DIR__.DIRECTORY_SEPARATOR.'Fixture'.DIRECTORY_SEPARATOR.'cc0.txt';

/**
* Example JSON file
*
* @var string
*/
const JSON_FILE = __DIR__ . DIRECTORY_SEPARATOR . 'Fixture' . DIRECTORY_SEPARATOR . 'invoice.json';
const JSON_FILE = __DIR__.DIRECTORY_SEPARATOR.'Fixture'.DIRECTORY_SEPARATOR.'invoice.json';

/**
* Example YAML file
*
* @var string
*/
const YAML_FILE = __DIR__ . DIRECTORY_SEPARATOR . 'Fixture' . DIRECTORY_SEPARATOR . 'invoice.yaml';
const YAML_FILE = __DIR__.DIRECTORY_SEPARATOR.'Fixture'.DIRECTORY_SEPARATOR.'invoice.yaml';

/**
* Example CommonMark file
*
* @var string
*/
const COMMONMARK_FILE = __DIR__ . DIRECTORY_SEPARATOR . 'Fixture' . DIRECTORY_SEPARATOR . 'commonmark.md';
const COMMONMARK_FILE = __DIR__.DIRECTORY_SEPARATOR.'Fixture'.DIRECTORY_SEPARATOR.'commonmark.md';

/**
* Example FrontMark file with YAML front matter
*
* @var string
*/
const YAML_FRONTMARK_FILE = __DIR__ . DIRECTORY_SEPARATOR . 'Fixture' . DIRECTORY_SEPARATOR . 'yaml-frontmark.md';
const YAML_FRONTMARK_FILE = __DIR__.DIRECTORY_SEPARATOR.'Fixture'.DIRECTORY_SEPARATOR.'yaml-frontmark.md';
/**
* Example FrontMark file with JSON front matter
*
* @var string
*/
const JSON_FRONTMARK_FILE = __DIR__ . DIRECTORY_SEPARATOR . 'Fixture' . DIRECTORY_SEPARATOR . 'json-frontmark.md';
const JSON_FRONTMARK_FILE = __DIR__.DIRECTORY_SEPARATOR.'Fixture'.DIRECTORY_SEPARATOR.'json-frontmark.md';

/**
* Sets up the fixture
Expand Down Expand Up @@ -169,7 +169,7 @@ public function testTextFactoryStringReader()
*/
public function testTextFactoryFileReader()
{
$textResource = Resource::text('file://' . self::TXT_FILE);
$textResource = Resource::text('file://'.self::TXT_FILE);
$this->assertInstanceOf(TextResource::class, $textResource);
$this->assertEquals($this->text, $textResource->get());
}
Expand All @@ -182,7 +182,7 @@ public function testTextFactoryFileReader()
*/
public function testTextFactoryInvalidReader()
{
Resource::text('foo://' . self::TXT_FILE);
Resource::text('foo://'.self::TXT_FILE);
}

/**
Expand All @@ -204,7 +204,7 @@ public function testTextFactoryFileWriter()
{
$tempFileName = $this->createTemporaryFileName();
$textResource = Resource::text($this->text);
$writer = $textResource->toTarget('file://' . $tempFileName, FileWriter::FILE_CREATE);
$writer = $textResource->toTarget('file://'.$tempFileName, FileWriter::FILE_CREATE);
$this->assertInstanceOf(FileWriter::class, $writer);
$this->assertStringEqualsFile($tempFileName, $this->text);
}
Expand All @@ -217,15 +217,15 @@ public function testTextFactoryFileWriter()
*/
public function testTextFactoryInvalidWriter()
{
Resource::text($this->text)->toTarget('foo://' . $this->createTemporaryFileName());
Resource::text($this->text)->toTarget('foo://'.$this->createTemporaryFileName());
}

/**
* Test the JSON resource factory with a file path input (file reader)
*/
public function testJsonFactoryFileReader()
{
$jsonResource = Resource::json('file://' . self::JSON_FILE);
$jsonResource = Resource::json('file://'.self::JSON_FILE);
$this->assertInstanceOf(JsonResource::class, $jsonResource);
$this->assertEquals($this->json, $jsonResource->get());
}
Expand All @@ -235,7 +235,7 @@ public function testJsonFactoryFileReader()
*/
public function testYamlFactoryFileReader()
{
$yamlResource = Resource::yaml('file://' . self::YAML_FILE);
$yamlResource = Resource::yaml('file://'.self::YAML_FILE);
$this->assertInstanceOf(YamlResource::class, $yamlResource);
$this->assertEquals($this->yaml, $yamlResource->get());
}
Expand All @@ -245,7 +245,7 @@ public function testYamlFactoryFileReader()
*/
public function testCommonMarkFactoryFileReader()
{
$commonMarkResource = Resource::commonMark('file://' . self::COMMONMARK_FILE);
$commonMarkResource = Resource::commonMark('file://'.self::COMMONMARK_FILE);
$this->assertInstanceOf(CommonMarkResource::class, $commonMarkResource);
$this->assertEquals($this->commonMark, $commonMarkResource->get());
}
Expand All @@ -255,18 +255,18 @@ public function testCommonMarkFactoryFileReader()
*/
public function testYamlFrontMarkFactoryFileReader()
{
$yamlFrontMarkResource = Resource::frontMark('file://' . self::YAML_FRONTMARK_FILE);
$this->assertInstanceOf(FrontMarkResource::class, $yamlFrontMarkResource);
$this->assertEquals($this->yamlFrontMark, strval($yamlFrontMarkResource));
$yamlFMResource = Resource::frontMark('file://'.self::YAML_FRONTMARK_FILE);
$this->assertInstanceOf(FrontMarkResource::class, $yamlFMResource);
$this->assertEquals($this->yamlFrontMark, strval($yamlFMResource));
}

/**
* Test the JSON FrontMark resource factory with a file path input (file reader)
*/
public function testJsonFrontMarkFactoryFileReader()
{
$jsonFrontMarkResource = Resource::frontMark('file://' . self::JSON_FRONTMARK_FILE);
$this->assertInstanceOf(FrontMarkResource::class, $jsonFrontMarkResource);
$this->assertEquals($this->jsonFrontMark, strval($jsonFrontMarkResource));
$jsonFMResource = Resource::frontMark('file://'.self::JSON_FRONTMARK_FILE);
$this->assertInstanceOf(FrontMarkResource::class, $jsonFMResource);
$this->assertEquals($this->jsonFrontMark, strval($jsonFMResource));
}
}
5 changes: 3 additions & 2 deletions src/Resource/Tests/FileIoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,9 @@ public function testFileWriterWithRecursiveDirectoryCreation()
$tempFile = $this->createTemporaryFile();
unlink($tempFile);
$this->tmpFiles[] = $tempFile .= DIRECTORY_SEPARATOR.'recursive.txt';
$textResource->dump(Kernel::create(Writer::class,
[$tempFile, Writer::FILE_CREATE | Writer::FILE_CREATE_DIRS]));
$textResource->dump(
Kernel::create(Writer::class, [$tempFile, Writer::FILE_CREATE | Writer::FILE_CREATE_DIRS])
);
$this->assertFileEquals(self::TXT_FILE, $tempFile);
}

Expand Down
3 changes: 2 additions & 1 deletion src/Resource/Tests/FrontMarkResourceMock.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ public function invalidateCommonMarkPart()
*
* @return PartSequence Sequence aggregate
*/
public function getSequence() {
public function getSequence()
{
return $this->part();
}
}

0 comments on commit dc2a840

Please sign in to comment.