Skip to content

Commit ee39b8c

Browse files
authored
Sync etl (#868)
[no important files changed]
1 parent ce13a53 commit ee39b8c

File tree

3 files changed

+28
-56
lines changed

3 files changed

+28
-56
lines changed

exercises/practice/etl/.meta/config.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
".meta/example.php"
2020
]
2121
},
22-
"blurb": "We are going to do the `Transform` step of an Extract-Transform-Load.",
23-
"source": "The Jumpstart Lab team",
24-
"source_url": "https://jumpstartlab.com"
22+
"blurb": "Change the data format for scoring a game to more easily add other languages.",
23+
"source": "Based on an exercise by the JumpstartLab team for students at The Turing School of Software and Design.",
24+
"source_url": "https://turing.edu"
2525
}

exercises/practice/etl/.meta/example.php

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,5 @@
11
<?php
22

3-
/*
4-
* By adding type hints and enabling strict type checking, code can become
5-
* easier to read, self-documenting and reduce the number of potential bugs.
6-
* By default, type declarations are non-strict, which means they will attempt
7-
* to change the original type to match the type specified by the
8-
* type-declaration.
9-
*
10-
* In other words, if you pass a string to a function requiring a float,
11-
* it will attempt to convert the string value to a float.
12-
*
13-
* To enable strict mode, a single declare directive must be placed at the top
14-
* of the file.
15-
* This means that the strictness of typing is configured on a per-file basis.
16-
* This directive not only affects the type declarations of parameters, but also
17-
* a function's return type.
18-
*
19-
* For more info review the Concept on strict type checking in the PHP track
20-
* <link>.
21-
*
22-
* To disable strict typing, comment out the directive below.
23-
*/
24-
253
declare(strict_types=1);
264

275
function transform($old)

exercises/practice/etl/EtlTest.php

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,5 @@
11
<?php
22

3-
/*
4-
* By adding type hints and enabling strict type checking, code can become
5-
* easier to read, self-documenting and reduce the number of potential bugs.
6-
* By default, type declarations are non-strict, which means they will attempt
7-
* to change the original type to match the type specified by the
8-
* type-declaration.
9-
*
10-
* In other words, if you pass a string to a function requiring a float,
11-
* it will attempt to convert the string value to a float.
12-
*
13-
* To enable strict mode, a single declare directive must be placed at the top
14-
* of the file.
15-
* This means that the strictness of typing is configured on a per-file basis.
16-
* This directive not only affects the type declarations of parameters, but also
17-
* a function's return type.
18-
*
19-
* For more info review the Concept on strict type checking in the PHP track
20-
* <link>.
21-
*
22-
* To disable strict typing, comment out the directive below.
23-
*/
24-
253
declare(strict_types=1);
264

275
class EtlTest extends PHPUnit\Framework\TestCase
@@ -31,37 +9,53 @@ public static function setUpBeforeClass(): void
319
require_once 'Etl.php';
3210
}
3311

12+
/**
13+
* uuid 78a7a9f9-4490-4a47-8ee9-5a38bb47d28f
14+
* @testdox single letter
15+
*/
3416
public function testTransformOneValue(): void
3517
{
3618
$old = ['1' => ['A']];
3719
$expected = ['a' => 1];
3820
$this->assertEquals($expected, transform($old));
3921
}
4022

23+
/**
24+
* uuid 60dbd000-451d-44c7-bdbb-97c73ac1f497
25+
* @testdox single score with multiple letters
26+
*/
4127
public function testTransformMoreValues(): void
4228
{
43-
$old = ['1' => str_split('AEIOU')];
29+
$old = [1 => ['A', 'E', 'I', 'O', 'U']];
4430
$expected = ['a' => 1, 'e' => 1, 'i' => 1, 'o' => 1, 'u' => 1];
4531
$this->assertEquals($expected, transform($old));
4632
}
4733

34+
/**
35+
* uuid f5c5de0c-301f-4fdd-a0e5-df97d4214f54
36+
* @testdox multiple scores with multiple letters
37+
*/
4838
public function testTransformMoreKeys(): void
4939
{
50-
$old = ['1' => str_split('AE'), '2' => str_split('DG')];
40+
$old = [1 => ['A', 'E'], 2 => ['D', 'G']];
5141
$expected = ['a' => 1, 'e' => 1, 'd' => 2, 'g' => 2];
5242
$this->assertEquals($expected, transform($old));
5343
}
5444

45+
/**
46+
* uuid 5db8ea89-ecb4-4dcd-902f-2b418cc87b9d
47+
* @testdox multiple scores with differing numbers of letters
48+
*/
5549
public function testTransformFullDataset(): void
5650
{
5751
$old = [
58-
'1' => str_split('AEIOULNRST'),
59-
'2' => str_split('DG'),
60-
'3' => str_split('BCMP'),
61-
'4' => str_split('FHVWY'),
62-
'5' => str_split('K'),
63-
'8' => str_split('JX'),
64-
'10' => str_split('QZ'),
52+
1 => ['A', 'E', 'I', 'O', 'U', 'L', 'N', 'R', 'S', 'T'],
53+
2 => ['D', 'G'],
54+
3 => ['B', 'C', 'M', 'P'],
55+
4 => ['F', 'H', 'V', 'W', 'Y'],
56+
5 => ['K'],
57+
8 => ['J', 'X'],
58+
10 => ['Q', 'Z'],
6559
];
6660
$expected = [
6761
'a' => 1, 'b' => 3, 'c' => 3, 'd' => 2, 'e' => 1,

0 commit comments

Comments
 (0)