Skip to content

Commit 0aa467f

Browse files
committed
Initial release
0 parents  commit 0aa467f

15 files changed

+2423
-0
lines changed

.coveralls.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
coverage_clover: build/logs/clover.xml
2+
json_path: build/logs/coveralls-upload.json
3+
service_name: travis-ci

.styleci

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
preset: recommended
2+
3+
risky: false
4+
5+
enabled:
6+
- align_equals
7+
- linebreak_after_opening_tag
8+
- mb_str_functions
9+
- phpdoc_align
10+
11+
disabled:
12+
- unalign_equals
13+
- no_spaces_after_function_name
14+
- no_spaces_inside_offset
15+
- no_spaces_inside_parenthesis
16+
- no_spaces_outside_offset
17+
- no_tab_indentation
18+
19+
finder:
20+
exclude:
21+
- "vendor"

.travis.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
language: php
2+
3+
php:
4+
- 5.6
5+
- 7.0
6+
- 7.1
7+
8+
before_script:
9+
- mkdir -p build/logs
10+
- composer self-update
11+
- composer install --prefer-source --no-interaction --dev
12+
13+
script:
14+
- vendor/bin/phpunit --coverage-clover build/logs/clover.xml
15+
16+
after_script:
17+
- php vendor/bin/coveralls -v
18+
19+
after_success:
20+
- sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then php vendor/bin/coveralls -v; fi;'

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# The MIT License (MIT)
2+
3+
Copyright (c) 2017 Lasse Rafn <lasserafn@gmail.com>
4+
5+
> Permission is hereby granted, free of charge, to any person obtaining a copy
6+
> of this software and associated documentation files (the "Software"), to deal
7+
> in the Software without restriction, including without limitation the rights
8+
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
> copies of the Software, and to permit persons to whom the Software is
10+
> furnished to do so, subject to the following conditions:
11+
>
12+
> The above copyright notice and this permission notice shall be included in
13+
> all copies or substantial portions of the Software.
14+
>
15+
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
> THE SOFTWARE.

README.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Modify HEX brightness
2+
3+
Ever wanted to lighten or darken a hex in PHP? This package will allow you to.
4+
5+
<p align="center">
6+
<a href="https://travis-ci.org/LasseRafn/php-hexer"><img src="https://img.shields.io/travis/LasseRafn/php-hexer.svg?style=flat-square" alt="Build Status"></a>
7+
<a href="https://coveralls.io/github/LasseRafn/php-hexer"><img src="https://img.shields.io/coveralls/LasseRafn/php-hexer.svg?style=flat-square" alt="Coverage"></a>
8+
<a href="https://styleci.io/repos/78973710"><img src="https://styleci.io/repos/78973710/shield?branch=master" alt="StyleCI Status"></a>
9+
<a href="https://packagist.org/packages/LasseRafn/php-hexer"><img src="https://img.shields.io/packagist/dt/LasseRafn/php-hexer.svg?style=flat-square" alt="Total Downloads"></a>
10+
<a href="https://packagist.org/packages/LasseRafn/php-hexer"><img src="https://img.shields.io/packagist/v/LasseRafn/php-hexer.svg?style=flat-square" alt="Latest Stable Version"></a>
11+
<a href="https://packagist.org/packages/LasseRafn/php-hexer"><img src="https://img.shields.io/packagist/l/LasseRafn/php-hexer.svg?style=flat-square" alt="License"></a>
12+
</p>
13+
14+
## Installation
15+
16+
You just require using composer and you're good to go!
17+
18+
```bash
19+
composer require lasserafn/php-hexer
20+
```
21+
22+
## Usage
23+
24+
As with installation, usage is quite simple.
25+
26+
```php
27+
use LasseRafn\Hexer\Hex;
28+
29+
// Lighten
30+
$hex = new Hex('#333'); // You can leave out the hashtag if you wish.
31+
echo $hex->lighten(15); // Output: #595959 (if you left out the hashtag, it would not be included in the output either)
32+
33+
// Darken
34+
$hex = new Hex('#fff');
35+
echo $hex->darken(15);
36+
```
37+
38+
## Methods
39+
40+
There are only two methods, that both accept just one parameter.
41+
42+
### `lighten($percentage)`
43+
44+
Will lighten the color by X percentage. Percentage must be between 0-100. An exception will be thrown otherwise.
45+
46+
### `darken($percentage)`
47+
48+
Will darken the color by X percentage. Percentage must be between 0-100. An exception will be thrown otherwise.
49+
50+
## Exceptions
51+
52+
If you input a HEX which is less than 3 characters of length, or greater than 6, an exception will be thrown. Similar with percentages, if you specify a percentage less than zero, or greater than 100, an exception will be thrown. If the percentage *is* zero, the hex itself will simply be returned.
53+
54+
## Requirements
55+
* PHP 5.6, 7.0 or 7.1

composer.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"name": "lasserafn/php-hexer",
3+
"description": "A package to adjust brightness from a hex colorcode",
4+
"keywords": [
5+
"hex",
6+
"color",
7+
"brightness",
8+
"php"
9+
],
10+
"type": "library",
11+
"license": "MIT",
12+
"authors": [
13+
{
14+
"name": "Lasse Rafn",
15+
"email": "lasserafn@gmail.com"
16+
}
17+
],
18+
"require": {
19+
"php": "^5.6|^7.0|^7.1"
20+
},
21+
"require-dev": {
22+
"phpunit/phpunit": "^5.7",
23+
"satooshi/php-coveralls": "^1.0"
24+
},
25+
"autoload": {
26+
"psr-4": {
27+
"LasseRafn\\Hexer\\": "src/"
28+
}
29+
},
30+
"autoload-dev": {
31+
"psr-4": {
32+
"Hexer\\Tests\\": "tests/"
33+
}
34+
},
35+
"config": {
36+
"sort-packages": true
37+
}
38+
}

0 commit comments

Comments
 (0)