| Conditions | 6 |
| Paths | 6 |
| Total Lines | 20 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 23 | public static function createPersistentDataHandler($handler) |
||
| 24 | { |
||
| 25 | if (!$handler) { |
||
| 26 | return session_status() === PHP_SESSION_ACTIVE |
||
| 27 | ? new InstagramSessionPersistentDataHandler() |
||
| 28 | : new InstagramMemoryPersistentDataHandler(); |
||
| 29 | } |
||
| 30 | |||
| 31 | if ($handler instanceof PersistentDataInterface) { |
||
| 32 | return $handler; |
||
| 33 | } |
||
| 34 | |||
| 35 | if ('session' === $handler) { |
||
| 36 | return new InstagramSessionPersistentDataHandler(); |
||
| 37 | } |
||
| 38 | if ('memory' === $handler) { |
||
| 39 | return new InstagramMemoryPersistentDataHandler(); |
||
| 40 | } |
||
| 41 | |||
| 42 | throw new InvalidArgumentException('The persistent data handler must be set to "session", "memory", or be an instance of Instagram\PersistentData\PersistentDataInterface'); |
||
| 43 | } |
||
| 45 |