Completed
Pull Request — master (#38)
by Christian
02:18
created

DataListExtension::byURL()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 3
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