Skip to content
This repository was archived by the owner on Apr 17, 2022. It is now read-only.

Commit 760ba28

Browse files
author
calvinalkan
committed
update dependencies and remove WpFacade.php
1 parent 0a40840 commit 760ba28

File tree

3 files changed

+427
-50
lines changed

3 files changed

+427
-50
lines changed

WpFacade.php

+39-40
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,29 @@
11
<?php
2+
3+
4+
declare(strict_types = 1);
5+
6+
7+
namespace WpFacade;
28

3-
namespace WpFacade;
4-
9+
use Contracts\ContainerAdapter;
10+
use Mockery;
511
use Mockery\MockInterface;
12+
use RuntimeException;
613

714
abstract class WpFacade {
8-
/** @var \BetterWpHooks\Contracts\EventContainerAdapter */
9-
private static $container;
10-
1115

16+
17+
/** @var ContainerAdapter */
18+
private static $container;
19+
1220
/**
1321
* The resolved object instances.
1422
*
1523
* @var array
1624
*/
1725
private static $resolvedInstance;
18-
19-
26+
2027
/**
2128
* Get the root object behind the facade.
2229
*
@@ -26,8 +33,7 @@ public static function getFacadeRoot() {
2633

2734
return static::resolveFacadeInstance( static::getFacadeAccessor() );
2835
}
29-
30-
36+
3137
/**
3238
* Get the registered name of the component.
3339
*
@@ -39,9 +45,7 @@ protected static function getFacadeAccessor() {
3945

4046
throw new RuntimeException( 'Facade does not implement getFacadeAccessor method.' );
4147
}
42-
43-
44-
48+
4549
/**
4650
* Resolve the facade root instance from the container.
4751
*
@@ -75,7 +79,7 @@ protected static function resolveFacadeInstance( $name ) {
7579
*
7680
* @return void
7781
*/
78-
public static function clearResolvedInstance( $name ) {
82+
public static function clearResolvedInstance( string $name ) {
7983
unset( static::$resolvedInstance[ $name ] );
8084
}
8185

@@ -91,24 +95,15 @@ public static function clearResolvedInstances() {
9195
}
9296

9397

94-
/**
95-
*
96-
* @return \BetterWpHooks\Contracts\EventContainerAdapter
97-
*/
98-
public static function getFacadeContainer(): Contracts\EventContainerAdapter {
98+
public static function getFacadeContainer(): ContainerAdapter {
9999

100100
return static::$container;
101101

102102
}
103103

104-
/**
105-
* Set the application instance.
106-
*
107-
* @param \BetterWpHooks\Contracts\EventContainerAdapter $container
108-
*
109-
* @return void
110-
*/
111-
public static function setFacadeContainer( $container ) {
104+
105+
106+
public static function setFacadeContainer( ContainerAdapter $container ) {
112107
static::$container = $container;
113108
}
114109

@@ -121,7 +116,7 @@ public static function setFacadeContainer( $container ) {
121116
*
122117
* @return mixed
123118
*
124-
* @throws \RuntimeException
119+
* @throws RuntimeException
125120
*/
126121
public static function __callStatic( string $method, array $args ) {
127122

@@ -135,8 +130,7 @@ public static function __callStatic( string $method, array $args ) {
135130
return $instance->$method( ...$args );
136131

137132
}
138-
139-
133+
140134
/**
141135
* Convert the facade into a Mockery spy.
142136
*
@@ -147,14 +141,15 @@ public static function spy() {
147141
if ( ! static::isMock() ) {
148142

149143
$class = static::getMockableClass();
150-
151-
return tap( $class ? Mockery::spy( $class ) : Mockery::spy(), function ( $spy ) {
152-
static::swap( $spy );
153-
} );
144+
145+
$spy = $class ? Mockery::spy($class) : Mockery::spy();
146+
static::swap($spy);
147+
148+
return $spy;
149+
154150
}
155151
}
156-
157-
152+
158153
/**
159154
* Initiate a partial mock on the facade.
160155
*
@@ -192,11 +187,14 @@ public static function shouldReceive() {
192187
* @return \Mockery\MockInterface
193188
*/
194189
protected static function createFreshMockInstance() {
195-
return tap( static::createMock(), function ( $mock ) {
196-
static::swap( $mock );
197-
198-
$mock->shouldAllowMockingProtectedMethods();
199-
} );
190+
191+
$mock = static::createMock();
192+
static::swap($mock);
193+
$mock->shouldAllowMockingProtectedMethods();
194+
195+
return $mock;
196+
197+
200198
}
201199

202200
/**
@@ -216,6 +214,7 @@ protected static function createMock() {
216214
* @return bool
217215
*/
218216
protected static function isMock() {
217+
219218
$name = static::getFacadeAccessor();
220219

221220
return isset( static::$resolvedInstance[ $name ] ) &&

composer.json

+12-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44
"homepage": "https://github.com/calvinalkan/base-container/",
55

66
"require": {
7-
"calvinalkan/interfaces": "0.1.0"
7+
"php": "^7.3",
8+
"calvinalkan/interfaces": "0.1.1"
9+
},
10+
11+
"require-dev": {
12+
"mockery/mockery": "^1.4"
813
},
914

1015
"license": "GPL-2.0-or-later",
@@ -15,6 +20,12 @@
1520
}
1621

1722
],
23+
24+
"suggest": {
25+
"mockery/mockery": "Required if you want to use the Facade Fake Replacement for testing purposes"
26+
27+
},
28+
1829
"autoload": {
1930
"psr-4": {
2031
"WpFacade\\": "/"

0 commit comments

Comments
 (0)