Completed
Push — master ( 952f49...c4dcc1 )
by Robbie
01:49
created

MarkdownText::MarkdownExtraAsHTML()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
/**
3
 * Represents a large text field that contains HTML and Markdown content.
4
 * Markdown gets processed automatically to HTML in templates
5
 */
6
class MarkdownText extends HTMLText {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
7
8
	/**
9
	 * Define the casting for field names and types
10
	 * @var array
11
	 */
12
	public static $casting = array(
13
		'MarkdownAsHTML'		=>	'MarkdownText',
14
		'MarkdownExtraAsHTML' 	=>	'MarkdownText',
15
	);
16
17
	/**
18
	 * Returns Markdown content as HTML for templates
19
	 * @return string HTML
20
	 */
21
	public function forTemplate() {
22
		return $this->MarkdownAsHTML();
23
	}
24
25
	/**
26
	 * Return Markdown content as HTML
27
	 * @return string HTML
28
	 */
29
	public function MarkdownAsHTML() {
30
		$parser = new MarkdownParser($this->value);
31
		return $parser->parse();
32
	}
33
34
	/**
35
	 * Return MarkdownExtra content as HTML
36
	 * @return string HTML
37
	 */
38
	public function MarkdownExtraAsHTML() {
39
		$parser = new MarkdownParser($this->value);
40
		return $parser->parseExtra();
41
	}
42
43
	/**
44
	 * Return an instance of the MarkdownTextareaField
45
	 * @param  string $title
0 ignored issues
show
Documentation introduced by
Should the type for parameter $title not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
46
	 * @param  array  $params
0 ignored issues
show
Documentation introduced by
Should the type for parameter $params not be array|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
47
	 * @return MarkdownTextareaField
48
	 */
49
	public function scaffoldFormField($title = null, $params = null) {
50
		return new MarkdownTextareaField($this->name, $title);
51
	}
52
53
}
54