CoursePresenter::getOrdinalYear()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 6
rs 10
1
<?php
2
3
namespace App\Judite\Presenters;
4
5
use NumberFormatter;
6
use Laracasts\Presenter\Presenter;
7
8
class CoursePresenter extends Presenter
9
{
10
    /**
11
     * The year of this course in ordinal format.
12
     *
13
     * @return string
14
     */
15
    public function getOrdinalYear()
16
    {
17
        $formatter = new NumberFormatter(app()->getLocale(), NumberFormatter::SPELLOUT);
0 ignored issues
show
introduced by
The method getLocale() does not exist on Illuminate\Container\Container. Are you sure you never get this type here, but always one of the subclasses? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

17
        $formatter = new NumberFormatter(app()->/** @scrutinizer ignore-call */ getLocale(), NumberFormatter::SPELLOUT);
Loading history...
18
        $formatter->setTextAttribute(NumberFormatter::DEFAULT_RULESET, '%spellout-ordinal');
19
20
        return ucfirst($formatter->format($this->entity->year));
21
    }
22
23
    /**
24
     * The semester of this course in ordinal format.
25
     *
26
     * @return string
27
     */
28
    public function getOrdinalSemester()
29
    {
30
        $formatter = new NumberFormatter(app()->getLocale(), NumberFormatter::ORDINAL);
31
32
        return ucfirst($formatter->format($this->entity->semester));
33
    }
34
}
35