PluginProbe
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF / trunk
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF vtrunk
2.3.4 2.3.3 2.3.2 2.3.1 2.3.0 2.2.9 2.2.8 trunk 1.10 1.3.3 1.3.4 1.3.5 1.3.5.1 1.3.5.2 1.3.6 1.3.6.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.5 All 103 releases
imagify / vendor / league / container / src / ContainerAwareTrait.php

ContainerAwareTrait.php in Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF trunk, at vendor/league/container/src/ContainerAwareTrait.php

41 lines 1.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 namespace Imagify\Dependencies\League\Container;
6
7 use BadMethodCallException;
8 use Imagify\Dependencies\League\Container\Exception\ContainerException;
9
10 trait ContainerAwareTrait
11 {
12 /**
13 * @var ?DefinitionContainerInterface
14 */
15 protected $container;
16
17 public function setContainer(DefinitionContainerInterface $container): ContainerAwareInterface
18 {
19 $this->container = $container;
20
21 if ($this instanceof ContainerAwareInterface) {
22 return $this;
23 }
24
25 throw new BadMethodCallException(sprintf(
26 'Attempt to use (%s) while not implementing (%s)',
27 ContainerAwareTrait::class,
28 ContainerAwareInterface::class
29 ));
30 }
31
32 public function getContainer(): DefinitionContainerInterface
33 {
34 if ($this->container instanceof DefinitionContainerInterface) {
35 return $this->container;
36 }
37
38 throw new ContainerException('No container implementation has been set.');
39 }
40 }
41