Passed
Push — develop ( aeaa02...49fa9d )
by Andrew
06:05
created

ICalendarVariable::ics()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * iCalendar plugin for Craft CMS 3.x
4
 *
5
 * Tools for parsing & formatting the RFC 2445 iCalendar (.ics) specification
6
 *
7
 * @link      https://nystudio107.com
8
 * @copyright Copyright (c) 2019 nystudio107
9
 */
10
11
namespace nystudio107\icalendar\variables;
12
13
use nystudio107\icalendar\ICalendar;
14
15
use ICal\ICal;
16
17
/**
18
 * @author    nystudio107
19
 * @package   ICalendar
20
 * @since     1.1.0
21
 */
22
class ICalendarVariable
23
{
24
    // Public Methods
25
    // =========================================================================
26
27
    /**
28
     * Format the passed in $text as per the iCalendar RFC 2445 spec:
29
     * https://icalendar.org/validator.html
30
     *
31
     * @param string $text
32
     *
33
     * @return string
34
     */
35
    public function rfc2445(string $text): string
36
    {
37
        return ICalendar::$plugin->convert->rfc2445($text);
38
    }
39
40
    /**
41
     * Return the ICal object (or null) for the events feed
42
     *
43
     * @param mixed|array|string $files
44
     * @param array              $config
45
     *
46
     * @return null|ICal
47
     */
48
    public function ics($files, array $config = [])
49
    {
50
        return ICalendar::$plugin->parse->ics($files, $config);
51
    }
52
}
53