Completed
Push — master ( 3de977...cf3a23 )
by mw
9s
created

FooCallbackContainer::addCallbackHandlers()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 26
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 1 Features 1
Metric Value
c 3
b 1
f 1
dl 0
loc 26
rs 8.8571
cc 1
eloc 14
nc 1
nop 1
1
<?php
2
3
namespace Onoi\CallbackContainer\Tests;
4
5
use Onoi\CallbackContainer\CallbackContainer;
6
use Onoi\CallbackContainer\CallbackLoader;
7
8
/**
9
 * @license GNU GPL v2+
10
 * @since 1.0
11
 *
12
 * @author mwjames
13
 */
14
class FooCallbackContainer implements CallbackContainer {
15
16
	public function register( CallbackLoader $callbackLoader ) {
17
		$this->addCallbackHandlers( $callbackLoader);
18
	}
19
20
	private function addCallbackHandlers( $callbackLoader ) {
21
22
		$callbackLoader->registerCallback( 'Foo', function() {
23
			return new \stdClass;
24
		} );
25
26
		$callbackLoader->registerExpectedReturnType( 'Foo', '\stdClass' );
27
28
		$callbackLoader->registerCallback( 'FooWithArgument', function( $argument ) use( $callbackLoader ) {
29
			$callbackLoader->registerExpectedReturnType( 'FooWithArgument', '\stdClass' );
30
31
			$stdClass = new \stdClass;
32
			$stdClass->argument = $argument;
33
34
			return $stdClass;
35
		} );
36
37
		$callbackLoader->registerCallback( 'FooWithNullArgument', function( $argument = null ) use( $callbackLoader ) {
38
			$callbackLoader->registerExpectedReturnType( 'FooWithNullArgument', '\stdClass' );
39
40
			$stdClass = new \stdClass;
41
			$stdClass->argument = $argument;
42
43
			return $stdClass;
44
		} );
45
	}
46
47
}
48