| Total Complexity | 6 |
| Total Lines | 60 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | class Space extends AbstractFfi |
||
| 10 | { |
||
| 11 | private Vector $gravity; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * Will get the reference on the first Space::getStaticBody() call, then |
||
| 15 | * will always return the same instance |
||
| 16 | */ |
||
| 17 | private ?Body $staticBody = null; |
||
| 18 | |||
| 19 | public function __construct() |
||
| 20 | { |
||
| 21 | parent::__construct(); |
||
| 22 | |||
| 23 | $this->setCData($this->getFfi()->cpSpaceNew()); |
||
|
|
|||
| 24 | } |
||
| 25 | |||
| 26 | public function setGravity(Vector $gravity) |
||
| 27 | { |
||
| 28 | $this->gravity = $gravity; |
||
| 29 | |||
| 30 | $this->getFfi()->cpSpaceSetGravity($this->getCData(), $this->gravity->getCData()); |
||
| 31 | } |
||
| 32 | |||
| 33 | /** |
||
| 34 | * The Space provided static body for a given cpSpace. |
||
| 35 | * This is merely provided for convenience and you are not required to use it. |
||
| 36 | */ |
||
| 37 | public function getStaticBody(): Body |
||
| 38 | { |
||
| 39 | if (null === $this->staticBody) { |
||
| 40 | $this->setStaticBody(Body::fromSpace($this)); |
||
| 41 | } |
||
| 42 | |||
| 43 | return $this->staticBody; |
||
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
| 47 | * Should be called only in the constructor |
||
| 48 | * |
||
| 49 | * @todo Check Chipmunk's way to handle setting a new static body |
||
| 50 | * @throws LogicException |
||
| 51 | */ |
||
| 52 | public function setStaticBody(Body $staticBody): self |
||
| 53 | { |
||
| 54 | // TODO |
||
| 55 | // if (null !== $this->staticBody) { |
||
| 56 | // throw new LogicException("Attempted to replace an already initialized Space's body"); |
||
| 57 | // } |
||
| 58 | |||
| 59 | $this->staticBody = $staticBody; |
||
| 60 | |||
| 61 | return $this; |
||
| 62 | } |
||
| 63 | |||
| 64 | public function addShape(Shape $shape): self |
||
| 69 | } |
||
| 70 | } |
||
| 71 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.