├── .gitignore ├── LICENSE ├── composer.json ├── composer.lock ├── phpunit.xml ├── readme.md ├── src └── FontAwesomeSVG.php └── tests ├── Fixtures └── icons │ ├── brands │ └── test.svg │ ├── duotone │ └── test.svg │ ├── light │ └── test.svg │ ├── regular │ └── test.svg │ ├── sharp-light │ └── test.svg │ ├── sharp-regular │ └── test.svg │ ├── sharp-solid │ └── test.svg │ ├── solid │ └── test.svg │ └── thin │ └── test.svg └── Unit └── FontAwesomeSVGTest.php /.gitignore: -------------------------------------------------------------------------------- 1 | fontawesome-svgs/ 2 | .tinkerwell 3 | vendor/ 4 | .phpunit.cache 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Hussein Al Hammad 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 all 13 | 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 THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "husseinalhammad/fontawesome-svg", 3 | "description": "PHP class to add Font Awesome 5+'s SVG icons inline without Javascript.", 4 | "keywords": ["fontawesome", "svg"], 5 | "license": "MIT", 6 | "homepage": "https://github.com/husseinalhammad/FontAwesomeSVG-PHP", 7 | "authors": [ 8 | { 9 | "name": "Hussein Al Hammad", 10 | "email": "contact@hussein-alhammad.com", 11 | "homepage": "https://hussein-alhammad.com" 12 | } 13 | ], 14 | "require": { 15 | "php": ">=5.3.0" 16 | }, 17 | "autoload": { 18 | "classmap": ["src"] 19 | }, 20 | "autoload-dev": { 21 | "psr-4": { 22 | "Husseinalhammad\\FontawesomeSvg\\Tests\\": "tests" 23 | } 24 | }, 25 | "require-dev": { 26 | "phpunit/phpunit": "^10.2" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", 5 | "This file is @generated automatically" 6 | ], 7 | "content-hash": "1fc48dfb02d43a242215dece55b2bda1", 8 | "packages": [], 9 | "packages-dev": [ 10 | { 11 | "name": "myclabs/deep-copy", 12 | "version": "1.11.1", 13 | "source": { 14 | "type": "git", 15 | "url": "https://github.com/myclabs/DeepCopy.git", 16 | "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c" 17 | }, 18 | "dist": { 19 | "type": "zip", 20 | "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", 21 | "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", 22 | "shasum": "" 23 | }, 24 | "require": { 25 | "php": "^7.1 || ^8.0" 26 | }, 27 | "conflict": { 28 | "doctrine/collections": "<1.6.8", 29 | "doctrine/common": "<2.13.3 || >=3,<3.2.2" 30 | }, 31 | "require-dev": { 32 | "doctrine/collections": "^1.6.8", 33 | "doctrine/common": "^2.13.3 || ^3.2.2", 34 | "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13" 35 | }, 36 | "type": "library", 37 | "autoload": { 38 | "files": [ 39 | "src/DeepCopy/deep_copy.php" 40 | ], 41 | "psr-4": { 42 | "DeepCopy\\": "src/DeepCopy/" 43 | } 44 | }, 45 | "notification-url": "https://packagist.org/downloads/", 46 | "license": [ 47 | "MIT" 48 | ], 49 | "description": "Create deep copies (clones) of your objects", 50 | "keywords": [ 51 | "clone", 52 | "copy", 53 | "duplicate", 54 | "object", 55 | "object graph" 56 | ], 57 | "support": { 58 | "issues": "https://github.com/myclabs/DeepCopy/issues", 59 | "source": "https://github.com/myclabs/DeepCopy/tree/1.11.1" 60 | }, 61 | "funding": [ 62 | { 63 | "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", 64 | "type": "tidelift" 65 | } 66 | ], 67 | "time": "2023-03-08T13:26:56+00:00" 68 | }, 69 | { 70 | "name": "nikic/php-parser", 71 | "version": "v4.16.0", 72 | "source": { 73 | "type": "git", 74 | "url": "https://github.com/nikic/PHP-Parser.git", 75 | "reference": "19526a33fb561ef417e822e85f08a00db4059c17" 76 | }, 77 | "dist": { 78 | "type": "zip", 79 | "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/19526a33fb561ef417e822e85f08a00db4059c17", 80 | "reference": "19526a33fb561ef417e822e85f08a00db4059c17", 81 | "shasum": "" 82 | }, 83 | "require": { 84 | "ext-tokenizer": "*", 85 | "php": ">=7.0" 86 | }, 87 | "require-dev": { 88 | "ircmaxell/php-yacc": "^0.0.7", 89 | "phpunit/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0" 90 | }, 91 | "bin": [ 92 | "bin/php-parse" 93 | ], 94 | "type": "library", 95 | "extra": { 96 | "branch-alias": { 97 | "dev-master": "4.9-dev" 98 | } 99 | }, 100 | "autoload": { 101 | "psr-4": { 102 | "PhpParser\\": "lib/PhpParser" 103 | } 104 | }, 105 | "notification-url": "https://packagist.org/downloads/", 106 | "license": [ 107 | "BSD-3-Clause" 108 | ], 109 | "authors": [ 110 | { 111 | "name": "Nikita Popov" 112 | } 113 | ], 114 | "description": "A PHP parser written in PHP", 115 | "keywords": [ 116 | "parser", 117 | "php" 118 | ], 119 | "support": { 120 | "issues": "https://github.com/nikic/PHP-Parser/issues", 121 | "source": "https://github.com/nikic/PHP-Parser/tree/v4.16.0" 122 | }, 123 | "time": "2023-06-25T14:52:30+00:00" 124 | }, 125 | { 126 | "name": "phar-io/manifest", 127 | "version": "2.0.3", 128 | "source": { 129 | "type": "git", 130 | "url": "https://github.com/phar-io/manifest.git", 131 | "reference": "97803eca37d319dfa7826cc2437fc020857acb53" 132 | }, 133 | "dist": { 134 | "type": "zip", 135 | "url": "https://api.github.com/repos/phar-io/manifest/zipball/97803eca37d319dfa7826cc2437fc020857acb53", 136 | "reference": "97803eca37d319dfa7826cc2437fc020857acb53", 137 | "shasum": "" 138 | }, 139 | "require": { 140 | "ext-dom": "*", 141 | "ext-phar": "*", 142 | "ext-xmlwriter": "*", 143 | "phar-io/version": "^3.0.1", 144 | "php": "^7.2 || ^8.0" 145 | }, 146 | "type": "library", 147 | "extra": { 148 | "branch-alias": { 149 | "dev-master": "2.0.x-dev" 150 | } 151 | }, 152 | "autoload": { 153 | "classmap": [ 154 | "src/" 155 | ] 156 | }, 157 | "notification-url": "https://packagist.org/downloads/", 158 | "license": [ 159 | "BSD-3-Clause" 160 | ], 161 | "authors": [ 162 | { 163 | "name": "Arne Blankerts", 164 | "email": "arne@blankerts.de", 165 | "role": "Developer" 166 | }, 167 | { 168 | "name": "Sebastian Heuer", 169 | "email": "sebastian@phpeople.de", 170 | "role": "Developer" 171 | }, 172 | { 173 | "name": "Sebastian Bergmann", 174 | "email": "sebastian@phpunit.de", 175 | "role": "Developer" 176 | } 177 | ], 178 | "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", 179 | "support": { 180 | "issues": "https://github.com/phar-io/manifest/issues", 181 | "source": "https://github.com/phar-io/manifest/tree/2.0.3" 182 | }, 183 | "time": "2021-07-20T11:28:43+00:00" 184 | }, 185 | { 186 | "name": "phar-io/version", 187 | "version": "3.2.1", 188 | "source": { 189 | "type": "git", 190 | "url": "https://github.com/phar-io/version.git", 191 | "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74" 192 | }, 193 | "dist": { 194 | "type": "zip", 195 | "url": "https://api.github.com/repos/phar-io/version/zipball/4f7fd7836c6f332bb2933569e566a0d6c4cbed74", 196 | "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74", 197 | "shasum": "" 198 | }, 199 | "require": { 200 | "php": "^7.2 || ^8.0" 201 | }, 202 | "type": "library", 203 | "autoload": { 204 | "classmap": [ 205 | "src/" 206 | ] 207 | }, 208 | "notification-url": "https://packagist.org/downloads/", 209 | "license": [ 210 | "BSD-3-Clause" 211 | ], 212 | "authors": [ 213 | { 214 | "name": "Arne Blankerts", 215 | "email": "arne@blankerts.de", 216 | "role": "Developer" 217 | }, 218 | { 219 | "name": "Sebastian Heuer", 220 | "email": "sebastian@phpeople.de", 221 | "role": "Developer" 222 | }, 223 | { 224 | "name": "Sebastian Bergmann", 225 | "email": "sebastian@phpunit.de", 226 | "role": "Developer" 227 | } 228 | ], 229 | "description": "Library for handling version information and constraints", 230 | "support": { 231 | "issues": "https://github.com/phar-io/version/issues", 232 | "source": "https://github.com/phar-io/version/tree/3.2.1" 233 | }, 234 | "time": "2022-02-21T01:04:05+00:00" 235 | }, 236 | { 237 | "name": "phpunit/php-code-coverage", 238 | "version": "10.1.2", 239 | "source": { 240 | "type": "git", 241 | "url": "https://github.com/sebastianbergmann/php-code-coverage.git", 242 | "reference": "db1497ec8dd382e82c962f7abbe0320e4882ee4e" 243 | }, 244 | "dist": { 245 | "type": "zip", 246 | "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/db1497ec8dd382e82c962f7abbe0320e4882ee4e", 247 | "reference": "db1497ec8dd382e82c962f7abbe0320e4882ee4e", 248 | "shasum": "" 249 | }, 250 | "require": { 251 | "ext-dom": "*", 252 | "ext-libxml": "*", 253 | "ext-xmlwriter": "*", 254 | "nikic/php-parser": "^4.15", 255 | "php": ">=8.1", 256 | "phpunit/php-file-iterator": "^4.0", 257 | "phpunit/php-text-template": "^3.0", 258 | "sebastian/code-unit-reverse-lookup": "^3.0", 259 | "sebastian/complexity": "^3.0", 260 | "sebastian/environment": "^6.0", 261 | "sebastian/lines-of-code": "^2.0", 262 | "sebastian/version": "^4.0", 263 | "theseer/tokenizer": "^1.2.0" 264 | }, 265 | "require-dev": { 266 | "phpunit/phpunit": "^10.1" 267 | }, 268 | "suggest": { 269 | "ext-pcov": "PHP extension that provides line coverage", 270 | "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage" 271 | }, 272 | "type": "library", 273 | "extra": { 274 | "branch-alias": { 275 | "dev-main": "10.1-dev" 276 | } 277 | }, 278 | "autoload": { 279 | "classmap": [ 280 | "src/" 281 | ] 282 | }, 283 | "notification-url": "https://packagist.org/downloads/", 284 | "license": [ 285 | "BSD-3-Clause" 286 | ], 287 | "authors": [ 288 | { 289 | "name": "Sebastian Bergmann", 290 | "email": "sebastian@phpunit.de", 291 | "role": "lead" 292 | } 293 | ], 294 | "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", 295 | "homepage": "https://github.com/sebastianbergmann/php-code-coverage", 296 | "keywords": [ 297 | "coverage", 298 | "testing", 299 | "xunit" 300 | ], 301 | "support": { 302 | "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", 303 | "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", 304 | "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.2" 305 | }, 306 | "funding": [ 307 | { 308 | "url": "https://github.com/sebastianbergmann", 309 | "type": "github" 310 | } 311 | ], 312 | "time": "2023-05-22T09:04:27+00:00" 313 | }, 314 | { 315 | "name": "phpunit/php-file-iterator", 316 | "version": "4.0.2", 317 | "source": { 318 | "type": "git", 319 | "url": "https://github.com/sebastianbergmann/php-file-iterator.git", 320 | "reference": "5647d65443818959172645e7ed999217360654b6" 321 | }, 322 | "dist": { 323 | "type": "zip", 324 | "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/5647d65443818959172645e7ed999217360654b6", 325 | "reference": "5647d65443818959172645e7ed999217360654b6", 326 | "shasum": "" 327 | }, 328 | "require": { 329 | "php": ">=8.1" 330 | }, 331 | "require-dev": { 332 | "phpunit/phpunit": "^10.0" 333 | }, 334 | "type": "library", 335 | "extra": { 336 | "branch-alias": { 337 | "dev-main": "4.0-dev" 338 | } 339 | }, 340 | "autoload": { 341 | "classmap": [ 342 | "src/" 343 | ] 344 | }, 345 | "notification-url": "https://packagist.org/downloads/", 346 | "license": [ 347 | "BSD-3-Clause" 348 | ], 349 | "authors": [ 350 | { 351 | "name": "Sebastian Bergmann", 352 | "email": "sebastian@phpunit.de", 353 | "role": "lead" 354 | } 355 | ], 356 | "description": "FilterIterator implementation that filters files based on a list of suffixes.", 357 | "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", 358 | "keywords": [ 359 | "filesystem", 360 | "iterator" 361 | ], 362 | "support": { 363 | "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", 364 | "security": "https://github.com/sebastianbergmann/php-file-iterator/security/policy", 365 | "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/4.0.2" 366 | }, 367 | "funding": [ 368 | { 369 | "url": "https://github.com/sebastianbergmann", 370 | "type": "github" 371 | } 372 | ], 373 | "time": "2023-05-07T09:13:23+00:00" 374 | }, 375 | { 376 | "name": "phpunit/php-invoker", 377 | "version": "4.0.0", 378 | "source": { 379 | "type": "git", 380 | "url": "https://github.com/sebastianbergmann/php-invoker.git", 381 | "reference": "f5e568ba02fa5ba0ddd0f618391d5a9ea50b06d7" 382 | }, 383 | "dist": { 384 | "type": "zip", 385 | "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/f5e568ba02fa5ba0ddd0f618391d5a9ea50b06d7", 386 | "reference": "f5e568ba02fa5ba0ddd0f618391d5a9ea50b06d7", 387 | "shasum": "" 388 | }, 389 | "require": { 390 | "php": ">=8.1" 391 | }, 392 | "require-dev": { 393 | "ext-pcntl": "*", 394 | "phpunit/phpunit": "^10.0" 395 | }, 396 | "suggest": { 397 | "ext-pcntl": "*" 398 | }, 399 | "type": "library", 400 | "extra": { 401 | "branch-alias": { 402 | "dev-main": "4.0-dev" 403 | } 404 | }, 405 | "autoload": { 406 | "classmap": [ 407 | "src/" 408 | ] 409 | }, 410 | "notification-url": "https://packagist.org/downloads/", 411 | "license": [ 412 | "BSD-3-Clause" 413 | ], 414 | "authors": [ 415 | { 416 | "name": "Sebastian Bergmann", 417 | "email": "sebastian@phpunit.de", 418 | "role": "lead" 419 | } 420 | ], 421 | "description": "Invoke callables with a timeout", 422 | "homepage": "https://github.com/sebastianbergmann/php-invoker/", 423 | "keywords": [ 424 | "process" 425 | ], 426 | "support": { 427 | "issues": "https://github.com/sebastianbergmann/php-invoker/issues", 428 | "source": "https://github.com/sebastianbergmann/php-invoker/tree/4.0.0" 429 | }, 430 | "funding": [ 431 | { 432 | "url": "https://github.com/sebastianbergmann", 433 | "type": "github" 434 | } 435 | ], 436 | "time": "2023-02-03T06:56:09+00:00" 437 | }, 438 | { 439 | "name": "phpunit/php-text-template", 440 | "version": "3.0.0", 441 | "source": { 442 | "type": "git", 443 | "url": "https://github.com/sebastianbergmann/php-text-template.git", 444 | "reference": "9f3d3709577a527025f55bcf0f7ab8052c8bb37d" 445 | }, 446 | "dist": { 447 | "type": "zip", 448 | "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/9f3d3709577a527025f55bcf0f7ab8052c8bb37d", 449 | "reference": "9f3d3709577a527025f55bcf0f7ab8052c8bb37d", 450 | "shasum": "" 451 | }, 452 | "require": { 453 | "php": ">=8.1" 454 | }, 455 | "require-dev": { 456 | "phpunit/phpunit": "^10.0" 457 | }, 458 | "type": "library", 459 | "extra": { 460 | "branch-alias": { 461 | "dev-main": "3.0-dev" 462 | } 463 | }, 464 | "autoload": { 465 | "classmap": [ 466 | "src/" 467 | ] 468 | }, 469 | "notification-url": "https://packagist.org/downloads/", 470 | "license": [ 471 | "BSD-3-Clause" 472 | ], 473 | "authors": [ 474 | { 475 | "name": "Sebastian Bergmann", 476 | "email": "sebastian@phpunit.de", 477 | "role": "lead" 478 | } 479 | ], 480 | "description": "Simple template engine.", 481 | "homepage": "https://github.com/sebastianbergmann/php-text-template/", 482 | "keywords": [ 483 | "template" 484 | ], 485 | "support": { 486 | "issues": "https://github.com/sebastianbergmann/php-text-template/issues", 487 | "source": "https://github.com/sebastianbergmann/php-text-template/tree/3.0.0" 488 | }, 489 | "funding": [ 490 | { 491 | "url": "https://github.com/sebastianbergmann", 492 | "type": "github" 493 | } 494 | ], 495 | "time": "2023-02-03T06:56:46+00:00" 496 | }, 497 | { 498 | "name": "phpunit/php-timer", 499 | "version": "6.0.0", 500 | "source": { 501 | "type": "git", 502 | "url": "https://github.com/sebastianbergmann/php-timer.git", 503 | "reference": "e2a2d67966e740530f4a3343fe2e030ffdc1161d" 504 | }, 505 | "dist": { 506 | "type": "zip", 507 | "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/e2a2d67966e740530f4a3343fe2e030ffdc1161d", 508 | "reference": "e2a2d67966e740530f4a3343fe2e030ffdc1161d", 509 | "shasum": "" 510 | }, 511 | "require": { 512 | "php": ">=8.1" 513 | }, 514 | "require-dev": { 515 | "phpunit/phpunit": "^10.0" 516 | }, 517 | "type": "library", 518 | "extra": { 519 | "branch-alias": { 520 | "dev-main": "6.0-dev" 521 | } 522 | }, 523 | "autoload": { 524 | "classmap": [ 525 | "src/" 526 | ] 527 | }, 528 | "notification-url": "https://packagist.org/downloads/", 529 | "license": [ 530 | "BSD-3-Clause" 531 | ], 532 | "authors": [ 533 | { 534 | "name": "Sebastian Bergmann", 535 | "email": "sebastian@phpunit.de", 536 | "role": "lead" 537 | } 538 | ], 539 | "description": "Utility class for timing", 540 | "homepage": "https://github.com/sebastianbergmann/php-timer/", 541 | "keywords": [ 542 | "timer" 543 | ], 544 | "support": { 545 | "issues": "https://github.com/sebastianbergmann/php-timer/issues", 546 | "source": "https://github.com/sebastianbergmann/php-timer/tree/6.0.0" 547 | }, 548 | "funding": [ 549 | { 550 | "url": "https://github.com/sebastianbergmann", 551 | "type": "github" 552 | } 553 | ], 554 | "time": "2023-02-03T06:57:52+00:00" 555 | }, 556 | { 557 | "name": "phpunit/phpunit", 558 | "version": "10.2.3", 559 | "source": { 560 | "type": "git", 561 | "url": "https://github.com/sebastianbergmann/phpunit.git", 562 | "reference": "35c8cac1734ede2ae354a6644f7088356ff5b08e" 563 | }, 564 | "dist": { 565 | "type": "zip", 566 | "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/35c8cac1734ede2ae354a6644f7088356ff5b08e", 567 | "reference": "35c8cac1734ede2ae354a6644f7088356ff5b08e", 568 | "shasum": "" 569 | }, 570 | "require": { 571 | "ext-dom": "*", 572 | "ext-json": "*", 573 | "ext-libxml": "*", 574 | "ext-mbstring": "*", 575 | "ext-xml": "*", 576 | "ext-xmlwriter": "*", 577 | "myclabs/deep-copy": "^1.10.1", 578 | "phar-io/manifest": "^2.0.3", 579 | "phar-io/version": "^3.0.2", 580 | "php": ">=8.1", 581 | "phpunit/php-code-coverage": "^10.1.1", 582 | "phpunit/php-file-iterator": "^4.0", 583 | "phpunit/php-invoker": "^4.0", 584 | "phpunit/php-text-template": "^3.0", 585 | "phpunit/php-timer": "^6.0", 586 | "sebastian/cli-parser": "^2.0", 587 | "sebastian/code-unit": "^2.0", 588 | "sebastian/comparator": "^5.0", 589 | "sebastian/diff": "^5.0", 590 | "sebastian/environment": "^6.0", 591 | "sebastian/exporter": "^5.0", 592 | "sebastian/global-state": "^6.0", 593 | "sebastian/object-enumerator": "^5.0", 594 | "sebastian/recursion-context": "^5.0", 595 | "sebastian/type": "^4.0", 596 | "sebastian/version": "^4.0" 597 | }, 598 | "suggest": { 599 | "ext-soap": "To be able to generate mocks based on WSDL files" 600 | }, 601 | "bin": [ 602 | "phpunit" 603 | ], 604 | "type": "library", 605 | "extra": { 606 | "branch-alias": { 607 | "dev-main": "10.2-dev" 608 | } 609 | }, 610 | "autoload": { 611 | "files": [ 612 | "src/Framework/Assert/Functions.php" 613 | ], 614 | "classmap": [ 615 | "src/" 616 | ] 617 | }, 618 | "notification-url": "https://packagist.org/downloads/", 619 | "license": [ 620 | "BSD-3-Clause" 621 | ], 622 | "authors": [ 623 | { 624 | "name": "Sebastian Bergmann", 625 | "email": "sebastian@phpunit.de", 626 | "role": "lead" 627 | } 628 | ], 629 | "description": "The PHP Unit Testing framework.", 630 | "homepage": "https://phpunit.de/", 631 | "keywords": [ 632 | "phpunit", 633 | "testing", 634 | "xunit" 635 | ], 636 | "support": { 637 | "issues": "https://github.com/sebastianbergmann/phpunit/issues", 638 | "security": "https://github.com/sebastianbergmann/phpunit/security/policy", 639 | "source": "https://github.com/sebastianbergmann/phpunit/tree/10.2.3" 640 | }, 641 | "funding": [ 642 | { 643 | "url": "https://phpunit.de/sponsors.html", 644 | "type": "custom" 645 | }, 646 | { 647 | "url": "https://github.com/sebastianbergmann", 648 | "type": "github" 649 | }, 650 | { 651 | "url": "https://tidelift.com/funding/github/packagist/phpunit/phpunit", 652 | "type": "tidelift" 653 | } 654 | ], 655 | "time": "2023-06-30T06:17:38+00:00" 656 | }, 657 | { 658 | "name": "sebastian/cli-parser", 659 | "version": "2.0.0", 660 | "source": { 661 | "type": "git", 662 | "url": "https://github.com/sebastianbergmann/cli-parser.git", 663 | "reference": "efdc130dbbbb8ef0b545a994fd811725c5282cae" 664 | }, 665 | "dist": { 666 | "type": "zip", 667 | "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/efdc130dbbbb8ef0b545a994fd811725c5282cae", 668 | "reference": "efdc130dbbbb8ef0b545a994fd811725c5282cae", 669 | "shasum": "" 670 | }, 671 | "require": { 672 | "php": ">=8.1" 673 | }, 674 | "require-dev": { 675 | "phpunit/phpunit": "^10.0" 676 | }, 677 | "type": "library", 678 | "extra": { 679 | "branch-alias": { 680 | "dev-main": "2.0-dev" 681 | } 682 | }, 683 | "autoload": { 684 | "classmap": [ 685 | "src/" 686 | ] 687 | }, 688 | "notification-url": "https://packagist.org/downloads/", 689 | "license": [ 690 | "BSD-3-Clause" 691 | ], 692 | "authors": [ 693 | { 694 | "name": "Sebastian Bergmann", 695 | "email": "sebastian@phpunit.de", 696 | "role": "lead" 697 | } 698 | ], 699 | "description": "Library for parsing CLI options", 700 | "homepage": "https://github.com/sebastianbergmann/cli-parser", 701 | "support": { 702 | "issues": "https://github.com/sebastianbergmann/cli-parser/issues", 703 | "source": "https://github.com/sebastianbergmann/cli-parser/tree/2.0.0" 704 | }, 705 | "funding": [ 706 | { 707 | "url": "https://github.com/sebastianbergmann", 708 | "type": "github" 709 | } 710 | ], 711 | "time": "2023-02-03T06:58:15+00:00" 712 | }, 713 | { 714 | "name": "sebastian/code-unit", 715 | "version": "2.0.0", 716 | "source": { 717 | "type": "git", 718 | "url": "https://github.com/sebastianbergmann/code-unit.git", 719 | "reference": "a81fee9eef0b7a76af11d121767abc44c104e503" 720 | }, 721 | "dist": { 722 | "type": "zip", 723 | "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/a81fee9eef0b7a76af11d121767abc44c104e503", 724 | "reference": "a81fee9eef0b7a76af11d121767abc44c104e503", 725 | "shasum": "" 726 | }, 727 | "require": { 728 | "php": ">=8.1" 729 | }, 730 | "require-dev": { 731 | "phpunit/phpunit": "^10.0" 732 | }, 733 | "type": "library", 734 | "extra": { 735 | "branch-alias": { 736 | "dev-main": "2.0-dev" 737 | } 738 | }, 739 | "autoload": { 740 | "classmap": [ 741 | "src/" 742 | ] 743 | }, 744 | "notification-url": "https://packagist.org/downloads/", 745 | "license": [ 746 | "BSD-3-Clause" 747 | ], 748 | "authors": [ 749 | { 750 | "name": "Sebastian Bergmann", 751 | "email": "sebastian@phpunit.de", 752 | "role": "lead" 753 | } 754 | ], 755 | "description": "Collection of value objects that represent the PHP code units", 756 | "homepage": "https://github.com/sebastianbergmann/code-unit", 757 | "support": { 758 | "issues": "https://github.com/sebastianbergmann/code-unit/issues", 759 | "source": "https://github.com/sebastianbergmann/code-unit/tree/2.0.0" 760 | }, 761 | "funding": [ 762 | { 763 | "url": "https://github.com/sebastianbergmann", 764 | "type": "github" 765 | } 766 | ], 767 | "time": "2023-02-03T06:58:43+00:00" 768 | }, 769 | { 770 | "name": "sebastian/code-unit-reverse-lookup", 771 | "version": "3.0.0", 772 | "source": { 773 | "type": "git", 774 | "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", 775 | "reference": "5e3a687f7d8ae33fb362c5c0743794bbb2420a1d" 776 | }, 777 | "dist": { 778 | "type": "zip", 779 | "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/5e3a687f7d8ae33fb362c5c0743794bbb2420a1d", 780 | "reference": "5e3a687f7d8ae33fb362c5c0743794bbb2420a1d", 781 | "shasum": "" 782 | }, 783 | "require": { 784 | "php": ">=8.1" 785 | }, 786 | "require-dev": { 787 | "phpunit/phpunit": "^10.0" 788 | }, 789 | "type": "library", 790 | "extra": { 791 | "branch-alias": { 792 | "dev-main": "3.0-dev" 793 | } 794 | }, 795 | "autoload": { 796 | "classmap": [ 797 | "src/" 798 | ] 799 | }, 800 | "notification-url": "https://packagist.org/downloads/", 801 | "license": [ 802 | "BSD-3-Clause" 803 | ], 804 | "authors": [ 805 | { 806 | "name": "Sebastian Bergmann", 807 | "email": "sebastian@phpunit.de" 808 | } 809 | ], 810 | "description": "Looks up which function or method a line of code belongs to", 811 | "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", 812 | "support": { 813 | "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues", 814 | "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/3.0.0" 815 | }, 816 | "funding": [ 817 | { 818 | "url": "https://github.com/sebastianbergmann", 819 | "type": "github" 820 | } 821 | ], 822 | "time": "2023-02-03T06:59:15+00:00" 823 | }, 824 | { 825 | "name": "sebastian/comparator", 826 | "version": "5.0.0", 827 | "source": { 828 | "type": "git", 829 | "url": "https://github.com/sebastianbergmann/comparator.git", 830 | "reference": "72f01e6586e0caf6af81297897bd112eb7e9627c" 831 | }, 832 | "dist": { 833 | "type": "zip", 834 | "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/72f01e6586e0caf6af81297897bd112eb7e9627c", 835 | "reference": "72f01e6586e0caf6af81297897bd112eb7e9627c", 836 | "shasum": "" 837 | }, 838 | "require": { 839 | "ext-dom": "*", 840 | "ext-mbstring": "*", 841 | "php": ">=8.1", 842 | "sebastian/diff": "^5.0", 843 | "sebastian/exporter": "^5.0" 844 | }, 845 | "require-dev": { 846 | "phpunit/phpunit": "^10.0" 847 | }, 848 | "type": "library", 849 | "extra": { 850 | "branch-alias": { 851 | "dev-main": "5.0-dev" 852 | } 853 | }, 854 | "autoload": { 855 | "classmap": [ 856 | "src/" 857 | ] 858 | }, 859 | "notification-url": "https://packagist.org/downloads/", 860 | "license": [ 861 | "BSD-3-Clause" 862 | ], 863 | "authors": [ 864 | { 865 | "name": "Sebastian Bergmann", 866 | "email": "sebastian@phpunit.de" 867 | }, 868 | { 869 | "name": "Jeff Welch", 870 | "email": "whatthejeff@gmail.com" 871 | }, 872 | { 873 | "name": "Volker Dusch", 874 | "email": "github@wallbash.com" 875 | }, 876 | { 877 | "name": "Bernhard Schussek", 878 | "email": "bschussek@2bepublished.at" 879 | } 880 | ], 881 | "description": "Provides the functionality to compare PHP values for equality", 882 | "homepage": "https://github.com/sebastianbergmann/comparator", 883 | "keywords": [ 884 | "comparator", 885 | "compare", 886 | "equality" 887 | ], 888 | "support": { 889 | "issues": "https://github.com/sebastianbergmann/comparator/issues", 890 | "source": "https://github.com/sebastianbergmann/comparator/tree/5.0.0" 891 | }, 892 | "funding": [ 893 | { 894 | "url": "https://github.com/sebastianbergmann", 895 | "type": "github" 896 | } 897 | ], 898 | "time": "2023-02-03T07:07:16+00:00" 899 | }, 900 | { 901 | "name": "sebastian/complexity", 902 | "version": "3.0.0", 903 | "source": { 904 | "type": "git", 905 | "url": "https://github.com/sebastianbergmann/complexity.git", 906 | "reference": "e67d240970c9dc7ea7b2123a6d520e334dd61dc6" 907 | }, 908 | "dist": { 909 | "type": "zip", 910 | "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/e67d240970c9dc7ea7b2123a6d520e334dd61dc6", 911 | "reference": "e67d240970c9dc7ea7b2123a6d520e334dd61dc6", 912 | "shasum": "" 913 | }, 914 | "require": { 915 | "nikic/php-parser": "^4.10", 916 | "php": ">=8.1" 917 | }, 918 | "require-dev": { 919 | "phpunit/phpunit": "^10.0" 920 | }, 921 | "type": "library", 922 | "extra": { 923 | "branch-alias": { 924 | "dev-main": "3.0-dev" 925 | } 926 | }, 927 | "autoload": { 928 | "classmap": [ 929 | "src/" 930 | ] 931 | }, 932 | "notification-url": "https://packagist.org/downloads/", 933 | "license": [ 934 | "BSD-3-Clause" 935 | ], 936 | "authors": [ 937 | { 938 | "name": "Sebastian Bergmann", 939 | "email": "sebastian@phpunit.de", 940 | "role": "lead" 941 | } 942 | ], 943 | "description": "Library for calculating the complexity of PHP code units", 944 | "homepage": "https://github.com/sebastianbergmann/complexity", 945 | "support": { 946 | "issues": "https://github.com/sebastianbergmann/complexity/issues", 947 | "source": "https://github.com/sebastianbergmann/complexity/tree/3.0.0" 948 | }, 949 | "funding": [ 950 | { 951 | "url": "https://github.com/sebastianbergmann", 952 | "type": "github" 953 | } 954 | ], 955 | "time": "2023-02-03T06:59:47+00:00" 956 | }, 957 | { 958 | "name": "sebastian/diff", 959 | "version": "5.0.3", 960 | "source": { 961 | "type": "git", 962 | "url": "https://github.com/sebastianbergmann/diff.git", 963 | "reference": "912dc2fbe3e3c1e7873313cc801b100b6c68c87b" 964 | }, 965 | "dist": { 966 | "type": "zip", 967 | "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/912dc2fbe3e3c1e7873313cc801b100b6c68c87b", 968 | "reference": "912dc2fbe3e3c1e7873313cc801b100b6c68c87b", 969 | "shasum": "" 970 | }, 971 | "require": { 972 | "php": ">=8.1" 973 | }, 974 | "require-dev": { 975 | "phpunit/phpunit": "^10.0", 976 | "symfony/process": "^4.2 || ^5" 977 | }, 978 | "type": "library", 979 | "extra": { 980 | "branch-alias": { 981 | "dev-main": "5.0-dev" 982 | } 983 | }, 984 | "autoload": { 985 | "classmap": [ 986 | "src/" 987 | ] 988 | }, 989 | "notification-url": "https://packagist.org/downloads/", 990 | "license": [ 991 | "BSD-3-Clause" 992 | ], 993 | "authors": [ 994 | { 995 | "name": "Sebastian Bergmann", 996 | "email": "sebastian@phpunit.de" 997 | }, 998 | { 999 | "name": "Kore Nordmann", 1000 | "email": "mail@kore-nordmann.de" 1001 | } 1002 | ], 1003 | "description": "Diff implementation", 1004 | "homepage": "https://github.com/sebastianbergmann/diff", 1005 | "keywords": [ 1006 | "diff", 1007 | "udiff", 1008 | "unidiff", 1009 | "unified diff" 1010 | ], 1011 | "support": { 1012 | "issues": "https://github.com/sebastianbergmann/diff/issues", 1013 | "security": "https://github.com/sebastianbergmann/diff/security/policy", 1014 | "source": "https://github.com/sebastianbergmann/diff/tree/5.0.3" 1015 | }, 1016 | "funding": [ 1017 | { 1018 | "url": "https://github.com/sebastianbergmann", 1019 | "type": "github" 1020 | } 1021 | ], 1022 | "time": "2023-05-01T07:48:21+00:00" 1023 | }, 1024 | { 1025 | "name": "sebastian/environment", 1026 | "version": "6.0.1", 1027 | "source": { 1028 | "type": "git", 1029 | "url": "https://github.com/sebastianbergmann/environment.git", 1030 | "reference": "43c751b41d74f96cbbd4e07b7aec9675651e2951" 1031 | }, 1032 | "dist": { 1033 | "type": "zip", 1034 | "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/43c751b41d74f96cbbd4e07b7aec9675651e2951", 1035 | "reference": "43c751b41d74f96cbbd4e07b7aec9675651e2951", 1036 | "shasum": "" 1037 | }, 1038 | "require": { 1039 | "php": ">=8.1" 1040 | }, 1041 | "require-dev": { 1042 | "phpunit/phpunit": "^10.0" 1043 | }, 1044 | "suggest": { 1045 | "ext-posix": "*" 1046 | }, 1047 | "type": "library", 1048 | "extra": { 1049 | "branch-alias": { 1050 | "dev-main": "6.0-dev" 1051 | } 1052 | }, 1053 | "autoload": { 1054 | "classmap": [ 1055 | "src/" 1056 | ] 1057 | }, 1058 | "notification-url": "https://packagist.org/downloads/", 1059 | "license": [ 1060 | "BSD-3-Clause" 1061 | ], 1062 | "authors": [ 1063 | { 1064 | "name": "Sebastian Bergmann", 1065 | "email": "sebastian@phpunit.de" 1066 | } 1067 | ], 1068 | "description": "Provides functionality to handle HHVM/PHP environments", 1069 | "homepage": "https://github.com/sebastianbergmann/environment", 1070 | "keywords": [ 1071 | "Xdebug", 1072 | "environment", 1073 | "hhvm" 1074 | ], 1075 | "support": { 1076 | "issues": "https://github.com/sebastianbergmann/environment/issues", 1077 | "security": "https://github.com/sebastianbergmann/environment/security/policy", 1078 | "source": "https://github.com/sebastianbergmann/environment/tree/6.0.1" 1079 | }, 1080 | "funding": [ 1081 | { 1082 | "url": "https://github.com/sebastianbergmann", 1083 | "type": "github" 1084 | } 1085 | ], 1086 | "time": "2023-04-11T05:39:26+00:00" 1087 | }, 1088 | { 1089 | "name": "sebastian/exporter", 1090 | "version": "5.0.0", 1091 | "source": { 1092 | "type": "git", 1093 | "url": "https://github.com/sebastianbergmann/exporter.git", 1094 | "reference": "f3ec4bf931c0b31e5b413f5b4fc970a7d03338c0" 1095 | }, 1096 | "dist": { 1097 | "type": "zip", 1098 | "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/f3ec4bf931c0b31e5b413f5b4fc970a7d03338c0", 1099 | "reference": "f3ec4bf931c0b31e5b413f5b4fc970a7d03338c0", 1100 | "shasum": "" 1101 | }, 1102 | "require": { 1103 | "ext-mbstring": "*", 1104 | "php": ">=8.1", 1105 | "sebastian/recursion-context": "^5.0" 1106 | }, 1107 | "require-dev": { 1108 | "phpunit/phpunit": "^10.0" 1109 | }, 1110 | "type": "library", 1111 | "extra": { 1112 | "branch-alias": { 1113 | "dev-main": "5.0-dev" 1114 | } 1115 | }, 1116 | "autoload": { 1117 | "classmap": [ 1118 | "src/" 1119 | ] 1120 | }, 1121 | "notification-url": "https://packagist.org/downloads/", 1122 | "license": [ 1123 | "BSD-3-Clause" 1124 | ], 1125 | "authors": [ 1126 | { 1127 | "name": "Sebastian Bergmann", 1128 | "email": "sebastian@phpunit.de" 1129 | }, 1130 | { 1131 | "name": "Jeff Welch", 1132 | "email": "whatthejeff@gmail.com" 1133 | }, 1134 | { 1135 | "name": "Volker Dusch", 1136 | "email": "github@wallbash.com" 1137 | }, 1138 | { 1139 | "name": "Adam Harvey", 1140 | "email": "aharvey@php.net" 1141 | }, 1142 | { 1143 | "name": "Bernhard Schussek", 1144 | "email": "bschussek@gmail.com" 1145 | } 1146 | ], 1147 | "description": "Provides the functionality to export PHP variables for visualization", 1148 | "homepage": "https://www.github.com/sebastianbergmann/exporter", 1149 | "keywords": [ 1150 | "export", 1151 | "exporter" 1152 | ], 1153 | "support": { 1154 | "issues": "https://github.com/sebastianbergmann/exporter/issues", 1155 | "source": "https://github.com/sebastianbergmann/exporter/tree/5.0.0" 1156 | }, 1157 | "funding": [ 1158 | { 1159 | "url": "https://github.com/sebastianbergmann", 1160 | "type": "github" 1161 | } 1162 | ], 1163 | "time": "2023-02-03T07:06:49+00:00" 1164 | }, 1165 | { 1166 | "name": "sebastian/global-state", 1167 | "version": "6.0.0", 1168 | "source": { 1169 | "type": "git", 1170 | "url": "https://github.com/sebastianbergmann/global-state.git", 1171 | "reference": "aab257c712de87b90194febd52e4d184551c2d44" 1172 | }, 1173 | "dist": { 1174 | "type": "zip", 1175 | "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/aab257c712de87b90194febd52e4d184551c2d44", 1176 | "reference": "aab257c712de87b90194febd52e4d184551c2d44", 1177 | "shasum": "" 1178 | }, 1179 | "require": { 1180 | "php": ">=8.1", 1181 | "sebastian/object-reflector": "^3.0", 1182 | "sebastian/recursion-context": "^5.0" 1183 | }, 1184 | "require-dev": { 1185 | "ext-dom": "*", 1186 | "phpunit/phpunit": "^10.0" 1187 | }, 1188 | "type": "library", 1189 | "extra": { 1190 | "branch-alias": { 1191 | "dev-main": "6.0-dev" 1192 | } 1193 | }, 1194 | "autoload": { 1195 | "classmap": [ 1196 | "src/" 1197 | ] 1198 | }, 1199 | "notification-url": "https://packagist.org/downloads/", 1200 | "license": [ 1201 | "BSD-3-Clause" 1202 | ], 1203 | "authors": [ 1204 | { 1205 | "name": "Sebastian Bergmann", 1206 | "email": "sebastian@phpunit.de" 1207 | } 1208 | ], 1209 | "description": "Snapshotting of global state", 1210 | "homepage": "http://www.github.com/sebastianbergmann/global-state", 1211 | "keywords": [ 1212 | "global state" 1213 | ], 1214 | "support": { 1215 | "issues": "https://github.com/sebastianbergmann/global-state/issues", 1216 | "source": "https://github.com/sebastianbergmann/global-state/tree/6.0.0" 1217 | }, 1218 | "funding": [ 1219 | { 1220 | "url": "https://github.com/sebastianbergmann", 1221 | "type": "github" 1222 | } 1223 | ], 1224 | "time": "2023-02-03T07:07:38+00:00" 1225 | }, 1226 | { 1227 | "name": "sebastian/lines-of-code", 1228 | "version": "2.0.0", 1229 | "source": { 1230 | "type": "git", 1231 | "url": "https://github.com/sebastianbergmann/lines-of-code.git", 1232 | "reference": "17c4d940ecafb3d15d2cf916f4108f664e28b130" 1233 | }, 1234 | "dist": { 1235 | "type": "zip", 1236 | "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/17c4d940ecafb3d15d2cf916f4108f664e28b130", 1237 | "reference": "17c4d940ecafb3d15d2cf916f4108f664e28b130", 1238 | "shasum": "" 1239 | }, 1240 | "require": { 1241 | "nikic/php-parser": "^4.10", 1242 | "php": ">=8.1" 1243 | }, 1244 | "require-dev": { 1245 | "phpunit/phpunit": "^10.0" 1246 | }, 1247 | "type": "library", 1248 | "extra": { 1249 | "branch-alias": { 1250 | "dev-main": "2.0-dev" 1251 | } 1252 | }, 1253 | "autoload": { 1254 | "classmap": [ 1255 | "src/" 1256 | ] 1257 | }, 1258 | "notification-url": "https://packagist.org/downloads/", 1259 | "license": [ 1260 | "BSD-3-Clause" 1261 | ], 1262 | "authors": [ 1263 | { 1264 | "name": "Sebastian Bergmann", 1265 | "email": "sebastian@phpunit.de", 1266 | "role": "lead" 1267 | } 1268 | ], 1269 | "description": "Library for counting the lines of code in PHP source code", 1270 | "homepage": "https://github.com/sebastianbergmann/lines-of-code", 1271 | "support": { 1272 | "issues": "https://github.com/sebastianbergmann/lines-of-code/issues", 1273 | "source": "https://github.com/sebastianbergmann/lines-of-code/tree/2.0.0" 1274 | }, 1275 | "funding": [ 1276 | { 1277 | "url": "https://github.com/sebastianbergmann", 1278 | "type": "github" 1279 | } 1280 | ], 1281 | "time": "2023-02-03T07:08:02+00:00" 1282 | }, 1283 | { 1284 | "name": "sebastian/object-enumerator", 1285 | "version": "5.0.0", 1286 | "source": { 1287 | "type": "git", 1288 | "url": "https://github.com/sebastianbergmann/object-enumerator.git", 1289 | "reference": "202d0e344a580d7f7d04b3fafce6933e59dae906" 1290 | }, 1291 | "dist": { 1292 | "type": "zip", 1293 | "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/202d0e344a580d7f7d04b3fafce6933e59dae906", 1294 | "reference": "202d0e344a580d7f7d04b3fafce6933e59dae906", 1295 | "shasum": "" 1296 | }, 1297 | "require": { 1298 | "php": ">=8.1", 1299 | "sebastian/object-reflector": "^3.0", 1300 | "sebastian/recursion-context": "^5.0" 1301 | }, 1302 | "require-dev": { 1303 | "phpunit/phpunit": "^10.0" 1304 | }, 1305 | "type": "library", 1306 | "extra": { 1307 | "branch-alias": { 1308 | "dev-main": "5.0-dev" 1309 | } 1310 | }, 1311 | "autoload": { 1312 | "classmap": [ 1313 | "src/" 1314 | ] 1315 | }, 1316 | "notification-url": "https://packagist.org/downloads/", 1317 | "license": [ 1318 | "BSD-3-Clause" 1319 | ], 1320 | "authors": [ 1321 | { 1322 | "name": "Sebastian Bergmann", 1323 | "email": "sebastian@phpunit.de" 1324 | } 1325 | ], 1326 | "description": "Traverses array structures and object graphs to enumerate all referenced objects", 1327 | "homepage": "https://github.com/sebastianbergmann/object-enumerator/", 1328 | "support": { 1329 | "issues": "https://github.com/sebastianbergmann/object-enumerator/issues", 1330 | "source": "https://github.com/sebastianbergmann/object-enumerator/tree/5.0.0" 1331 | }, 1332 | "funding": [ 1333 | { 1334 | "url": "https://github.com/sebastianbergmann", 1335 | "type": "github" 1336 | } 1337 | ], 1338 | "time": "2023-02-03T07:08:32+00:00" 1339 | }, 1340 | { 1341 | "name": "sebastian/object-reflector", 1342 | "version": "3.0.0", 1343 | "source": { 1344 | "type": "git", 1345 | "url": "https://github.com/sebastianbergmann/object-reflector.git", 1346 | "reference": "24ed13d98130f0e7122df55d06c5c4942a577957" 1347 | }, 1348 | "dist": { 1349 | "type": "zip", 1350 | "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/24ed13d98130f0e7122df55d06c5c4942a577957", 1351 | "reference": "24ed13d98130f0e7122df55d06c5c4942a577957", 1352 | "shasum": "" 1353 | }, 1354 | "require": { 1355 | "php": ">=8.1" 1356 | }, 1357 | "require-dev": { 1358 | "phpunit/phpunit": "^10.0" 1359 | }, 1360 | "type": "library", 1361 | "extra": { 1362 | "branch-alias": { 1363 | "dev-main": "3.0-dev" 1364 | } 1365 | }, 1366 | "autoload": { 1367 | "classmap": [ 1368 | "src/" 1369 | ] 1370 | }, 1371 | "notification-url": "https://packagist.org/downloads/", 1372 | "license": [ 1373 | "BSD-3-Clause" 1374 | ], 1375 | "authors": [ 1376 | { 1377 | "name": "Sebastian Bergmann", 1378 | "email": "sebastian@phpunit.de" 1379 | } 1380 | ], 1381 | "description": "Allows reflection of object attributes, including inherited and non-public ones", 1382 | "homepage": "https://github.com/sebastianbergmann/object-reflector/", 1383 | "support": { 1384 | "issues": "https://github.com/sebastianbergmann/object-reflector/issues", 1385 | "source": "https://github.com/sebastianbergmann/object-reflector/tree/3.0.0" 1386 | }, 1387 | "funding": [ 1388 | { 1389 | "url": "https://github.com/sebastianbergmann", 1390 | "type": "github" 1391 | } 1392 | ], 1393 | "time": "2023-02-03T07:06:18+00:00" 1394 | }, 1395 | { 1396 | "name": "sebastian/recursion-context", 1397 | "version": "5.0.0", 1398 | "source": { 1399 | "type": "git", 1400 | "url": "https://github.com/sebastianbergmann/recursion-context.git", 1401 | "reference": "05909fb5bc7df4c52992396d0116aed689f93712" 1402 | }, 1403 | "dist": { 1404 | "type": "zip", 1405 | "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/05909fb5bc7df4c52992396d0116aed689f93712", 1406 | "reference": "05909fb5bc7df4c52992396d0116aed689f93712", 1407 | "shasum": "" 1408 | }, 1409 | "require": { 1410 | "php": ">=8.1" 1411 | }, 1412 | "require-dev": { 1413 | "phpunit/phpunit": "^10.0" 1414 | }, 1415 | "type": "library", 1416 | "extra": { 1417 | "branch-alias": { 1418 | "dev-main": "5.0-dev" 1419 | } 1420 | }, 1421 | "autoload": { 1422 | "classmap": [ 1423 | "src/" 1424 | ] 1425 | }, 1426 | "notification-url": "https://packagist.org/downloads/", 1427 | "license": [ 1428 | "BSD-3-Clause" 1429 | ], 1430 | "authors": [ 1431 | { 1432 | "name": "Sebastian Bergmann", 1433 | "email": "sebastian@phpunit.de" 1434 | }, 1435 | { 1436 | "name": "Jeff Welch", 1437 | "email": "whatthejeff@gmail.com" 1438 | }, 1439 | { 1440 | "name": "Adam Harvey", 1441 | "email": "aharvey@php.net" 1442 | } 1443 | ], 1444 | "description": "Provides functionality to recursively process PHP variables", 1445 | "homepage": "https://github.com/sebastianbergmann/recursion-context", 1446 | "support": { 1447 | "issues": "https://github.com/sebastianbergmann/recursion-context/issues", 1448 | "source": "https://github.com/sebastianbergmann/recursion-context/tree/5.0.0" 1449 | }, 1450 | "funding": [ 1451 | { 1452 | "url": "https://github.com/sebastianbergmann", 1453 | "type": "github" 1454 | } 1455 | ], 1456 | "time": "2023-02-03T07:05:40+00:00" 1457 | }, 1458 | { 1459 | "name": "sebastian/type", 1460 | "version": "4.0.0", 1461 | "source": { 1462 | "type": "git", 1463 | "url": "https://github.com/sebastianbergmann/type.git", 1464 | "reference": "462699a16464c3944eefc02ebdd77882bd3925bf" 1465 | }, 1466 | "dist": { 1467 | "type": "zip", 1468 | "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/462699a16464c3944eefc02ebdd77882bd3925bf", 1469 | "reference": "462699a16464c3944eefc02ebdd77882bd3925bf", 1470 | "shasum": "" 1471 | }, 1472 | "require": { 1473 | "php": ">=8.1" 1474 | }, 1475 | "require-dev": { 1476 | "phpunit/phpunit": "^10.0" 1477 | }, 1478 | "type": "library", 1479 | "extra": { 1480 | "branch-alias": { 1481 | "dev-main": "4.0-dev" 1482 | } 1483 | }, 1484 | "autoload": { 1485 | "classmap": [ 1486 | "src/" 1487 | ] 1488 | }, 1489 | "notification-url": "https://packagist.org/downloads/", 1490 | "license": [ 1491 | "BSD-3-Clause" 1492 | ], 1493 | "authors": [ 1494 | { 1495 | "name": "Sebastian Bergmann", 1496 | "email": "sebastian@phpunit.de", 1497 | "role": "lead" 1498 | } 1499 | ], 1500 | "description": "Collection of value objects that represent the types of the PHP type system", 1501 | "homepage": "https://github.com/sebastianbergmann/type", 1502 | "support": { 1503 | "issues": "https://github.com/sebastianbergmann/type/issues", 1504 | "source": "https://github.com/sebastianbergmann/type/tree/4.0.0" 1505 | }, 1506 | "funding": [ 1507 | { 1508 | "url": "https://github.com/sebastianbergmann", 1509 | "type": "github" 1510 | } 1511 | ], 1512 | "time": "2023-02-03T07:10:45+00:00" 1513 | }, 1514 | { 1515 | "name": "sebastian/version", 1516 | "version": "4.0.1", 1517 | "source": { 1518 | "type": "git", 1519 | "url": "https://github.com/sebastianbergmann/version.git", 1520 | "reference": "c51fa83a5d8f43f1402e3f32a005e6262244ef17" 1521 | }, 1522 | "dist": { 1523 | "type": "zip", 1524 | "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c51fa83a5d8f43f1402e3f32a005e6262244ef17", 1525 | "reference": "c51fa83a5d8f43f1402e3f32a005e6262244ef17", 1526 | "shasum": "" 1527 | }, 1528 | "require": { 1529 | "php": ">=8.1" 1530 | }, 1531 | "type": "library", 1532 | "extra": { 1533 | "branch-alias": { 1534 | "dev-main": "4.0-dev" 1535 | } 1536 | }, 1537 | "autoload": { 1538 | "classmap": [ 1539 | "src/" 1540 | ] 1541 | }, 1542 | "notification-url": "https://packagist.org/downloads/", 1543 | "license": [ 1544 | "BSD-3-Clause" 1545 | ], 1546 | "authors": [ 1547 | { 1548 | "name": "Sebastian Bergmann", 1549 | "email": "sebastian@phpunit.de", 1550 | "role": "lead" 1551 | } 1552 | ], 1553 | "description": "Library that helps with managing the version number of Git-hosted PHP projects", 1554 | "homepage": "https://github.com/sebastianbergmann/version", 1555 | "support": { 1556 | "issues": "https://github.com/sebastianbergmann/version/issues", 1557 | "source": "https://github.com/sebastianbergmann/version/tree/4.0.1" 1558 | }, 1559 | "funding": [ 1560 | { 1561 | "url": "https://github.com/sebastianbergmann", 1562 | "type": "github" 1563 | } 1564 | ], 1565 | "time": "2023-02-07T11:34:05+00:00" 1566 | }, 1567 | { 1568 | "name": "theseer/tokenizer", 1569 | "version": "1.2.1", 1570 | "source": { 1571 | "type": "git", 1572 | "url": "https://github.com/theseer/tokenizer.git", 1573 | "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e" 1574 | }, 1575 | "dist": { 1576 | "type": "zip", 1577 | "url": "https://api.github.com/repos/theseer/tokenizer/zipball/34a41e998c2183e22995f158c581e7b5e755ab9e", 1578 | "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e", 1579 | "shasum": "" 1580 | }, 1581 | "require": { 1582 | "ext-dom": "*", 1583 | "ext-tokenizer": "*", 1584 | "ext-xmlwriter": "*", 1585 | "php": "^7.2 || ^8.0" 1586 | }, 1587 | "type": "library", 1588 | "autoload": { 1589 | "classmap": [ 1590 | "src/" 1591 | ] 1592 | }, 1593 | "notification-url": "https://packagist.org/downloads/", 1594 | "license": [ 1595 | "BSD-3-Clause" 1596 | ], 1597 | "authors": [ 1598 | { 1599 | "name": "Arne Blankerts", 1600 | "email": "arne@blankerts.de", 1601 | "role": "Developer" 1602 | } 1603 | ], 1604 | "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", 1605 | "support": { 1606 | "issues": "https://github.com/theseer/tokenizer/issues", 1607 | "source": "https://github.com/theseer/tokenizer/tree/1.2.1" 1608 | }, 1609 | "funding": [ 1610 | { 1611 | "url": "https://github.com/theseer", 1612 | "type": "github" 1613 | } 1614 | ], 1615 | "time": "2021-07-28T10:34:58+00:00" 1616 | } 1617 | ], 1618 | "aliases": [], 1619 | "minimum-stability": "stable", 1620 | "stability-flags": [], 1621 | "prefer-stable": false, 1622 | "prefer-lowest": false, 1623 | "platform": { 1624 | "php": ">=5.3.0" 1625 | }, 1626 | "platform-dev": [], 1627 | "plugin-api-version": "2.1.0" 1628 | } 1629 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ./tests/Unit 7 | 8 | 9 | 10 | 11 | ./src 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Font Awesome SVG - PHP 2 | 3 | A PHP class that can be used to add [Font Awesome 6+](https://fontawesome.com/)'s SVG icons inline without Javascript. 4 | 5 | ## Installation 6 | 7 | You can install it using Composer: 8 | 9 | ``` 10 | composer require husseinalhammad/fontawesome-svg 11 | ``` 12 | 13 | Or you can download the `FontAwesomeSVG.php` file and include it manually. 14 | 15 | ## Usage 16 | 17 | ### Files 18 | 19 | - Download Font Awesome (Free or Pro) 20 | - Get the folder `advanced-options/raw-svg` and place it in your project 21 | - Add `svg-with-js/css/fa-svg-with-js` to your document (or write your own CSS) 22 | 23 | ### Examples 24 | 25 | ```php 26 | // $dir = directory where SVG files are 27 | $FA = new FontAwesomeSVG($dir); 28 | 29 | echo $FA->get_svg('fa-solid fa-file'); 30 | ``` 31 | 32 | Add custom classes: 33 | 34 | ```php 35 | echo $FA->get_svg('fa-solid fa-file', ['class' => 'my-custom-class another-class']); 36 | ``` 37 | 38 | Remove default class `.svg-inline--fa`: 39 | 40 | ```php 41 | echo $FA->get_svg('fa-solid fa-file', ['default_class' => false]); 42 | ``` 43 | 44 | Change `` fill (default is `currentColor`): 45 | 46 | ```php 47 | echo $FA->get_svg('fa-solid fa-file', ['fill' => '#f44336']); 48 | ``` 49 | 50 | Add ``: 51 | 52 | ```php 53 | echo $FA->get_svg('fa-solid fa-file', ['title' => 'My accessible icon']); 54 | ``` 55 | 56 | Multiple options at once: 57 | 58 | ```php 59 | echo $FA->get_svg('fa-solid fa-file', [ 60 | 'class' => 'my-custom-class another-class', 61 | 'default_class' => false, 62 | 'title' => 'My title', 63 | 'role' => 'img', 64 | 'fill' => '#ffffff', 65 | ]); 66 | ``` 67 | 68 | Customise duotone icons: 69 | 70 | ```php 71 | echo $FA->get_svg('fa-duotone fa-laugh-wink', [ 72 | 'primary' => [ 73 | 'fill' => '#e64980', 74 | ], 75 | 'secondary' => [ 76 | 'fill' => '#fcc417', 77 | 'opacity' => '1', 78 | ], 79 | ]); 80 | ``` 81 | 82 | | Option | What it means | 83 | | ------------- | ------------------------------------------------------------------------------------------------- | 84 | | class | Adds classes to the SVG tag | 85 | | default_class | If set to `false`, the default CSS class won't be added to the SVG tag. Deafult: `true`. | 86 | | inline_style | Whether to add duotone styles as inline style to the `` tag. Deafult: `true`. | 87 | | title | Adds a `` inside the SVG tag for semantic icons | 88 | | title_id | Adds an `id` attribute to `` and adds `aria-labelledby` on the SVG tag with the same value | 89 | | role | The value of the `role` attribute in the SVG tag. Default: `img` | 90 | | fill | The value of the `fill` attribute in the `<path>` inside the SVG. Default: `currentColor` | 91 | | primary | Duotone primary options (see table below) | 92 | | secondary | Duotone secondary options (see table below) | 93 | 94 | ## Duotone 95 | 96 | > Requires **v5.10.0** or greater, and a FontAwesome Pro license 97 | 98 | ## Sharp 99 | 100 | > Requires **v6.4.0** or greater, and a FontAwesome Pro license 101 | 102 | ```php 103 | echo $FA->get_svg('fa-sharp fa-light fa-file'); 104 | echo $FA->get_svg('fa-sharp fa-regular fa-file'); 105 | echo $FA->get_svg('fa-sharp fa-solid fa-file'); 106 | ``` 107 | 108 | ### options 109 | 110 | If `inline_style` is enabled, the value of `fill` and `opacity` are also used in the inline style on `<svg>` tag. 111 | 112 | | Option | What it means | 113 | | ------- | ----------------------------------------------------------------------------------------- | 114 | | fill | The value of the `fill` attribute in the `<path>` inside the SVG. Default: `currentColor` | 115 | | opacity | The value of the `opacity` attribute in the `<path>` inside the SVG. | 116 | 117 | ### Examples: 118 | 119 | Single colour: 120 | 121 | ```php 122 | echo $FA->get_svg('fad fa-laugh-wink', [ 123 | 'fill' => '#e64980', 124 | ]); 125 | ``` 126 | 127 | Swapping Layer Opacity: 128 | 129 | ```php 130 | echo $FA->get_svg('fad fa-laugh-wink', [ 131 | 'fill' => '#e64980', 132 | 'class' => 'fa-swap-opacity', 133 | ]); 134 | ``` 135 | 136 | Single colour with custom opacity: 137 | 138 | ```php 139 | echo $FA->get_svg('fad fa-laugh-wink', [ 140 | 'fill' => '#e64980', 141 | 'secondary' => [ 142 | 'opacity' => '0.2', 143 | ], 144 | ]); 145 | ``` 146 | 147 | Custom colours and opacity: 148 | 149 | ```php 150 | echo $FA->get_svg('fad fa-laugh-wink', [ 151 | 'primary' => [ 152 | 'fill' => '#e64980', 153 | 'opacity' => '0.5', 154 | ], 155 | 'secondary' => [ 156 | 'fill' => '#fcc417', 157 | 'opacity' => '1', 158 | ], 159 | ]); 160 | ``` 161 | 162 | ## Aliases 163 | 164 | The short aliases from version 5 are still supported 165 | 166 | ```php 167 | echo $FA->get_svg('fab fa-twitter'); 168 | echo $FA->get_svg('fad fa-file'); 169 | echo $FA->get_svg('fal fa-file'); 170 | echo $FA->get_svg('far fa-file'); 171 | echo $FA->get_svg('fas fa-file'); 172 | 173 | // And the new shorthands for thin and sharp 174 | echo $FA->get_svg('fat fa-file'); // thin 175 | echo $FA->get_svg('fasl fa-file'); // sharp-light 176 | echo $FA->get_svg('fasr fa-file'); // sharp-regular 177 | echo $FA->get_svg('fass fa-file'); // sharp-solid 178 | ``` 179 | 180 | ## Accessibility 181 | 182 | The below is implemented based on: 183 | 184 | - Font Awesome's [Accessibility docs](https://fontawesome.com/how-to-use/on-the-web/other-topics/accessibility) 185 | - Heather Migliorisi's article on CSS-Tricks [Accessible SVGs](https://css-tricks.com/accessible-svgs/) 186 | 187 | ### `role` attribute 188 | 189 | `role="img"` is added to the SVG tag by default: 190 | 191 | ```html 192 | <svg role="img"></svg> 193 | ``` 194 | 195 | ### `<title>`, `aria-labelledby` 196 | 197 | You can set a `<title>`, an `id` for the `<title>` and the `aria-labelledby` attribute will be added automatically: 198 | 199 | ```php 200 | echo $FA->get_svg('fa-solid fa-file', [ 201 | 'title' => 'File', 202 | 'title_id' => 'file-id', 203 | ]); 204 | ``` 205 | 206 | ```html 207 | <svg aria-labelledby="file-id"> 208 | <title id="file-id">File 209 | 210 | ``` 211 | 212 | ### `aria-*` attributes 213 | 214 | You can add any aria-\* attribute to the SVG tag: 215 | 216 | ```php 217 | echo $FA->get_svg('fa-solid fa-file', [ 218 | 'aria-label' => 'File', 219 | ]); 220 | ``` 221 | 222 | ```html 223 | 224 | ``` 225 | 226 | ### `aria-hidden` attribute 227 | 228 | `aria-hidden="true"` is added to the SVG tag by default unless `` (and `aria-labelledby`) or `aria-label` is set. 229 | 230 | ```php 231 | echo $FA->get_svg('fa-solid fa-file'); 232 | ``` 233 | 234 | ```html 235 | <svg aria-hidden="true"></svg> 236 | ``` 237 | -------------------------------------------------------------------------------- /src/FontAwesomeSVG.php: -------------------------------------------------------------------------------- 1 | <?php 2 | 3 | class FontAwesomeSVG { 4 | 5 | public $svg_dir; 6 | 7 | public function __construct($svg_dir) { 8 | if( !is_dir($svg_dir) ) { 9 | throw new Exception("Directory $svg_dir does not exist"); 10 | } 11 | 12 | $this->svg_dir = $svg_dir; 13 | } 14 | 15 | 16 | 17 | 18 | /** 19 | * Get SVG icon 20 | * 21 | * @param string $id icon ID e.g. fas fa-house 22 | * @param array $opts options array 23 | * @return string|boolean 24 | */ 25 | public function get_svg($id, $opts=[]) { 26 | try { 27 | $icon = $this->get_icon_details($id); 28 | } catch(Exception $e) { 29 | return false; 30 | } 31 | 32 | $doc = new DOMDocument(); 33 | $doc->load($icon['filepath']); 34 | 35 | $default_opts = [ 36 | 'title' => false, 37 | 'class' => false, 38 | 'default_class' => true, 39 | 'inline_style' => true, 40 | 'role' => 'img', 41 | 'fill' => 'currentColor', 42 | ]; 43 | 44 | $opts = array_merge($default_opts, $opts); 45 | 46 | 47 | 48 | $classes = ''; 49 | if($opts['default_class']) { 50 | $classes .= 'svg-inline--fa'; 51 | } 52 | if($opts['class']) { 53 | $classes .= ' ' . $opts['class']; 54 | } 55 | 56 | 57 | // $opts[aria-*] 58 | // strlen('aria-') = 5 59 | $aria_opts = array_filter($opts, function($item, $key){ 60 | if(substr($key, 0, 5) == 'aria-') return $item; 61 | }, ARRAY_FILTER_USE_BOTH); 62 | 63 | 64 | 65 | foreach ($doc->getElementsByTagName('svg') as $item) { 66 | if($classes != '') $item->setAttribute('class', $classes); 67 | if($opts['role']) $item->setAttribute('role', $opts['role']); 68 | 69 | 70 | foreach($aria_opts as $key => $val) { 71 | $item->setAttribute($key, $val); 72 | } 73 | 74 | 75 | if($opts['title']) { 76 | $title = $doc->createElement("title"); 77 | $title->nodeValue = $opts['title']; 78 | 79 | $title_node = $item->appendChild($title); 80 | 81 | // <title> id attribute has to be set to add aria-labelledby 82 | if(isset($opts['title_id'])) { 83 | $title_id = $opts['title_id']; 84 | $title_node->setAttribute('id', $title_id); 85 | $item->setAttribute('aria-labelledby', $title_id); 86 | } 87 | 88 | } 89 | 90 | 91 | if(!isset($aria_opts['aria-label']) && !isset($opts['title_id'])) { 92 | $item->setAttribute('aria-hidden', 'true'); 93 | } 94 | } 95 | 96 | 97 | 98 | 99 | foreach ($doc->getElementsByTagName('path') as $item) { 100 | $fill = $opts['fill']; 101 | $opacity = false; 102 | 103 | // duotone 104 | switch($item->getAttribute('class')) { 105 | case 'fa-primary': 106 | if(isset($opts['primary']['fill'])) $fill = $opts['primary']['fill']; 107 | if(isset($opts['primary']['opacity'])) $opacity = $opts['primary']['opacity']; 108 | break; 109 | 110 | 111 | case 'fa-secondary': 112 | if(isset($opts['secondary']['fill'])) $fill = $opts['secondary']['fill']; 113 | if(isset($opts['secondary']['opacity'])) $opacity = $opts['secondary']['opacity']; 114 | break; 115 | } 116 | 117 | 118 | $item->setAttribute('fill', $fill); 119 | if($opacity) $item->setAttribute('opacity', $opacity); 120 | } 121 | 122 | 123 | 124 | 125 | 126 | // duotone styles 127 | if($opts['inline_style']) { 128 | $styles = []; 129 | 130 | if(isset($opts['primary']['fill'])) { 131 | $styles[] = '--fa-primary-color:' . $opts['primary']['fill']; 132 | } 133 | 134 | if(isset($opts['primary']['opacity'])) { 135 | $styles[] = '--fa-primary-opacity:' . $opts['primary']['opacity']; 136 | } 137 | 138 | 139 | if(isset($opts['secondary']['fill'])) { 140 | $styles[] = '--fa-secondary-color:' . $opts['secondary']['fill']; 141 | } 142 | 143 | if(isset($opts['secondary']['opacity'])) { 144 | $styles[] = '--fa-secondary-opacity:' . $opts['secondary']['opacity']; 145 | } 146 | 147 | 148 | if(empty($styles) || !isset($opts['primary']['fill'], $opts['secondary']['fill']) ) { 149 | $styles[] = 'color:' . $opts['fill']; 150 | } 151 | 152 | 153 | 154 | if($styles) { 155 | foreach ($doc->getElementsByTagName('svg') as $svg) { 156 | $svg->setAttribute('style', implode(';', $styles)); 157 | } 158 | } 159 | } 160 | 161 | 162 | return $doc->saveHTML(); 163 | } 164 | 165 | 166 | 167 | 168 | /** 169 | * Get an icon's details from icon ID 170 | * 171 | * @param string $id icon ID e.g. fas fa-house 172 | * @return array 173 | */ 174 | public function get_icon_details($id) { 175 | $icon = array(); 176 | 177 | $classes = explode(' ', $id); 178 | $dir = $this->get_icon_dir($classes); 179 | $filename = $this->get_icon_filename($classes, $dir); 180 | $filepath = $this->get_icon_filepath($dir, $filename); 181 | 182 | $icon['dir'] = $dir; 183 | $icon['filename'] = $filename; 184 | $icon['filepath'] = $filepath; 185 | 186 | if(!is_file($icon['filepath'])) { 187 | throw new Exception('File ' . $icon['filepath'] . ' does not exist.'); 188 | } 189 | 190 | return $icon; 191 | } 192 | 193 | 194 | 195 | 196 | /** 197 | * Get the directory that contains the SVG icon file 198 | * 199 | * @param string $style 200 | * @return string 201 | */ 202 | public function get_icon_dir($classes) { 203 | if (in_array('fa-sharp', $classes)) { 204 | if (in_array('fa-regular', $classes)) return 'sharp-regular'; 205 | if (in_array('fa-light', $classes)) return 'sharp-light'; 206 | if (in_array('fa-solid', $classes)) return 'sharp-solid'; 207 | } 208 | 209 | if (in_array('fasr', $classes)) return 'sharp-regular'; 210 | if (in_array('fasl', $classes)) return 'sharp-light'; 211 | if (in_array('fass', $classes)) return 'sharp-solid'; 212 | 213 | if (in_array('far', $classes)) return 'regular'; 214 | if (in_array('fa-regular', $classes)) return 'regular'; 215 | 216 | if (in_array('fal', $classes)) return 'light'; 217 | if (in_array('fa-light', $classes)) return 'light'; 218 | 219 | if (in_array('fab', $classes)) return 'brands'; 220 | if (in_array('fa-brands', $classes)) return 'brands'; 221 | 222 | if (in_array('fad', $classes)) return 'duotone'; 223 | if (in_array('fa-duotone', $classes)) return 'duotone'; 224 | 225 | if (in_array('fat', $classes)) return 'thin'; 226 | if (in_array('fa-thin', $classes)) return 'thin'; 227 | 228 | return 'solid'; 229 | } 230 | 231 | 232 | 233 | 234 | /** 235 | * Get the icon's SVG file name 236 | * 237 | * @param array $classes 238 | * @param string $dir 239 | * @return string 240 | */ 241 | public function get_icon_filename($classes, $dir) { 242 | foreach ($classes as $class) { 243 | $filename = str_replace('fa-', '', $class); 244 | $path = $this->get_icon_filepath($dir, $filename); 245 | 246 | if (is_file($path)) { 247 | return $filename; 248 | } 249 | } 250 | 251 | $id = join(' ', $classes); 252 | 253 | throw new Exception("No icon found for '$id'"); 254 | } 255 | 256 | 257 | 258 | 259 | /** 260 | * Get the icon's SVG file path 261 | * 262 | * @param string $dir 263 | * @param string $filename 264 | * @return string 265 | */ 266 | public function get_icon_filepath($dir, $filename) { 267 | return str_replace('/', DIRECTORY_SEPARATOR, "$this->svg_dir/$dir/$filename.svg"); 268 | } 269 | } 270 | -------------------------------------------------------------------------------- /tests/Fixtures/icons/brands/test.svg: -------------------------------------------------------------------------------- 1 | <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path d="M397.694,25.056L14.611,461.893C6.605,471.022 7.517,484.933 16.647,492.939C25.776,500.944 39.687,500.032 47.693,490.903L430.775,54.067C438.781,44.938 437.869,31.027 428.74,23.021C419.611,15.015 405.699,15.927 397.694,25.056Z"/></svg> 2 | -------------------------------------------------------------------------------- /tests/Fixtures/icons/duotone/test.svg: -------------------------------------------------------------------------------- 1 | <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!-- Font Awesome Pro 5.15.3 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) --><defs><style>.fa-secondary{opacity:.4}</style></defs><path d="M397.694,25.056L14.611,461.893C6.605,471.022 7.517,484.933 16.647,492.939C25.776,500.944 39.687,500.032 47.693,490.903L430.775,54.067C438.781,44.938 437.869,31.027 428.74,23.021C419.611,15.015 405.699,15.927 397.694,25.056Z" class="fa-secondary"/><path d="M312.013,122.76L14.611,461.893C6.605,471.022 7.517,484.933 16.647,492.939C25.776,500.944 39.687,500.032 47.693,490.903L345.094,151.771C353.1,142.641 352.188,128.73 343.059,120.725C333.93,112.719 320.019,113.631 312.013,122.76Z" class="fa-primary"/></svg> 2 | -------------------------------------------------------------------------------- /tests/Fixtures/icons/light/test.svg: -------------------------------------------------------------------------------- 1 | <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path d="M397.694,25.056L14.611,461.893C6.605,471.022 7.517,484.933 16.647,492.939C25.776,500.944 39.687,500.032 47.693,490.903L430.775,54.067C438.781,44.938 437.869,31.027 428.74,23.021C419.611,15.015 405.699,15.927 397.694,25.056Z"/></svg> 2 | -------------------------------------------------------------------------------- /tests/Fixtures/icons/regular/test.svg: -------------------------------------------------------------------------------- 1 | <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path d="M397.694,25.056L14.611,461.893C6.605,471.022 7.517,484.933 16.647,492.939C25.776,500.944 39.687,500.032 47.693,490.903L430.775,54.067C438.781,44.938 437.869,31.027 428.74,23.021C419.611,15.015 405.699,15.927 397.694,25.056Z"/></svg> 2 | -------------------------------------------------------------------------------- /tests/Fixtures/icons/sharp-light/test.svg: -------------------------------------------------------------------------------- 1 | <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path d="M397.694,25.056L14.611,461.893C6.605,471.022 7.517,484.933 16.647,492.939C25.776,500.944 39.687,500.032 47.693,490.903L430.775,54.067C438.781,44.938 437.869,31.027 428.74,23.021C419.611,15.015 405.699,15.927 397.694,25.056Z"/></svg> 2 | -------------------------------------------------------------------------------- /tests/Fixtures/icons/sharp-regular/test.svg: -------------------------------------------------------------------------------- 1 | <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path d="M397.694,25.056L14.611,461.893C6.605,471.022 7.517,484.933 16.647,492.939C25.776,500.944 39.687,500.032 47.693,490.903L430.775,54.067C438.781,44.938 437.869,31.027 428.74,23.021C419.611,15.015 405.699,15.927 397.694,25.056Z"/></svg> 2 | -------------------------------------------------------------------------------- /tests/Fixtures/icons/sharp-solid/test.svg: -------------------------------------------------------------------------------- 1 | <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path d="M397.694,25.056L14.611,461.893C6.605,471.022 7.517,484.933 16.647,492.939C25.776,500.944 39.687,500.032 47.693,490.903L430.775,54.067C438.781,44.938 437.869,31.027 428.74,23.021C419.611,15.015 405.699,15.927 397.694,25.056Z"/></svg> 2 | -------------------------------------------------------------------------------- /tests/Fixtures/icons/solid/test.svg: -------------------------------------------------------------------------------- 1 | <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path d="M397.694,25.056L14.611,461.893C6.605,471.022 7.517,484.933 16.647,492.939C25.776,500.944 39.687,500.032 47.693,490.903L430.775,54.067C438.781,44.938 437.869,31.027 428.74,23.021C419.611,15.015 405.699,15.927 397.694,25.056Z"/></svg> 2 | -------------------------------------------------------------------------------- /tests/Fixtures/icons/thin/test.svg: -------------------------------------------------------------------------------- 1 | <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path d="M397.694,25.056L14.611,461.893C6.605,471.022 7.517,484.933 16.647,492.939C25.776,500.944 39.687,500.032 47.693,490.903L430.775,54.067C438.781,44.938 437.869,31.027 428.74,23.021C419.611,15.015 405.699,15.927 397.694,25.056Z"/></svg> 2 | -------------------------------------------------------------------------------- /tests/Unit/FontAwesomeSVGTest.php: -------------------------------------------------------------------------------- 1 | <?php 2 | 3 | namespace Husseinalhammad\FontawesomeSvg\Tests; 4 | 5 | use Exception; 6 | use FontAwesomeSVG; 7 | use PHPUnit\Framework\TestCase; 8 | 9 | final class FontAwesomeSVGTest extends TestCase 10 | { 11 | static public function icons(): array 12 | { 13 | return [ 14 | ['fab fa-test', 'brands', 'test'], 15 | ['fad fa-test', 'duotone', 'test'], 16 | ['fal fa-test', 'light', 'test'], 17 | ['far fa-test', 'regular', 'test'], 18 | ['fas fa-test', 'solid', 'test'], 19 | ['fat fa-test', 'thin', 'test'], 20 | ['fa-brands fa-test', 'brands', 'test'], 21 | ['fa-duotone fa-test', 'duotone', 'test'], 22 | ['fa-light fa-test', 'light', 'test'], 23 | ['fa-regular fa-test', 'regular', 'test'], 24 | ['fa-solid fa-test', 'solid', 'test'], 25 | ['fa-thin fa-test', 'thin', 'test'], 26 | ['fa-sharp fa-light fa-test', 'sharp-light', 'test'], 27 | ['fa-sharp fa-regular fa-test', 'sharp-regular', 'test'], 28 | ['fa-sharp fa-solid fa-test', 'sharp-solid', 'test'], 29 | ['fasl fa-test', 'sharp-light', 'test'], 30 | ['fasr fa-test', 'sharp-regular', 'test'], 31 | ['fass fa-test', 'sharp-solid', 'test'], 32 | ]; 33 | } 34 | 35 | private function createInstance(): FontAwesomeSVG 36 | { 37 | return new FontAwesomeSVG(__DIR__ . '/../Fixtures/icons'); 38 | } 39 | 40 | public function test_it_requires_an_existing_svg_dir(): void 41 | { 42 | $this->expectException(Exception::class); 43 | 44 | new FontAwesomeSVG('path/does/not/exist'); 45 | } 46 | 47 | /** 48 | * @dataProvider icons 49 | */ 50 | public function test_it_can_get_an_svg($icon): void 51 | { 52 | $fa = $this->createInstance(); 53 | 54 | $svg = $fa->get_svg($icon); 55 | 56 | $this->assertStringContainsString('class="svg-inline--fa"', $svg); 57 | $this->assertStringContainsString('style="color:currentColor"', $svg); 58 | $this->assertStringContainsString('fill="currentColor"', $svg); 59 | $this->assertStringContainsString('role="img"', $svg); 60 | $this->assertStringContainsString('aria-hidden="true"', $svg); 61 | } 62 | 63 | /** 64 | * @dataProvider icons 65 | */ 66 | public function test_it_can_add_a_custom_class($icon): void 67 | { 68 | $fa = $this->createInstance(); 69 | 70 | $svg = $fa->get_svg($icon, ['class' => 'my-custom-class another-class']); 71 | 72 | $this->assertStringContainsString('class="svg-inline--fa my-custom-class another-class"', $svg); 73 | } 74 | 75 | /** 76 | * @dataProvider icons 77 | */ 78 | public function test_it_can_remove_the_default_class($icon): void 79 | { 80 | $fa = $this->createInstance(); 81 | 82 | $svg = $fa->get_svg($icon, ['default_class' => false]); 83 | 84 | $this->assertStringNotContainsString('svg-inline--fa', $svg); 85 | } 86 | 87 | /** 88 | * @dataProvider icons 89 | */ 90 | public function test_it_can_change_path_fill($icon): void 91 | { 92 | $fa = $this->createInstance(); 93 | 94 | $svg = $fa->get_svg($icon, ['fill' => '#f44336']); 95 | 96 | $this->assertStringContainsString('fill="#f44336"', $svg); 97 | } 98 | 99 | /** 100 | * @dataProvider icons 101 | */ 102 | public function test_it_can_add_title_tag($icon): void 103 | { 104 | $fa = $this->createInstance(); 105 | 106 | $svg = $fa->get_svg($icon, ['title' => 'My accessible icon']); 107 | 108 | $this->assertStringContainsString('<title>My accessible icon', $svg); 109 | } 110 | 111 | /** 112 | * @dataProvider icons 113 | */ 114 | public function test_it_can_add_title_id_attribute($icon): void 115 | { 116 | $fa = $this->createInstance(); 117 | 118 | $svg = $fa->get_svg($icon, [ 119 | 'title' => 'My accessible icon', 120 | 'title_id' => 'my-accessible-attribute', 121 | ]); 122 | 123 | $this->assertStringContainsString('aria-labelledby="my-accessible-attribute"', $svg); 124 | $this->assertStringContainsString('', $svg); 125 | } 126 | 127 | /** 128 | * @dataProvider icons 129 | */ 130 | public function test_it_can_change_role($icon): void 131 | { 132 | $fa = $this->createInstance(); 133 | 134 | $svg = $fa->get_svg($icon, ['role' => 'presentation']); 135 | 136 | $this->assertStringContainsString('role="presentation"', $svg); 137 | } 138 | 139 | /** 140 | * @dataProvider icons 141 | */ 142 | public function test_it_can_add_aria_labels($icon): void 143 | { 144 | $fa = $this->createInstance(); 145 | 146 | $svg = $fa->get_svg($icon, ['aria-label' => 'File']); 147 | 148 | $this->assertStringContainsString('aria-label="File"', $svg); 149 | } 150 | 151 | public function test_it_can_change_duotone_colors(): void 152 | { 153 | $fa = $this->createInstance(); 154 | 155 | $svg = $fa->get_svg('fad fa-test', [ 156 | 'primary' => [ 157 | 'fill' => '#e64980', 158 | 'opacity' => '.1', 159 | ], 160 | 'secondary' => [ 161 | 'fill' => '#fcc417', 162 | 'opacity' => '.2', 163 | ], 164 | ]); 165 | 166 | $this->assertStringContainsString('--fa-primary-color:#e64980', $svg); 167 | $this->assertStringContainsString('--fa-secondary-color:#fcc417', $svg); 168 | $this->assertStringContainsString('--fa-primary-opacity:.1', $svg); 169 | $this->assertStringContainsString('--fa-secondary-opacity:.2', $svg); 170 | $this->assertStringContainsString('fill="#e64980"', $svg); 171 | $this->assertStringContainsString('fill="#fcc417"', $svg); 172 | $this->assertStringContainsString('opacity=".1"', $svg); 173 | $this->assertStringContainsString('opacity=".2"', $svg); 174 | } 175 | 176 | public function test_it_can_remove_duotone_inline_styles(): void 177 | { 178 | $fa = $this->createInstance(); 179 | 180 | $svg = $fa->get_svg('fad fa-test', [ 181 | 'inline_style' => false, 182 | ]); 183 | 184 | $this->assertStringNotContainsString('--fa-primary-color', $svg); 185 | $this->assertStringNotContainsString('--fa-primary-opacity', $svg); 186 | $this->assertStringNotContainsString('--fa-secondary-color', $svg); 187 | $this->assertStringNotContainsString('--fa-secondary-opacity', $svg); 188 | } 189 | 190 | /** 191 | * @dataProvider icons 192 | */ 193 | public function test_it_can_get_the_icons($icon, $dir, $filename): void 194 | { 195 | $fa = $this->createInstance(); 196 | 197 | $details = $fa->get_icon_details($icon); 198 | 199 | $this->assertStringContainsString($dir, $details['dir']); 200 | $this->assertStringContainsString($filename, $details['filename']); 201 | } 202 | } 203 | --------------------------------------------------------------------------------