FileLogger   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 3
1
<?php
2
/*
3
 * This file is part of Yolk - Gamer Network's PHP Framework.
4
 *
5
 * Copyright (c) 2014 Gamer Network Ltd.
6
 * 
7
 * Distributed under the MIT License, a copy of which is available in the
8
 * LICENSE file that was bundled with this package, or online at:
9
 * https://github.com/gamernetwork/yolk-logger
10
 */
11
12
namespace yolk\log\adapter;
13
14
use yolk\log\Exception;
15
16
/**
17
 * Provides logging to the filesystem.
18
 */
19
class FileLogger extends StreamLogger {
20
   
21
	/**
22
	 * Open a file on the filesystem.
23
	 * @param string $file   full path and file name of target file
24
	 */
25
	public function __construct( $file ) {
26
27
		if( !$file )
28
			throw new \InvalidArgumentException('No file specified');
29
		elseif( !$stream = fopen($file, 'a+') )
30
			throw new Exception("Unable to open log file: {$file}");
31
32
		parent::__construct($stream);
33
34
	}
35
36
}
37
38
// EOF