Skip to content

Commit eff9156

Browse files
committed
snake case to camelcase
Signed-off-by: rahul <[email protected]>
2 parents af32a4c + 75487eb commit eff9156

File tree

6 files changed

+40
-30
lines changed

6 files changed

+40
-30
lines changed

src/Exception/CouldNotWriteFileException.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22

33
namespace rcsofttech85\FileHandler\Exception;
44

5-
class CouldNotWriteFileException extends \Exception
5+
use Exception;
6+
use Throwable;
7+
8+
class CouldNotWriteFileException extends Exception
69
{
7-
public function __construct($message = "Error writing to file", $code = 0, \Throwable $previous = null) {
10+
public function __construct($message = "Error writing to file", $code = 0, Throwable $previous = null)
11+
{
812
parent::__construct($message, $code, $previous);
913
}
10-
}
14+
}

src/Exception/FileNotClosedException.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22

33
namespace rcsofttech85\FileHandler\Exception;
44

5-
class FileNotClosedException extends \Exception
6-
{
5+
use Exception;
6+
use Throwable;
77

8-
public function __construct($message = "Failed to close file", $code = 0, \Throwable $previous = null) {
8+
class FileNotClosedException extends Exception
9+
{
10+
public function __construct($message = "Failed to close file", $code = 0, Throwable $previous = null)
11+
{
912
parent::__construct($message, $code, $previous);
1013
}
11-
}
14+
}

src/Exception/FileNotFoundException.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22

33
namespace rcsofttech85\FileHandler\Exception;
44

5-
class FileNotFoundException extends \Exception
6-
{
5+
use Exception;
6+
use Throwable;
77

8-
public function __construct($message = "File not found", $code = 0, \Throwable $previous = null) {
8+
class FileNotFoundException extends Exception
9+
{
10+
public function __construct($message = "File not found", $code = 0, Throwable $previous = null)
11+
{
912
parent::__construct($message, $code, $previous);
1013
}
11-
}
14+
}

src/Exception/InvalidFileException.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77

88
class InvalidFileException extends Exception
99
{
10-
1110
public function __construct($message = "invalid file format", $code = 0, Throwable $previous = null)
1211
{
1312
parent::__construct($message, $code, $previous);
1413
}
15-
}
14+
}

tests/bootstrap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<?php
22

3-
require dirname(__DIR__).'/vendor/autoload.php';
3+
require dirname(__DIR__) . '/vendor/autoload.php';

tests/FileHandlerTest.php renamed to tests/unit/FileHandlerTest.php

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
<?php
22

3+
namespace unit;
4+
35
use PHPUnit\Framework\Attributes\DataProvider;
46
use PHPUnit\Framework\Attributes\Test;
57
use PHPUnit\Framework\Attributes\TestDox;
68
use PHPUnit\Framework\TestCase;
79
use rcsofttech85\FileHandler\Exception\CouldNotWriteFileException;
810
use rcsofttech85\FileHandler\Exception\FileNotFoundException;
911
use rcsofttech85\FileHandler\FileHandler;
12+
use TypeError;
1013

1114
class FileHandlerTest extends TestCase
1215
{
13-
1416
private FileHandler|null $fileHandler;
1517

1618
protected function setUp(): void
@@ -31,7 +33,7 @@ protected function tearDown(): void
3133

3234

3335
#[Test]
34-
public function file_successfully_written()
36+
public function fileSuccessfullyWritten()
3537
{
3638
$this->fileHandler->open(filename: 'file');
3739

@@ -41,15 +43,15 @@ public function file_successfully_written()
4143
}
4244

4345
#[Test]
44-
public function should_throw_exception_if_file_is_not_Found()
46+
public function shouldThrowExceptionIfFileIsNotFound()
4547
{
4648
$this->expectException(FileNotFoundException::class);
4749
$this->expectExceptionMessage('File not found');
4850
$this->fileHandler->open(filename: 'unknown');
4951
}
5052

5153
#[Test]
52-
public function should_throw_exception_if_file_is_not_writable()
54+
public function shouldThrowExceptionIfFileIsNotWritable()
5355
{
5456
$this->fileHandler->open(filename: 'file', mode: 'r');
5557

@@ -59,7 +61,7 @@ public function should_throw_exception_if_file_is_not_writable()
5961
}
6062

6163
#[Test]
62-
public function multiple_file_can_be_written_simultaneously()
64+
public function multipleFileCanBeWrittenSimultaneously()
6365
{
6466
$this->fileHandler->open(filename: 'file');
6567

@@ -76,7 +78,7 @@ public function multiple_file_can_be_written_simultaneously()
7678

7779

7880
#[Test]
79-
public function file_is_closed_properly()
81+
public function fileIsClosedProperly()
8082
{
8183
$this->fileHandler->open(filename: 'file');
8284
$this->fileHandler->write(data: "hello world");
@@ -87,9 +89,9 @@ public function file_is_closed_properly()
8789
}
8890

8991
#[Test]
90-
#[DataProvider('provide_movie_names')]
92+
#[DataProvider('provideMovieNames')]
9193
#[TestDox('search result with name $keyword exists in file.')]
92-
public function result_found_for_exact_name_match(string $keyword)
94+
public function resultFoundForExactNameMatch(string $keyword)
9395
{
9496
$isMovieAvailable = $this->fileHandler->open(filename: 'movie.csv')->searchInCsvFile(
9597
keyword: $keyword,
@@ -99,9 +101,9 @@ public function result_found_for_exact_name_match(string $keyword)
99101
}
100102

101103
#[Test]
102-
#[DataProvider('provide_studio_names')]
104+
#[DataProvider('provideStudioNames')]
103105
#[TestDox('search result with name $keyword exists in file.')]
104-
public function studio_is_found_for_exact_name_match(string $keyword)
106+
public function studioIsFoundForExactNameMatch(string $keyword)
105107
{
106108
$isStudioFound = $this->fileHandler->open(filename: 'movie.csv')->searchInCsvFile(
107109
keyword: $keyword,
@@ -111,7 +113,7 @@ public function studio_is_found_for_exact_name_match(string $keyword)
111113
}
112114

113115
#[Test]
114-
public function to_array_method_returns_valid_array()
116+
public function toArrayMethodReturnsValidArray()
115117
{
116118
$data = $this->fileHandler->open(filename: 'movie.csv')->toArray();
117119
$expected = [
@@ -130,7 +132,7 @@ public function to_array_method_returns_valid_array()
130132
}
131133

132134
#[Test]
133-
public function search_by_keyword_and_return_array()
135+
public function searchByKeywordAndReturnArray()
134136
{
135137
$expected = [
136138
'Film' => 'Zack and Miri Make a Porno',
@@ -153,19 +155,18 @@ public function search_by_keyword_and_return_array()
153155
$this->assertEquals($expected, $data);
154156
}
155157

156-
public static function provide_studio_names(): iterable
158+
public static function provideStudioNames(): iterable
157159
{
158160
yield ["Fox"];
159161
yield ["Universal"];
160162
yield ["Warner Bros."];
161163
}
162164

163165

164-
public static function provide_movie_names(): iterable
166+
public static function provideMovieNames(): iterable
165167
{
166168
yield ["The Ugly Truth"];
167169
yield ["Leap Year"];
168170
yield ["Twilight"];
169171
}
170-
171-
}
172+
}

0 commit comments

Comments
 (0)