Skip to content

Commit 1d128fb

Browse files
Merge pull request #7 from ARCANEDEV/patch-1
Updating the package
2 parents c0ed826 + 7c2232c commit 1d128fb

File tree

10 files changed

+73
-89
lines changed

10 files changed

+73
-89
lines changed

.scrutinizer.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ checks:
2121
tools:
2222
external_code_coverage:
2323
timeout: 600
24-
runs: 2
24+
runs: 3
2525
php_code_sniffer:
2626
enabled: true
2727
config:

.travis.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ php:
1010

1111
matrix:
1212
allow_failures:
13-
- php: 7.2
1413
- php: nightly
1514

1615
before_script:
@@ -23,5 +22,5 @@ script:
2322
- vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover
2423

2524
after_script:
26-
- if [ "$TRAVIS_PHP_VERSION" != "7.2" ] && [ "$TRAVIS_PHP_VERSION" != "nightly" ]; then wget https://scrutinizer-ci.com/ocular.phar; fi
27-
- if [ "$TRAVIS_PHP_VERSION" != "7.2" ] && [ "$TRAVIS_PHP_VERSION" != "nightly" ]; then php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi
25+
- if [ "$TRAVIS_PHP_VERSION" != "nightly" ]; then wget https://scrutinizer-ci.com/ocular.phar; fi
26+
- if [ "$TRAVIS_PHP_VERSION" != "nightly" ]; then php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2015-2017 | ARCANEDEV - Gravatar
3+
Copyright (c) 2015-2018 | ARCANEDEV - Gravatar
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"license": "MIT",
1818
"require": {
1919
"php" : ">=7.0",
20-
"arcanedev/support": "~4.0"
20+
"arcanedev/support": "~4.2.0"
2121
},
2222
"require-dev": {
2323
"phpunit/phpunit": "~6.0",

config/gravatar.php

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,28 @@
33
// For more details: https://en.gravatar.com/site/implement/images/
44

55
return [
6-
/* ------------------------------------------------------------------------------------------------
6+
7+
/* -----------------------------------------------------------------
78
| Default
8-
| ------------------------------------------------------------------------------------------------
9-
| The default avatar to display if we have no results (you can also set a default image url).
9+
| -----------------------------------------------------------------
10+
| The default avatar to display if we have no results.
1011
|
11-
| Supported:
12-
| * false
13-
| * '404'
14-
| * 'mm' : (mystery-man) a simple, cartoon-style silhouetted outline of a person (does not vary by email hash).
15-
| * 'identicon' : a geometric pattern based on an email hash.
16-
| * 'monsterid' : a generated 'monster' with different colors, faces, etc.
17-
| * 'wavatar' : generated faces with differing features and backgrounds.
18-
| * 'retro' : awesome generated, 8-bit arcade-style pixelated faces.
12+
| Supported: 'identicon', '404', 'mm', 'monsterid', 'wavatar', 'retro', false
1913
*/
14+
2015
'default' => 'identicon',
2116

22-
/* ------------------------------------------------------------------------------------------------
17+
/* -----------------------------------------------------------------
2318
| Size
24-
| ------------------------------------------------------------------------------------------------
19+
| -----------------------------------------------------------------
2520
| The default avatar size.
2621
*/
22+
2723
'size' => 80,
2824

29-
/* ------------------------------------------------------------------------------------------------
25+
/* -----------------------------------------------------------------
3026
| Rating
31-
| ------------------------------------------------------------------------------------------------
27+
| -----------------------------------------------------------------
3228
| Set the type of avatars we allow to show.
3329
|
3430
| Supported:
@@ -37,5 +33,7 @@
3733
| * 'r' : may contain such things as harsh profanity, intense violence, nudity, or hard drug use.
3834
| * 'x' : may contain hardcore sexual imagery or extremely disturbing violence.
3935
*/
36+
4037
'max-rating' => 'g',
38+
4139
];

src/Gravatar.php

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -64,28 +64,14 @@ class Gravatar implements Contracts\Gravatar
6464
*
6565
* @var array
6666
*/
67-
private $supportedImages = [
68-
'404', // Do not load any image if none is associated with the email hash,
69-
// instead return an HTTP 404 response
70-
'mm', // (mystery-man) a simple, cartoon-style silhouetted outline of a person.
71-
'identicon', // a geometric pattern based on an email hash
72-
'monsterid', // a generated 'monster' with different colors, faces, etc
73-
'wavatar', // generated faces with differing features and backgrounds
74-
'retro', // awesome generated, 8-bit arcade-style pixelated faces
75-
// 'blank',
76-
];
67+
private $supportedImages = ['404', 'mm', 'identicon', 'monsterid', 'wavatar', 'retro'];
7768

7869
/**
7970
* Supported image ratings.
8071
*
8172
* @var array
8273
*/
83-
private $supportedRatings = [
84-
'g', // suitable for display on all websites with any audience type.
85-
'pg', // may contain rude gestures, provocatively dressed individuals, the lesser swear words, or mild violence.
86-
'r', // may contain such things as harsh profanity, intense violence, nudity, or hard drug use.
87-
'x' // may contain hardcore sexual imagery or extremely disturbing violence.
88-
];
74+
private $supportedRatings = ['g', 'pg', 'r', 'x'];
8975

9076
/* -----------------------------------------------------------------
9177
| Constructor
@@ -270,7 +256,7 @@ public function get($email, $hash = true)
270256

271257
$params = $this->getParams($email);
272258

273-
return $url . '?' . http_build_query($params);
259+
return $url.'?'.http_build_query($params);
274260
}
275261

276262
/**
@@ -293,9 +279,9 @@ public function image($email, $alt = null, array $attributes = [], $rating = nul
293279
? min(512, max($dimensions))
294280
: $this->getSize();
295281

296-
$src = $this->src($email, $size, $rating);
297-
298-
return HtmlBuilder::image($src, $alt, $attributes);
282+
return HtmlBuilder::image(
283+
$this->src($email, $size, $rating), $alt, $attributes
284+
);
299285
}
300286

301287
/**

src/Helpers/HtmlBuilder.php

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88
*/
99
class HtmlBuilder
1010
{
11-
/* ------------------------------------------------------------------------------------------------
12-
| Main Functions
13-
| ------------------------------------------------------------------------------------------------
11+
/* -----------------------------------------------------------------
12+
| Main Methods
13+
| -----------------------------------------------------------------
1414
*/
15+
1516
/**
1617
* Generate an HTML image element.
1718
*
@@ -25,7 +26,7 @@ public static function image($url, $alt = null, $attributes = [])
2526
{
2627
$attributes['alt'] = $alt;
2728

28-
return '<img src="' . $url . '"' . self::attributes($attributes) . '>';
29+
return '<img src="'.$url.'"'.static::attributes($attributes).'>';
2930
}
3031

3132

@@ -44,14 +45,19 @@ public static function attributes($attributes)
4445
// as this will convert HTML attributes such as "required" to a correct
4546
// form like required="required" instead of using incorrect numerics.
4647
foreach ((array) $attributes as $key => $value) {
47-
$html[] = self::attributeElement($key, $value);
48+
$html[] = static::attributeElement($key, $value);
4849
}
4950

5051
$html = array_filter($html);
5152

52-
return count($html) > 0 ? ' ' . implode(' ', $html) : '';
53+
return count($html) > 0 ? ' '.implode(' ', $html) : '';
5354
}
5455

56+
/* -----------------------------------------------------------------
57+
| Other Methods
58+
| -----------------------------------------------------------------
59+
*/
60+
5561
/**
5662
* Build a single attribute element.
5763
*
@@ -60,16 +66,11 @@ public static function attributes($attributes)
6066
*
6167
* @return string|null
6268
*/
63-
private static function attributeElement($key, $value)
69+
protected static function attributeElement($key, $value)
6470
{
65-
if (is_numeric($key)) {
71+
if (is_numeric($key))
6672
$key = $value;
67-
}
68-
69-
if ( ! is_null($value)) {
70-
return $key . '="' . htmlentities($value, ENT_QUOTES, 'UTF-8', false) . '"';
71-
}
7273

73-
return null;
74+
return is_null($value) ? null : $key.'="'.e($value).'"';
7475
}
7576
}

tests/GravatarServiceProviderTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class GravatarServiceProviderTest extends TestCase
1515
| -----------------------------------------------------------------
1616
*/
1717

18-
/** @var GravatarServiceProvider */
18+
/** @var \Arcanedev\Gravatar\GravatarServiceProvider */
1919
private $provider;
2020

2121
/* -----------------------------------------------------------------
@@ -53,7 +53,7 @@ public function it_can_be_instantiated()
5353
];
5454

5555
foreach ($expectations as $expected) {
56-
$this->assertInstanceOf($expected, $this->provider);
56+
static::assertInstanceOf($expected, $this->provider);
5757
}
5858
}
5959

@@ -64,6 +64,6 @@ public function it_can_provides()
6464
\Arcanedev\Gravatar\Contracts\Gravatar::class,
6565
];
6666

67-
$this->assertSame($expected, $this->provider->provides());
67+
static::assertSame($expected, $this->provider->provides());
6868
}
6969
}

0 commit comments

Comments
 (0)