• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

janu-software / facebook-php-sdk / 13285164661

12 Feb 2025 12:17PM UTC coverage: 93.359%. Remained the same
13285164661

push

github

stanislav-janu
php 8.1 lock file

956 of 1024 relevant lines covered (93.36%)

11.45 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

75.0
/src/PersistentData/PersistentDataFactory.php
1
<?php
2

3
declare(strict_types=1);
4
/**
5
 * Copyright 2017 Facebook, Inc.
6
 * You are hereby granted a non-exclusive, worldwide, royalty-free license to
7
 * use, copy, modify, and distribute this software in source code or binary
8
 * form for use in connection with the web services and APIs provided by
9
 * Facebook.
10
 * As with any software that integrates with the Facebook platform, your use
11
 * of this software is subject to the Facebook Developer Principles and
12
 * Policies [http://developers.facebook.com/policy/]. This copyright notice
13
 * shall be included in all copies or substantial portions of the software.
14
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20
 * DEALINGS IN THE SOFTWARE.
21
 */
22

23
namespace JanuSoftware\Facebook\PersistentData;
24

25
use InvalidArgumentException;
26

27

28
class PersistentDataFactory
29
{
30
        private function __construct()
31
        {
32
                // a factory constructor should never be invoked
33
        }
×
34

35

36
        /**
37
         * PersistentData generation.
38
         *
39
         * @throws InvalidArgumentException if the persistent data handler isn't "session", "memory", or an instance of Facebook\PersistentData\PersistentDataInterface
40
         */
41
        public static function createPersistentDataHandler(
42
                null|PersistentDataInterface|string $handler,
43
        ): InMemoryPersistentDataHandler|PersistentDataInterface|SessionPersistentDataHandler {
44
                if ($handler === null) {
18✔
45
                        return session_status() === PHP_SESSION_ACTIVE
12✔
46
                                ? new SessionPersistentDataHandler
×
47
                                : new InMemoryPersistentDataHandler;
12✔
48
                }
49

50
                if ($handler instanceof PersistentDataInterface) {
6✔
51
                        return $handler;
3✔
52
                }
53

54
                if ($handler === 'session') {
3✔
55
                        return new SessionPersistentDataHandler;
×
56
                }
57
                if ($handler === 'memory') {
3✔
58
                        return new InMemoryPersistentDataHandler;
2✔
59
                }
60

61
                throw new InvalidArgumentException('The persistent data handler must be set to "session", "memory", or be an instance of Facebook\PersistentData\PersistentDataInterface');
1✔
62
        }
63
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc