DataListExtension::byURL()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Ntb\RestAPI;
4
5
/**
6
 * Useful extensions for data lists.
7
 * @author Christian Blank <[email protected]>
8
 */
9
class DataListExtension extends \Extension {
10
11
    /**
12
     * Returns the first element in a data list, that has the given url segment.
13
     *
14
     * Works in the same way as DataList::byID.
15
     *
16
     * @param string $url the url segment
17
     * @return \DataObject the object, that has the given url segment
18
     */
19
    public function byURL($url) {
20
        $URL = \Convert::raw2sql($url);
21
        return $this->owner->filter('URLSegment', $URL)->first();
22
    }
23
}
24