Skip to content

Commit ce13a53

Browse files
authored
Sync clock (#863)
1 parent 06f8456 commit ce13a53

File tree

4 files changed

+416
-127
lines changed

4 files changed

+416
-127
lines changed

exercises/practice/clock/.meta/config.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,5 @@
2222
]
2323
},
2424
"blurb": "Implement a clock that handles times without dates.",
25-
"source": "Pairing session with Erin Drummond",
26-
"source_url": "https://twitter.com/ebdrummond"
25+
"source": "Pairing session with Erin Drummond"
2726
}

exercises/practice/clock/.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
class Clock

exercises/practice/clock/Clock.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,17 @@
2626

2727
class Clock
2828
{
29+
/**
30+
* This class implements PHP's magic method __toString().
31+
*
32+
* By implementing this method, the class adheres to the `Stringable` interface.
33+
* When an object of this class is used in string context (e.g., echo or string cast),
34+
* this method is automatically called.
35+
*
36+
* More on `Stringable`: https://www.php.net/manual/en/class.stringable.php
37+
*
38+
* @return string The string representation of the Clock object
39+
*/
2940
public function __toString(): string
3041
{
3142
throw new \BadMethodCallException("Implement the __toString function");

0 commit comments

Comments
 (0)