Issues (3627)

Services/FullContact_Name.php (1 issue)

1
<?php
2
3
/*
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at.
7
 *
8
 * http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
17
namespace MauticPlugin\MauticFullContactBundle\Services;
18
19
/**
20
 * This class handles everything related to names that aren't person-based info lookup.
21
 *
22
 * @author   Keith Casey <[email protected]>
23
 * @license  http://www.apache.org/licenses/LICENSE-2.0 Apache
24
 */
25
class FullContact_Name extends FullContact_Base
26
{
27
    /**
28
     * Supported lookup methods.
29
     *
30
     * @var array
31
     */
32
    protected $_supportedMethods = ['normalizer', 'deducer', 'similarity', 'stats', 'parser'];
33
    protected $_resourceUri      = '';
34
35
    /**
36
     * This takes a name and breaks it into its individual parts.
37
     *
38
     * @param type $name
39
     * @param type $casing -> valid values are uppercase, lowercase, titlecase
0 ignored issues
show
The type MauticPlugin\MauticFullContactBundle\Services\type was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
40
     *
41
     * @return type
42
     */
43
    public function normalizer($name, $casing = 'titlecase')
44
    {
45
        $this->_resourceUri = '/name/normalizer.json';
46
        $this->_execute(['q' => $name, 'method' => 'normalizer', 'casing' => $casing]);
47
48
        return $this->response_obj;
49
    }
50
51
    /**
52
     * This resolves a person's name from either their email address or a
53
     *   username. This is basically a wrapper for the Person lookup methods.
54
     *
55
     * @param type $name
56
     * @param type $type   -> valid values are email and username
57
     * @param type $casing -> valid values are uppercase, lowercase, titlecase
58
     *
59
     * @return type
60
     */
61
    public function deducer($value, $type = 'email', $casing = 'titlecase')
62
    {
63
        $this->_resourceUri = '/name/deducer.json';
64
        $this->_execute([$type => $value, 'method' => 'deducer', 'casing' => $casing]);
65
66
        return $this->response_obj;
67
    }
68
69
    /**
70
     * These are two names to compare.
71
     *
72
     * @param type $name1
73
     * @param type $name2
74
     * @param type $casing
75
     *
76
     * @return type
77
     */
78
    public function similarity($name1, $name2, $casing = 'titlecase')
79
    {
80
        $this->_resourceUri = '/name/similarity.json';
81
        $this->_execute(['q1' => $name1, 'q2' => $name2, 'method' => 'similarity', 'casing' => $casing]);
82
83
        return $this->response_obj;
84
    }
85
86
    public function stats($value, $type = 'givenName', $casing = 'titlecase')
87
    {
88
        $this->_resourceUri = '/name/stats.json';
89
        $this->_execute([$type => $value, 'method' => 'stats', 'casing' => $casing]);
90
91
        return $this->response_obj;
92
    }
93
94
    public function parser($name, $casing = 'titlecase')
95
    {
96
        $this->_resourceUri = '/name/parser.json';
97
        $this->_execute(['q' => $name, 'method' => 'parser', 'casing' => $casing]);
98
99
        return $this->response_obj;
100
    }
101
}
102