File tree Expand file tree Collapse file tree 9 files changed +45
-25
lines changed Expand file tree Collapse file tree 9 files changed +45
-25
lines changed Original file line number Diff line number Diff line change 6
6
"require" : {
7
7
"php" : " >7.3 <9.0" ,
8
8
"ext-json" : " *" ,
9
- "getdkan/contracts" : " ^1.1.3" ,
10
9
"guzzlehttp/guzzle" : " ^6.5.8 || >7.4.5" ,
11
10
"opis/json-schema" : " ^1.0.8"
12
11
},
13
12
"require-dev" : {
13
+ "getdkan/contracts" : " ^1.2" ,
14
14
"phpunit/phpunit" : " ^9.6" ,
15
- "rector/rector" : " ^0.15.19 " ,
15
+ "rector/rector" : " ^1@stable " ,
16
16
"squizlabs/php_codesniffer" : " ^3.7" ,
17
17
"symfony/phpunit-bridge" : " ^7.0"
18
18
},
Original file line number Diff line number Diff line change 6
6
use Rector \DeadCode \Rector \ClassMethod \RemoveUselessParamTagRector ;
7
7
use Rector \DeadCode \Rector \ClassMethod \RemoveUselessReturnTagRector ;
8
8
use Rector \DeadCode \Rector \Property \RemoveUselessVarTagRector ;
9
- use Rector \Php73 \Rector \FuncCall \JsonThrowOnErrorRector ;
10
9
use Rector \Set \ValueObject \SetList ;
11
10
use Rector \TypeDeclaration \Rector \ClassMethod \AddMethodCallBasedStrictParamTypeRector ;
12
- use Rector \TypeDeclaration \Rector \ClassMethod \ArrayShapeFromConstantArrayReturnRector ;
13
11
14
12
return static function (RectorConfig $ rectorConfig ): void {
15
13
$ rectorConfig ->paths ([
16
14
__DIR__ . '/src ' ,
17
15
__DIR__ . '/test ' ,
18
- __DIR__ . 'rector.php ' ,
16
+ __DIR__ . '/ rector.php ' ,
19
17
]);
20
18
21
19
$ rectorConfig ->sets ([
27
25
]);
28
26
29
27
$ rectorConfig ->skip ([
30
- // Don't throw errors on JSON parse problems. Yet.
31
- // @todo Throw errors and deal with them appropriately.
32
- JsonThrowOnErrorRector::class,
33
28
// We like our tags. Please don't remove them.
34
29
RemoveUselessParamTagRector::class,
35
30
RemoveUselessReturnTagRector::class,
36
31
RemoveUselessVarTagRector::class,
37
- ArrayShapeFromConstantArrayReturnRector::class,
38
32
AddMethodCallBasedStrictParamTypeRector::class,
39
33
]);
40
34
Original file line number Diff line number Diff line change 2
2
3
3
namespace Harvest \ETL ;
4
4
5
- use Opis \JsonSchema \Validator ;
6
5
use Opis \JsonSchema \Schema ;
6
+ use Opis \JsonSchema \Validator ;
7
7
8
8
class Factory
9
9
{
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ public function __construct(
24
24
$ this ->itemStorage = $ item_storage ;
25
25
}
26
26
27
- public function run ($ item )
27
+ public function run ($ item ): int
28
28
{
29
29
30
30
$ state = $ this ->itemState ($ item );
@@ -42,7 +42,7 @@ public function run($item)
42
42
return $ state ;
43
43
}
44
44
45
- private function itemState ($ item )
45
+ private function itemState ($ item ): int
46
46
{
47
47
if (isset ($ item ->identifier )) {
48
48
$ identifier = Util::getDatasetId ($ item );
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ public function __construct(Factory $factory)
17
17
$ this ->factory = $ factory ;
18
18
}
19
19
20
- public function revert ()
20
+ public function revert (): int
21
21
{
22
22
$ ids = $ this ->factory ->hashStorage ->retrieveAll ();
23
23
$ load = $ this ->factory ->get ("load " );
@@ -36,7 +36,7 @@ public function revert()
36
36
return $ counter ;
37
37
}
38
38
39
- public function harvest ()
39
+ public function harvest (): array
40
40
{
41
41
$ result = [];
42
42
$ transformers = null ;
Original file line number Diff line number Diff line change @@ -11,17 +11,17 @@ public function __construct(array $result)
11
11
$ this ->result = $ result ;
12
12
}
13
13
14
- public function countCreated ()
14
+ public function countCreated (): int
15
15
{
16
16
return $ this ->loadCount ("NEW " );
17
17
}
18
18
19
- public function countUpdated ()
19
+ public function countUpdated (): int
20
20
{
21
21
return $ this ->loadCount ("UPDATED " );
22
22
}
23
23
24
- public function countFailed ()
24
+ public function countFailed (): int
25
25
{
26
26
$ load_failures = $ this ->loadCount ("FAILURE " );
27
27
$ transform_failures = $ this ->transformFailures ();
@@ -48,7 +48,7 @@ public function countProcessed(): int
48
48
return count ($ ids );
49
49
}
50
50
51
- private function loadCount (string $ status )
51
+ private function loadCount (string $ status ): int
52
52
{
53
53
$ count = 0 ;
54
54
if (!isset ($ this ->result ['status ' ]['load ' ])) {
@@ -64,7 +64,7 @@ private function loadCount(string $status)
64
64
return $ count ;
65
65
}
66
66
67
- private function transformFailures ()
67
+ private function transformFailures (): int
68
68
{
69
69
$ count = 0 ;
70
70
Original file line number Diff line number Diff line change 2
2
3
3
namespace Harvest \Storage ;
4
4
5
- use Contracts \ BulkRetrieverInterface ;
6
- use Contracts \ StorerInterface ;
7
-
8
- interface StorageInterface extends StorerInterface, BulkRetrieverInterface
5
+ /**
6
+ * Interface for harvest storage.
7
+ */
8
+ interface StorageInterface
9
9
{
10
+ /**
11
+ * Store data with an identifier.
12
+ *
13
+ * @param mixed $data
14
+ * The data to be stored.
15
+ * @param string|null $id
16
+ * The identifier for the data. If the act of storing generates the
17
+ * id, there is no need to pass one.
18
+ *
19
+ * @return string
20
+ * The identifier.
21
+ *
22
+ * @throws \Exception
23
+ * Issues storing the data.
24
+ */
25
+ public function store ($ data , string $ id = null ): string ;
10
26
27
+ /**
28
+ * Retrieve all.
29
+ *
30
+ * @return array
31
+ * An array of ids.
32
+ */
33
+ public function retrieveAll (): array ;
11
34
}
Original file line number Diff line number Diff line change 2
2
3
3
namespace HarvestTest ;
4
4
5
+ use GuzzleHttp \Client ;
6
+ use GuzzleHttp \Psr7 \Response ;
5
7
use PHPUnit \Framework \TestCase ;
6
8
use Harvest \ResultInterpreter ;
7
9
use Harvest \ETL \Factory ;
@@ -35,9 +37,9 @@ public function testBasic(string $uri): void
35
37
$ item_store = new MemStore ();
36
38
$ hash_store = new MemStore ();
37
39
38
- $ mock_client = $ this ->createMock (\ GuzzleHttp \ Client::class);
40
+ $ mock_client = $ this ->createMock (Client::class);
39
41
$ mock_client ->method ('request ' )->willReturn (
40
- new \ GuzzleHttp \ Psr7 \ Response (
42
+ new Response (
41
43
200 ,
42
44
[],
43
45
file_get_contents (__DIR__ . "/json/data3.json " )
Original file line number Diff line number Diff line change 4
4
5
5
use PHPUnit \Framework \TestCase ;
6
6
use Harvest \Util ;
7
+
7
8
class UtilTest extends TestCase
8
9
{
9
10
public function test (): void
You can’t perform that action at this time.
0 commit comments