PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / trunk
Booking for Appointments and Events Calendar – Amelia vtrunk
2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / vendor / php-http / discovery / src / Strategy / PuliBetaStrategy.php
ameliabooking / vendor / php-http / discovery / src / Strategy Last commit date
CommonClassesStrategy.php 6 months ago CommonPsr17ClassesStrategy.php 6 months ago DiscoveryStrategy.php 3 years ago MockClientStrategy.php 3 years ago PuliBetaStrategy.php 3 years ago
PuliBetaStrategy.php
93 lines
1 <?php
2
3 namespace AmeliaHttp\Discovery\Strategy;
4
5 use AmeliaHttp\Discovery\ClassDiscovery;
6 use AmeliaHttp\Discovery\Exception\PuliUnavailableException;
7 use Puli\Discovery\Api\Discovery;
8 use Puli\GeneratedPuliFactory;
9
10 /**
11 * Find candidates using Puli.
12 *
13 * @internal
14 * @final
15 *
16 * @author David de Boer <david@ddeboer.nl>
17 * @author Márk Sági-Kazár <mark.sagikazar@gmail.com>
18 */
19 class PuliBetaStrategy implements DiscoveryStrategy
20 {
21 /**
22 * @var GeneratedPuliFactory
23 */
24 protected static $puliFactory;
25
26 /**
27 * @var Discovery
28 */
29 protected static $puliDiscovery;
30
31 /**
32 * @return GeneratedPuliFactory
33 *
34 * @throws PuliUnavailableException
35 */
36 private static function getPuliFactory()
37 {
38 if (null === self::$puliFactory) {
39 if (!defined('PULI_FACTORY_CLASS')) {
40 throw new PuliUnavailableException('Puli Factory is not available');
41 }
42
43 $puliFactoryClass = PULI_FACTORY_CLASS;
44
45 if (!ClassDiscovery::safeClassExists($puliFactoryClass)) {
46 throw new PuliUnavailableException('Puli Factory class does not exist');
47 }
48
49 self::$puliFactory = new $puliFactoryClass();
50 }
51
52 return self::$puliFactory;
53 }
54
55 /**
56 * Returns the Puli discovery layer.
57 *
58 * @return Discovery
59 *
60 * @throws PuliUnavailableException
61 */
62 private static function getPuliDiscovery()
63 {
64 if (!isset(self::$puliDiscovery)) {
65 $factory = self::getPuliFactory();
66 $repository = $factory->createRepository();
67
68 self::$puliDiscovery = $factory->createDiscovery($repository);
69 }
70
71 return self::$puliDiscovery;
72 }
73
74 /**
75 * {@inheritdoc}
76 */
77 public static function getCandidates($type)
78 {
79 $returnData = [];
80 $bindings = self::getPuliDiscovery()->findBindings($type);
81
82 foreach ($bindings as $binding) {
83 $condition = true;
84 if ($binding->hasParameterValue('depends')) {
85 $condition = $binding->getParameterValue('depends');
86 }
87 $returnData[] = ['class' => $binding->getClassName(), 'condition' => $condition];
88 }
89
90 return $returnData;
91 }
92 }
93