You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			37 lines
		
	
	
		
			838 B
		
	
	
	
		
			PHP
		
	
			
		
		
	
	
			37 lines
		
	
	
		
			838 B
		
	
	
	
		
			PHP
		
	
| <?php
 | |
| /** @noinspection PhpIllegalPsrClassPathInspection */
 | |
| 
 | |
| use jrosset\Collections\Collection;
 | |
| 
 | |
| require_once __DIR__ . '/../vendor/autoload.php';
 | |
| 
 | |
| class Measure {
 | |
|     private int    $value;
 | |
|     private string $unit;
 | |
| 
 | |
|     public function __construct (int $value, string $unit = 's') {
 | |
|         $this->value = $value;
 | |
|         $this->unit = $unit;
 | |
|     }
 | |
| 
 | |
|     public function asString (): string {
 | |
|         return $this->value . $this->unit;
 | |
|     }
 | |
| }
 | |
| 
 | |
| /**
 | |
|  * @return Collection<int, Measure>
 | |
|  */
 | |
| function getMeasures (): Collection {
 | |
|     $measures = new Collection();
 | |
|     $measures->add(new Measure(38));
 | |
|     $measures->add(new Measure(27));
 | |
|     $measures->add(new Measure(34));
 | |
| 
 | |
|     return $measures;
 | |
| }
 | |
| 
 | |
| echo 'Measures :' . PHP_EOL;
 | |
| foreach (getMeasures() as $no => $measure) {
 | |
|     echo "\t#" . $no . ' = ' . $measure->asString() . PHP_EOL;
 | |
| } |