Debian Codegraph @

lib/3rdParty/composer/symfony/http-client/Internal/Canary.php

raw symbols SCIP
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <[email protected]>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Symfony\Component\HttpClient\Internal;
13
14 /**
15 * @author Nicolas Grekas <[email protected]>
16 *
17 * @internal
18 */
19 final class Canary
20 {
21 public function __construct(
22 private \Closure $canceller,
23 ) {
24 }
25
26 public function cancel(): void
27 {
28 if (isset($this->canceller)) {
29 $canceller = $this->canceller;
30 unset($this->canceller);
31 $canceller();
32 }
33 }
34
35 public function __destruct()
36 {
37 $this->cancel();
38 }
39 }