Skip to content

Feature/improve implementation #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.neon]
indent_size = 2

[*.xml.dist]
indent_size = 2
Comment on lines +1 to +18

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you base this off of what the current file was or did you just make it?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. This is based on how to easily autoformat the package files on IDE. It is used as a baseline so that PHPStorm or Vscode or any IDE can easily format the file on saving or on editing. Most PHP libraries comes with those to have a unify coding practice/style.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know what .editorconfig is, I was just asking how you came up with the values for the configuration.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value are the on I use ... the default is set for PHP according to PHP standard coding style from PSR-1

The other also stem form standard practices in PHP world

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, makes sense.

7 changes: 7 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
* text=auto

/.editorconfig export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/phpstan.neon export-ignore
/README.md export-ignore
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
vendor
.idea
composer.lock
1,243 changes: 642 additions & 601 deletions Multiavatar.php

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ composer require multiavatar/multiavatar-php
### Usage ###

```
$multiavatar = new Multiavatar();
$avatarId = "Binx Bond";
$multiavatar = new Multiavatar($avatarId, null, null);
echo($multiavatar->svgCode);
echo $multiavatar($avatarId);
```

For advanced usage, pass boolean `true` as the second parameter if you wish to generate an avatar without the environment part.

Pass an associative array as the third parameter to generate a specific avatar version.

```
$multiavatar = new Multiavatar();
$avatarId = "ANY_STRING";
$multiavatar = new Multiavatar($avatarId, true, array("part" => 11, "theme" => "C"));
echo($multiavatar->svgCode);
echo $multiavatar($avatarId, true, ["part" => "11", "theme" => "C"]);
```

See `index.php` for examples.
Expand Down Expand Up @@ -88,4 +88,4 @@ For additional information and extended functionality, visit the [multiavatar.co

The app is based on static html for the home page, and on Laravel 8 + Vue.js for extended functionality, including the web store.

The product mockup generator for the [Merch Maker](https://multiavatar.com/merch-maker) is based on the ImageMagick PHP library.
The product mockup generator for the [Merch Maker](https://multiavatar.com/merch-maker) is based on the ImageMagick PHP library.
10 changes: 10 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,15 @@
],
"autoload": {
"classmap": ["Multiavatar.php"]
},
"require-dev": {
"phpstan/phpstan": "^0.12.63",
"phpstan/phpstan-strict-rules": "^0.12.7"
},
"scripts": {
"phpstan": "phpstan analyse --level max Multiavatar.php -c phpstan.neon --ansi"
},
"scripts-descriptions": {
"phpstan": "Static analysis of PHP scripts"
}
}
32 changes: 11 additions & 21 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,36 +1,26 @@
<?php

require_once("Multiavatar.php");
require_once "Multiavatar.php";

$multiAvatar = new Multiavatar();

$avatarId = "Starcrasher";
$multiavatar = new Multiavatar($avatarId, null, null);
echo($multiavatar->svgCode);

echo $multiAvatar($avatarId);

// Without the environment part
$avatarId = "Pandalion";
$multiavatar = new Multiavatar($avatarId, true, null);
echo($multiavatar->svgCode);

// $avatarId = "Pandalion";
// echo $multiAvatar($avatarId, true);

// Generate a specific version
$avatarId = "Pandalion";
$multiavatar = new Multiavatar($avatarId, null, array("part" => 11, "theme" => "C"));
echo($multiavatar->svgCode);

// $avatarId = "Pandalion";
// echo $multiAvatar($avatarId, false, ["part" => 11, "theme" => "C"]);

// Test with integer
$avatarId = 123456789;
$multiavatar = new Multiavatar($avatarId, null, null);
echo($multiavatar->svgCode);

// $avatarId = 123456789;
// echo $multiAvatar($avatarId);

// $avatarId = "a86f755add37fe0b649c";
// $multiavatar = new Multiavatar($avatarId, null, null);
// echo($multiavatar->svgCode);

// echo $multiAvatar($avatarId);

// $avatarId = "f7542474d54d2d2d97e4";
// $multiavatar = new Multiavatar($avatarId, null, null);
// echo($multiavatar->svgCode);
// echo $multiAvatar($avatarId);
5 changes: 5 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
includes:
- vendor/phpstan/phpstan-strict-rules/rules.neon
parameters:
ignoreErrors:
reportUnmatchedIgnoredErrors: true