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

LM-Commons / LmcUser / 9697313754

27 Jun 2024 01:16PM UTC coverage: 90.508% (-0.08%) from 90.584%
9697313754

push

github

web-flow
Merge pull request #89 from visto9259/fix_74

Fix 74 and other cleanups

5 of 7 new or added lines in 3 files covered. (71.43%)

1602 of 1770 relevant lines covered (90.51%)

3.56 hits per line

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

44.44
/src/Authentication/Adapter/AdapterChainServiceFactory.php
1
<?php
2
namespace LmcUser\Authentication\Adapter;
3

4
use Psr\Container\ContainerInterface;
5
use Laminas\ServiceManager\Factory\FactoryInterface;
6
use Laminas\ServiceManager\ServiceLocatorInterface;
7
use LmcUser\Options\ModuleOptions;
8
use LmcUser\Authentication\Adapter\Exception\OptionsNotFoundException;
9

10
class AdapterChainServiceFactory implements FactoryInterface
11
{
12
    public function __invoke(ContainerInterface $serviceLocator, $requestedName, array $options = null)
×
13
    {
14
        $chain = new AdapterChain();
×
15
        $chain->setEventManager($serviceLocator->get('EventManager'));
×
16

17
        $options = $this->getOptions($serviceLocator);
×
18

19
        //iterate and attach multiple adapters and events if offered
20
        foreach ($options->getAuthAdapters() as $priority => $adapterName) {
×
21
            $adapter = $serviceLocator->get($adapterName);
×
22

23
            if (is_callable(array($adapter, 'authenticate'))) {
×
24
                $chain->getEventManager()->attach('authenticate', array($adapter, 'authenticate'), $priority);
×
25
            }
26

27
            if (is_callable(array($adapter, 'logout'))) {
×
28
                $chain->getEventManager()->attach('logout', array($adapter, 'logout'), $priority);
×
29
            }
30

NEW
31
            if (is_callable(array($adapter, 'reset'))) {
×
NEW
32
                $chain->getEventManager()->attach('reset', array($adapter, 'reset'), $priority);
×
33
            }
34
        }
35

36
        return $chain;
×
37
    }
38

39
    /**
40
     * @var ModuleOptions
41
     */
42
    protected $options;
43

44
    public function createService(ServiceLocatorInterface $serviceLocator)
×
45
    {
46
        $this->__invoke($serviceLocator, null);
×
47
    }
48

49

50
    /**
51
     * set options
52
     *
53
     * @param  ModuleOptions $options
54
     * @return AdapterChainServiceFactory
55
     */
56
    public function setOptions(ModuleOptions $options)
1✔
57
    {
58
        $this->options = $options;
1✔
59
        return $this;
1✔
60
    }
61

62
    /**
63
     * get options
64
     *
65
     * @param  ServiceLocatorInterface $serviceLocator (optional) Service Locator
66
     * @return ModuleOptions $options
67
     * @throws OptionsNotFoundException If options tried to retrieve without being set but no SL was provided
68
     */
69
    public function getOptions(ServiceLocatorInterface $serviceLocator = null)
3✔
70
    {
71
        if (!$this->options) {
3✔
72
            if (!$serviceLocator) {
2✔
73
                throw new OptionsNotFoundException(
1✔
74
                    'Options were tried to retrieve but not set ' .
1✔
75
                    'and no service locator was provided'
1✔
76
                );
1✔
77
            }
78

79
            $this->setOptions($serviceLocator->get('lmcuser_module_options'));
1✔
80
        }
81

82
        return $this->options;
2✔
83
    }
84
}
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

© 2025 Coveralls, Inc