phpwintools /
wmi-scripting
| 1 | <?php |
||||||||
| 2 | |||||||||
| 3 | namespace PhpWinTools\WmiScripting\Configuration; |
||||||||
| 4 | |||||||||
| 5 | use COM; |
||||||||
| 6 | use VARIANT; |
||||||||
| 7 | use PhpWinTools\Support\COM\ComWrapper; |
||||||||
| 8 | use PhpWinTools\Support\COM\VariantWrapper; |
||||||||
| 9 | use PhpWinTools\Support\COM\Testing\COMFake; |
||||||||
| 10 | use PhpWinTools\Support\COM\ComVariantWrapper; |
||||||||
| 11 | use PhpWinTools\WmiScripting\Connections\ComConnection; |
||||||||
| 12 | use PhpWinTools\WmiScripting\Testing\Support\VARIANTFake; |
||||||||
| 13 | use PhpWinTools\WmiScripting\Support\ApiObjects\Contracts\Locator; |
||||||||
| 14 | use PhpWinTools\WmiScripting\Exceptions\UnresolvableClassException; |
||||||||
| 15 | use PhpWinTools\WmiScripting\Support\ApiObjects\Contracts\Property; |
||||||||
| 16 | use PhpWinTools\WmiScripting\Support\ApiObjects\Contracts\Services; |
||||||||
| 17 | use PhpWinTools\WmiScripting\Support\ApiObjects\Contracts\ObjectSet; |
||||||||
| 18 | use PhpWinTools\WmiScripting\Support\ApiObjects\Contracts\Qualifier; |
||||||||
| 19 | use PhpWinTools\WmiScripting\Support\ApiObjects\Contracts\ObjectItem; |
||||||||
| 20 | use PhpWinTools\WmiScripting\Support\ApiObjects\Contracts\ObjectPath; |
||||||||
| 21 | use PhpWinTools\WmiScripting\Support\ApiObjects\Contracts\PropertySet; |
||||||||
| 22 | use PhpWinTools\WmiScripting\Support\ApiObjects\Contracts\ObjectItemEx; |
||||||||
| 23 | use PhpWinTools\WmiScripting\Support\ApiObjects\Contracts\QualifierSet; |
||||||||
| 24 | |||||||||
| 25 | class Resolver |
||||||||
| 26 | { |
||||||||
| 27 | /** @var Config */ |
||||||||
| 28 | protected $config; |
||||||||
| 29 | |||||||||
| 30 | 33 | public function __construct(Config $config = null) |
|||||||
| 31 | { |
||||||||
| 32 | 33 | $this->config = $config ?? Config::instance(); |
|||||||
| 33 | 33 | } |
|||||||
| 34 | |||||||||
| 35 | /** |
||||||||
| 36 | * @param string|callable|object $resolvable |
||||||||
| 37 | * @param mixed ...$parameters |
||||||||
| 38 | * |
||||||||
| 39 | * @return mixed |
||||||||
| 40 | */ |
||||||||
| 41 | 7 | public function make($resolvable, ...$parameters) |
|||||||
| 42 | { |
||||||||
| 43 | 7 | if (is_callable($resolvable)) { |
|||||||
| 44 | 1 | return $resolvable(...$parameters); |
|||||||
| 45 | } |
||||||||
| 46 | |||||||||
| 47 | 6 | if (is_object($resolvable)) { |
|||||||
| 48 | 2 | return $resolvable; |
|||||||
| 49 | } |
||||||||
| 50 | |||||||||
| 51 | 4 | if (is_string($resolvable) && class_exists($resolvable)) { |
|||||||
| 52 | 3 | return new $resolvable(...$parameters); |
|||||||
| 53 | } |
||||||||
| 54 | |||||||||
| 55 | 1 | throw UnresolvableClassException::default($resolvable); |
|||||||
| 56 | } |
||||||||
| 57 | |||||||||
| 58 | 2 | public function comClass($module_name, $server_name = null, $code_page = null, $type_lib = null) |
|||||||
|
0 ignored issues
–
show
The parameter
$type_lib is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
The parameter
$server_name is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
|
|||||||||
| 59 | { |
||||||||
| 60 | 2 | return $this->make( |
|||||||
| 61 | 2 | $this->config->getComClass(), |
|||||||
| 62 | 2 | $module_name, |
|||||||
| 63 | 2 | $server_name = null, |
|||||||
| 64 | 2 | $code_page = null, |
|||||||
| 65 | 2 | $type_lib = null |
|||||||
| 66 | ); |
||||||||
| 67 | } |
||||||||
| 68 | |||||||||
| 69 | public function variantClass($value = null, string $class_name = null, $code_page = null) |
||||||||
|
0 ignored issues
–
show
The parameter
$value is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
The parameter
$code_page is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
The parameter
$class_name is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
|
|||||||||
| 70 | { |
||||||||
| 71 | return $this->make($this->config->getVariantClass(), $value = null, $class_name = null, $code_page = null); |
||||||||
| 72 | } |
||||||||
| 73 | |||||||||
| 74 | /** |
||||||||
| 75 | * @param COM|COMFake $com |
||||||||
| 76 | * @param Config|null $config |
||||||||
| 77 | * |
||||||||
| 78 | * @return ComVariantWrapper |
||||||||
| 79 | */ |
||||||||
| 80 | public function comVariantWrapper($com, Config $config = null) |
||||||||
| 81 | { |
||||||||
| 82 | return $this->make($this->config->getComVariantWrapper(), $com, $config ?? $config); |
||||||||
| 83 | } |
||||||||
| 84 | |||||||||
| 85 | /** |
||||||||
| 86 | * @param COM|COMFake $com |
||||||||
| 87 | * @param Config|null $config |
||||||||
| 88 | * |
||||||||
| 89 | * @return ComWrapper |
||||||||
| 90 | */ |
||||||||
| 91 | 2 | public function comWrapper($com, Config $config = null) |
|||||||
| 92 | { |
||||||||
| 93 | 2 | return $this->make($this->config->getComWrapper(), $com, $config ?? $this->config); |
|||||||
| 94 | } |
||||||||
| 95 | |||||||||
| 96 | /** |
||||||||
| 97 | * @param VARIANT|VARIANTFake $variant |
||||||||
| 98 | * @param Config|null $config |
||||||||
| 99 | * |
||||||||
| 100 | * @return VariantWrapper |
||||||||
| 101 | */ |
||||||||
| 102 | public function variantWrapper($variant, Config $config = null) |
||||||||
| 103 | { |
||||||||
| 104 | return $this->make($this->config->getVariantWrapper(), $variant, $config ?? $this->config); |
||||||||
| 105 | } |
||||||||
| 106 | |||||||||
| 107 | /** |
||||||||
| 108 | * @param ComVariantWrapper|null $wrapper |
||||||||
| 109 | * @param Config|null $config |
||||||||
| 110 | * |
||||||||
| 111 | * @return Locator |
||||||||
| 112 | */ |
||||||||
| 113 | 2 | public function locator(ComVariantWrapper $wrapper = null, Config $config = null) |
|||||||
| 114 | { |
||||||||
| 115 | 2 | return $this->make($this->config->getApiObject(Locator::class), $wrapper, $config ?? $this->config); |
|||||||
| 116 | } |
||||||||
| 117 | |||||||||
| 118 | 2 | public function objectItem(VariantWrapper $variant, array $resolve = [], Config $config = null) |
|||||||
| 119 | { |
||||||||
| 120 | 2 | return $this->make( |
|||||||
| 121 | 2 | $this->config->getApiObject(ObjectItem::class), |
|||||||
| 122 | 2 | $variant, |
|||||||
| 123 | 2 | $resolve, |
|||||||
| 124 | 2 | $config ?? $this->config |
|||||||
| 125 | ); |
||||||||
| 126 | } |
||||||||
| 127 | |||||||||
| 128 | /** |
||||||||
| 129 | * @param VariantWrapper $variant |
||||||||
| 130 | * @param array $resolve |
||||||||
| 131 | * @param Config|null $config |
||||||||
| 132 | * |
||||||||
| 133 | * @return ObjectItemEx |
||||||||
| 134 | */ |
||||||||
| 135 | public function objectItemEx(VariantWrapper $variant, array $resolve = [], Config $config = null) |
||||||||
| 136 | { |
||||||||
| 137 | return $this->make( |
||||||||
| 138 | $this->config->getApiObject(ObjectItemEx::class), |
||||||||
| 139 | $variant, |
||||||||
| 140 | $resolve, |
||||||||
| 141 | $config ?? $this->config |
||||||||
| 142 | ); |
||||||||
| 143 | } |
||||||||
| 144 | |||||||||
| 145 | /** |
||||||||
| 146 | * @param VariantWrapper $variant |
||||||||
| 147 | * @param Config|null $config |
||||||||
| 148 | * |
||||||||
| 149 | * @return ObjectPath |
||||||||
| 150 | */ |
||||||||
| 151 | 2 | public function objectPath(VariantWrapper $variant, Config $config = null) |
|||||||
| 152 | { |
||||||||
| 153 | 2 | return $this->make($this->config->getApiObject(ObjectPath::class), $variant, $config ?? $this->config); |
|||||||
| 154 | } |
||||||||
| 155 | |||||||||
| 156 | /** |
||||||||
| 157 | * @param VariantWrapper $variant |
||||||||
| 158 | * @param array $resolve |
||||||||
| 159 | * @param Config|null $config |
||||||||
| 160 | * |
||||||||
| 161 | * @return ObjectSet |
||||||||
| 162 | */ |
||||||||
| 163 | 2 | public function objectSet(VariantWrapper $variant, array $resolve = [], Config $config = null) |
|||||||
| 164 | { |
||||||||
| 165 | 2 | return $this->make($this->config->getApiObject(ObjectSet::class), $variant, $resolve, $config ?? $this->config); |
|||||||
| 166 | } |
||||||||
| 167 | |||||||||
| 168 | /** |
||||||||
| 169 | * @param VariantWrapper $variant |
||||||||
| 170 | * @param Config|null $config |
||||||||
| 171 | * |
||||||||
| 172 | * @return Property |
||||||||
| 173 | */ |
||||||||
| 174 | 2 | public function property(VariantWrapper $variant, Config $config = null) |
|||||||
| 175 | { |
||||||||
| 176 | 2 | return $this->make($this->config->getApiObject(Property::class), $variant, $config ?? $this->config); |
|||||||
| 177 | } |
||||||||
| 178 | |||||||||
| 179 | /** |
||||||||
| 180 | * @param VariantWrapper $variant |
||||||||
| 181 | * @param array $resolve |
||||||||
| 182 | * @param Config|null $config |
||||||||
| 183 | * |
||||||||
| 184 | * @return PropertySet |
||||||||
| 185 | */ |
||||||||
| 186 | 2 | public function propertySet(VariantWrapper $variant, array $resolve = [], Config $config = null) |
|||||||
| 187 | { |
||||||||
| 188 | 2 | return $this->make( |
|||||||
| 189 | 2 | $this->config->getApiObject(PropertySet::class), |
|||||||
| 190 | 2 | $variant, |
|||||||
| 191 | 2 | $resolve, |
|||||||
| 192 | 2 | $config ?? $this->config |
|||||||
| 193 | ); |
||||||||
| 194 | } |
||||||||
| 195 | |||||||||
| 196 | /** |
||||||||
| 197 | * @param VariantWrapper $variant |
||||||||
| 198 | * @param Config|null $config |
||||||||
| 199 | * |
||||||||
| 200 | * @return Qualifier |
||||||||
| 201 | */ |
||||||||
| 202 | 2 | public function qualifier(VariantWrapper $variant, Config $config = null) |
|||||||
| 203 | { |
||||||||
| 204 | 2 | return $this->make($this->config->getApiObject(Qualifier::class), $variant, $config ?? $this->config); |
|||||||
| 205 | } |
||||||||
| 206 | |||||||||
| 207 | /** |
||||||||
| 208 | * @param VariantWrapper $variant |
||||||||
| 209 | * @param Config|null $config |
||||||||
| 210 | * |
||||||||
| 211 | * @return QualifierSet |
||||||||
| 212 | */ |
||||||||
| 213 | 2 | public function qualifierSet(VariantWrapper $variant, Config $config = null) |
|||||||
| 214 | { |
||||||||
| 215 | 2 | return $this->make($this->config->getApiObject(QualifierSet::class), $variant, $config ?? $this->config); |
|||||||
| 216 | } |
||||||||
| 217 | |||||||||
| 218 | /** |
||||||||
| 219 | * @param ComVariantWrapper|null $com |
||||||||
| 220 | * @param ComConnection|null $connection |
||||||||
| 221 | * @param Config|null $config |
||||||||
| 222 | * |
||||||||
| 223 | * @return Services |
||||||||
| 224 | */ |
||||||||
| 225 | 2 | public function services(ComVariantWrapper $com = null, ComConnection $connection = null, Config $config = null) |
|||||||
| 226 | { |
||||||||
| 227 | 2 | return $this->make($this->config->getApiObject(Services::class), $com, $connection, $config ?? $this->config); |
|||||||
| 228 | } |
||||||||
| 229 | } |
||||||||
| 230 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.