Skip to content

Instantly share code, notes, and snippets.

@terremoth
Last active April 3, 2025 01:09
Show Gist options
  • Select an option

  • Save terremoth/1241bdf3a66b9a31ec319145b6d9ba47 to your computer and use it in GitHub Desktop.

Select an option

Save terremoth/1241bdf3a66b9a31ec319145b6d9ba47 to your computer and use it in GitHub Desktop.
Exemplo de lista de compras para discussão thread safe, parallel programming
<?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