• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pixelpeter / laravel5-genderize-api-client / 15701686167

17 Jun 2025 08:06AM UTC coverage: 98.925%. Remained the same
15701686167

push

github

web-flow
Bump stefanzweifel/git-auto-commit-action from 5 to 6 (#25)

Bumps [stefanzweifel/git-auto-commit-action](https://github.com/stefanzweifel/git-auto-commit-action) from 5 to 6.
- [Release notes](https://github.com/stefanzweifel/git-auto-commit-action/releases)
- [Changelog](https://github.com/stefanzweifel/git-auto-commit-action/blob/master/CHANGELOG.md)
- [Commits](https://github.com/stefanzweifel/git-auto-commit-action/compare/v5...v6)

---
updated-dependencies:
- dependency-name: stefanzweifel/git-auto-commit-action
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

92 of 93 relevant lines covered (98.92%)

13.06 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/GenderizeClient.php
1
<?php
2

3
namespace Pixelpeter\Genderize;
4

5
use Pixelpeter\Genderize\Models\GenderizeResponse;
6
use Unirest\Request;
7

8
class GenderizeClient
9
{
10
    /**
11
     * @var array Holds one or more names to check
12
     */
13
    protected $names;
14

15
    /**
16
     * @var string | null The language used for the check
17
     */
18
    protected $lang;
19

20
    /**
21
     * @var string | null The country used for the check
22
     */
23
    protected $country;
24

25
    /**
26
     * @var string The api key used for the request
27
     */
28
    protected $apikey;
29

30
    /**
31
     * @var \Unirest\Request
32
     */
33
    protected $request;
34

35
    /**
36
     * @const API_URL The URL of the api endpoint
37
     */
38
    const API_URL = 'https://api.genderize.io';
39

40
    /**
41
     * Create new instance of Pixelpeter\Genderize\GenderizeClient
42
     */
43
    public function __construct(Request $request)
24✔
44
    {
45
        $this->apikey = config('genderize.apikey');
24✔
46
        $this->request = $request;
24✔
47
    }
24✔
48

49
    /**
50
     * Fluent setter for names given as string
51
     *
52
     * @param  string | array  $name
53
     * @return $this|GenderizeClient
54
     */
55
    public function name($name = '')
21✔
56
    {
57
        if (is_array($name)) {
21✔
58
            return $this->names($name);
3✔
59
        }
60

61
        $this->names = [$name];
18✔
62

63
        return $this;
18✔
64
    }
65

66
    /**
67
     * Fluent setter for names given as array
68
     *
69
     * @return $this
70
     */
71
    public function names(array $names)
6✔
72
    {
73
        $this->names = $names;
6✔
74

75
        return $this;
6✔
76
    }
77

78
    /**
79
     * Fluent setter for language
80
     *
81
     * @param  null  $lang
82
     * @return $this
83
     */
84
    public function lang($lang = null)
6✔
85
    {
86
        $this->lang = $lang;
6✔
87

88
        return $this;
6✔
89
    }
90

91
    /**
92
     * Fluent setter for country
93
     *
94
     * @param  null  $country
95
     * @return $this
96
     */
97
    public function country($country = null)
6✔
98
    {
99
        $this->country = $country;
6✔
100

101
        return $this;
6✔
102
    }
103

104
    /**
105
     * Send the request
106
     *
107
     * @return GenderizeResponse
108
     */
109
    public function get()
3✔
110
    {
111
        $headers = ['Accept' => 'application/json'];
3✔
112

113
        $response = $this->request->get(self::API_URL, $headers, $this->buildQuery());
3✔
114

115
        return new GenderizeResponse($response);
3✔
116
    }
117

118
    /**
119
     * Build the query
120
     *
121
     * @return array
122
     */
123
    protected function buildQuery()
3✔
124
    {
125
        $query = [
126
            'name' => $this->names,
3✔
127
            'country_id' => $this->country,
3✔
128
            'language_id' => $this->lang,
3✔
129
            'apikey' => $this->apikey,
3✔
130
        ];
131

132
        return array_filter($query);
3✔
133
    }
134
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc