Zend   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 37
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A log() 0 12 3
A __construct() 0 3 1
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Metaways Infosystems GmbH, 2011
6
 * @copyright Aimeos (aimeos.org), 2014-2018
7
 * @package MW
8
 * @subpackage Logger
9
 */
10
11
12
namespace Aimeos\MW\Logger;
13
14
15
/**
16
 * Log messages using \Zend_Log.
17
 *
18
 * @package MW
19
 * @subpackage Logger
20
 */
21
class Zend extends \Aimeos\MW\Logger\Base implements \Aimeos\MW\Logger\Iface
22
{
23
	private $logger = null;
24
25
26
	/**
27
	 * Initializes the logger object.
28
	 *
29
	 * @param \Zend_Log $logger \Zend_Log object
30
	 */
31
	public function __construct( \Zend_Log $logger )
0 ignored issues
show
Bug introduced by
The type Zend_Log was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
32
	{
33
		$this->logger = $logger;
34
	}
35
36
37
	/**
38
	 * Writes a message to the configured log facility.
39
	 *
40
	 * @param string|array|object $message Message text that should be written to the log facility
41
	 * @param integer $priority Priority of the message for filtering
42
	 * @param string $facility Facility for logging different types of messages (e.g. message, auth, user, changelog)
43
	 * @throws \Aimeos\MW\Logger\Exception If an error occurs in \Zend_Log
44
	 * @see \Aimeos\MW\Logger\Base for available log level constants
45
	 */
46
	public function log( $message, $priority = \Aimeos\MW\Logger\Base::ERR, $facility = 'message' )
47
	{
48
		try
49
		{
50
			if( !is_scalar( $message ) ) {
51
				$message = json_encode( $message );
52
			}
53
54
			$this->logger->log( '<' . $facility . '> ' . $message, $priority );
55
		}
56
		catch( \Zend_Log_Exception $ze )	{
0 ignored issues
show
Bug introduced by
The type Zend_Log_Exception was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
57
			throw new \Aimeos\MW\Logger\Exception( $ze->getMessage() );
58
		}
59
	}
60
}