Last active
April 3, 2025 01:09
-
-
Save terremoth/1241bdf3a66b9a31ec319145b6d9ba47 to your computer and use it in GitHub Desktop.
Exemplo de lista de compras para discussão thread safe, parallel programming
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| class CarrinhoDeCompras | |
| { | |
| private $lista = []; | |
| public function add(mixed $item): static | |
| { | |
| $this->lista[] = $item; | |
| return $this; | |
| } | |
| public function remove(mixed $index): void | |
| { | |
| unset($this->lista[$index]); | |
| return $this; | |
| } | |
| public function countItems(): int | |
| { | |
| return count($this->lista); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment