Completed
Push — fix/logo-package-prepend-autom... ( 62c51d )
by Marin
42:49 queued 32:30
created

Logo::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * A logo for Jetpack.
4
 *
5
 * @package jetpack-logo
6
 */
7
8
namespace Automattic\Jetpack\Assets;
9
10
/**
11
 * Create and render a Jetpack logo.
12
 */
13
class Logo {
14
	/**
15
	 * Absolute URL of the Jetpack logo.
16
	 *
17
	 * @var string
18
	 */
19
	private $url;
20
21
	/**
22
	 * Constructor.
23
	 * You can optionally pass a URL to override the default one.
24
	 *
25
	 * @param string $url New URL of the Jetpack logo.
26
	 */
27
	public function __construct( $url = '' ) {
28
		if ( ! $url ) {
29
			$url = plugins_url( 'assets/logo.svg', __DIR__ );
30
		}
31
32
		$this->url = $url;
33
	}
34
35
	/**
36
	 * Build and render an <img /> tag with the Jetpack logo.
37
	 *
38
	 * @return string The Jetpack logo in an <img /> tag.
39
	 */
40
	public function render() {
41
		return sprintf(
42
			'<img src="%s" class="jetpack-logo" alt="%s" />',
43
			esc_url( $this->url ),
44
			esc_attr( 'Jetpack.' )
45
		);
46
	}
47
}
48