Completed
Push — master ( e2a1f2...9f2620 )
by Ron
02:23
created

ViewTryFinallySimulator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 2
c 1
b 1
f 0
lcom 0
cbo 0
dl 0
loc 19
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A tryThis() 0 11 2
1
<?php
2
namespace View\Helpers;
3
4
abstract class ViewTryFinallySimulator {
5
	/**
6
	 * @param callable $fn
7
	 * @param callable $finally
8
	 * @return mixed
9
	 * @throws \Exception
10
	 */
11
	public static function tryThis($fn, $finally) {
12
		$result = null;
13
		try {
14
			$result = call_user_func($fn);
15
		} catch (\Exception $e) {
16
			call_user_func($finally);
17
			throw $e;
18
		}
19
		call_user_func($finally);
20
		return $result;
21
	}
22
}
23