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

ViewTryFinallySimulator::tryThis()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 11
rs 9.4285
cc 2
eloc 9
nc 2
nop 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