Completed
Push — master ( e027a1...e8793f )
by Piotr
03:10
created

ExampleService::authorizedMethod()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

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 2
nc 1
nop 2
1
<?php
2
/**
3
 * Copyright (C) 2013-2016
4
 * Piotr Olaszewski <[email protected]>
5
 *
6
 * Permission is hereby granted, free of charge, to any person obtaining a copy
7
 * of this software and associated documentation files (the "Software"), to deal
8
 * in the Software without restriction, including without limitation the rights
9
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
 * copies of the Software, and to permit persons to whom the Software is
11
 * furnished to do so, subject to the following conditions:
12
 *
13
 * The above copyright notice and this permission notice shall be included in
14
 * all copies or substantial portions of the Software.
15
 *
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
 * SOFTWARE.
23
 */
24
use Ouzo\Utilities\Arrays;
25
use Ouzo\Utilities\Functions;
26
27
/**
28
 * ExampleService
29
 *
30
 * @author Piotr Olaszewski <[email protected]>
31
 */
32
class ExampleService
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...
33
{
34
    private $clientId = null;
35
36
    public function uppercaseUserName($userName)
37
    {
38
        return strtoupper($userName);
39
    }
40
41
    public function appendPrefixToNumbers($numbers, $prefix)
42
    {
43
        return Arrays::map($numbers, Functions::prepend($prefix));
44
    }
45
46
    public function getUserContext($user)
47
    {
48
        $userContext = new stdClass();
49
        $userContext->id = time();
50
        $userContext->userInfo = new stdClass();
51
        $userContext->userInfo->name = $user->name;
52
        $userContext->userInfo->age = $user->age;
53
        return $userContext;
54
    }
55
56
    public function extractCompaniesNames($companies)
57
    {
58
        return Arrays::map($companies, Functions::extractField('name'));
59
    }
60
61
    public function wrapErrors($errors)
62
    {
63
        $result = new stdClass();
64
        $result->result = false;
65
        $result->errors = $errors;
66
        return $result;
67
    }
68
69
    public function serviceAuth($object)
70
    {
71
        if ($object->token != 'test_token') {
72
            throw new SoapFault('WT', 'Wrong token');
73
        } else {
74
            $this->clientId = $object->id;
75
        }
76
    }
77
78
    public function authorizedMethod($name, $surname)
79
    {
80
        return 'clientId [' . $this->clientId . '] name [' . $name . '] surname [' . $surname . ']';
81
    }
82
83
    public function methodWithoutReturn($userToken)
84
    {
85
        file_put_contents('/tmp/wsdl-creator-example-log', $userToken . PHP_EOL, FILE_APPEND);
86
    }
87
88
    public function methodWithoutParameters()
89
    {
90
        return 'method without parameters';
91
    }
92
}
93