Skip to content

Commit

Permalink
Sync clock (#863)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasnorre authored Dec 21, 2024
1 parent 06f8456 commit ce13a53
Show file tree
Hide file tree
Showing 4 changed files with 416 additions and 127 deletions.
3 changes: 1 addition & 2 deletions exercises/practice/clock/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,5 @@
]
},
"blurb": "Implement a clock that handles times without dates.",
"source": "Pairing session with Erin Drummond",
"source_url": "https://twitter.com/ebdrummond"
"source": "Pairing session with Erin Drummond"
}
22 changes: 0 additions & 22 deletions exercises/practice/clock/.meta/example.php
Original file line number Diff line number Diff line change
@@ -1,27 +1,5 @@
<?php

/*
* By adding type hints and enabling strict type checking, code can become
* easier to read, self-documenting and reduce the number of potential bugs.
* By default, type declarations are non-strict, which means they will attempt
* to change the original type to match the type specified by the
* type-declaration.
*
* In other words, if you pass a string to a function requiring a float,
* it will attempt to convert the string value to a float.
*
* To enable strict mode, a single declare directive must be placed at the top
* of the file.
* This means that the strictness of typing is configured on a per-file basis.
* This directive not only affects the type declarations of parameters, but also
* a function's return type.
*
* For more info review the Concept on strict type checking in the PHP track
* <link>.
*
* To disable strict typing, comment out the directive below.
*/

declare(strict_types=1);

class Clock
Expand Down
11 changes: 11 additions & 0 deletions exercises/practice/clock/Clock.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@

class Clock
{
/**
* This class implements PHP's magic method __toString().
*
* By implementing this method, the class adheres to the `Stringable` interface.
* When an object of this class is used in string context (e.g., echo or string cast),
* this method is automatically called.
*
* More on `Stringable`: https://www.php.net/manual/en/class.stringable.php
*
* @return string The string representation of the Clock object
*/
public function __toString(): string
{
throw new \BadMethodCallException("Implement the __toString function");
Expand Down
Loading

0 comments on commit ce13a53

Please sign in to comment.