├── .gitignore ├── README.md ├── bin └── snipper ├── composer.json ├── composer.lock ├── phpunit.xml.dist ├── src └── Snipper │ ├── Client │ ├── ClientInterface.php │ └── KnplabsClient.php │ └── Console │ ├── Command │ ├── Get.php │ ├── Init.php │ └── SnipperCommand.php │ └── SnipperApplication.php └── tests ├── .config ├── snipper.empty.json ├── snipper.json └── snipper.wrong.json ├── Snipper ├── Console │ ├── Command │ │ ├── GetTest.php │ │ ├── InitTest.php │ │ └── TestCase.php │ └── SnipperApplicationTest.php └── Mocks │ └── ClientMock.php └── bootstrap.php /.gitignore: -------------------------------------------------------------------------------- 1 | vendor/ 2 | tests/.coverage 3 | *.sublime-* 4 | .editorconfig 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ABANDONED 2 | 3 | This project is abandoned. Could be rewritten in Go. 4 | 5 | # Snipper 6 | 7 | Easy way to manage snippets from GitHub Gist service. 8 | 9 | > Project is in development — only basic functionality is available 10 | 11 | Snipper offers easy way to manage your code snippets directly from GitHub Gist service. 12 | Create gist with `#` in description (any part of description) and star it. Then 13 | use your gist as code snippet by it's name without hash sign. 14 | 15 | ## Installation 16 | 17 | ```bash 18 | composer global require snipper/snipper:@stable 19 | ``` 20 | 21 | ## Usage 22 | 23 | ### Initialize application 24 | 25 | You must provide GitHub personal access token to bypass API request limit. In current release no permissions required. 26 | 27 | ```bash 28 | snipper init 29 | ``` 30 | 31 | ### Get snippet 32 | 33 | Snipper search snippets only in your starred gists by hash tag as name of the snippet. 34 | 35 | If there are several snippets with same name then Snipper ask you which one to use. 36 | 37 | ```bash 38 | snipper get # without hash sign 39 | ``` 40 | 41 | This command will try to get snippet with `#` in **description** of the gist. 42 | 43 | ## LICENSE 44 | 45 | [WTFPL](http://www.wtfpl.net/) 46 | -------------------------------------------------------------------------------- /bin/snipper: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | run(); 21 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "snipper/snipper", 3 | "description": "Easy way to get snippets from GitHub Gist service", 4 | "keywords": ["cli", "util", "snippet", "gist", "github"], 5 | "homepage": "https://github.com/ilsenem/snipper", 6 | "license": "MIT", 7 | "authors": [ 8 | { 9 | "name": "Ilya Nemytchenko", 10 | "email": "ilya.nemytchenko@gmail.com", 11 | "role": "Developer" 12 | } 13 | ], 14 | "bin": [ 15 | "bin/snipper" 16 | ], 17 | "autoload": { 18 | "psr-4": { 19 | "Snipper\\": "src/Snipper/" 20 | } 21 | }, 22 | "autoload-dev": { 23 | "psr-4": { 24 | "Snipper\\Tests\\": "tests/Snipper/" 25 | } 26 | }, 27 | "minimum-stability": "stable", 28 | "require": { 29 | "php": "^5.4", 30 | "symfony/console": "^2.7", 31 | "knplabs/github-api": "^1.4" 32 | }, 33 | "require-dev": { 34 | "php": "^5.4", 35 | "ext-xdebug": "^2.2", 36 | "symfony/var-dumper": "^2.7", 37 | "phpunit/phpunit": "^4.7", 38 | "phpunit/php-code-coverage": "^2.1" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /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#composer-lock-the-lock-file", 5 | "This file is @generated automatically" 6 | ], 7 | "hash": "4b064ddfbe19619b3b5d8eb57ed53a48", 8 | "packages": [ 9 | { 10 | "name": "guzzle/guzzle", 11 | "version": "v3.9.3", 12 | "source": { 13 | "type": "git", 14 | "url": "https://github.com/guzzle/guzzle3.git", 15 | "reference": "0645b70d953bc1c067bbc8d5bc53194706b628d9" 16 | }, 17 | "dist": { 18 | "type": "zip", 19 | "url": "https://api.github.com/repos/guzzle/guzzle3/zipball/0645b70d953bc1c067bbc8d5bc53194706b628d9", 20 | "reference": "0645b70d953bc1c067bbc8d5bc53194706b628d9", 21 | "shasum": "" 22 | }, 23 | "require": { 24 | "ext-curl": "*", 25 | "php": ">=5.3.3", 26 | "symfony/event-dispatcher": "~2.1" 27 | }, 28 | "replace": { 29 | "guzzle/batch": "self.version", 30 | "guzzle/cache": "self.version", 31 | "guzzle/common": "self.version", 32 | "guzzle/http": "self.version", 33 | "guzzle/inflection": "self.version", 34 | "guzzle/iterator": "self.version", 35 | "guzzle/log": "self.version", 36 | "guzzle/parser": "self.version", 37 | "guzzle/plugin": "self.version", 38 | "guzzle/plugin-async": "self.version", 39 | "guzzle/plugin-backoff": "self.version", 40 | "guzzle/plugin-cache": "self.version", 41 | "guzzle/plugin-cookie": "self.version", 42 | "guzzle/plugin-curlauth": "self.version", 43 | "guzzle/plugin-error-response": "self.version", 44 | "guzzle/plugin-history": "self.version", 45 | "guzzle/plugin-log": "self.version", 46 | "guzzle/plugin-md5": "self.version", 47 | "guzzle/plugin-mock": "self.version", 48 | "guzzle/plugin-oauth": "self.version", 49 | "guzzle/service": "self.version", 50 | "guzzle/stream": "self.version" 51 | }, 52 | "require-dev": { 53 | "doctrine/cache": "~1.3", 54 | "monolog/monolog": "~1.0", 55 | "phpunit/phpunit": "3.7.*", 56 | "psr/log": "~1.0", 57 | "symfony/class-loader": "~2.1", 58 | "zendframework/zend-cache": "2.*,<2.3", 59 | "zendframework/zend-log": "2.*,<2.3" 60 | }, 61 | "suggest": { 62 | "guzzlehttp/guzzle": "Guzzle 5 has moved to a new package name. The package you have installed, Guzzle 3, is deprecated." 63 | }, 64 | "type": "library", 65 | "extra": { 66 | "branch-alias": { 67 | "dev-master": "3.9-dev" 68 | } 69 | }, 70 | "autoload": { 71 | "psr-0": { 72 | "Guzzle": "src/", 73 | "Guzzle\\Tests": "tests/" 74 | } 75 | }, 76 | "notification-url": "https://packagist.org/downloads/", 77 | "license": [ 78 | "MIT" 79 | ], 80 | "authors": [ 81 | { 82 | "name": "Michael Dowling", 83 | "email": "mtdowling@gmail.com", 84 | "homepage": "https://github.com/mtdowling" 85 | }, 86 | { 87 | "name": "Guzzle Community", 88 | "homepage": "https://github.com/guzzle/guzzle/contributors" 89 | } 90 | ], 91 | "description": "PHP HTTP client. This library is deprecated in favor of https://packagist.org/packages/guzzlehttp/guzzle", 92 | "homepage": "http://guzzlephp.org/", 93 | "keywords": [ 94 | "client", 95 | "curl", 96 | "framework", 97 | "http", 98 | "http client", 99 | "rest", 100 | "web service" 101 | ], 102 | "time": "2015-03-18 18:23:50" 103 | }, 104 | { 105 | "name": "knplabs/github-api", 106 | "version": "1.4.14", 107 | "source": { 108 | "type": "git", 109 | "url": "https://github.com/KnpLabs/php-github-api.git", 110 | "reference": "9010dbe21f4b0bae0edae26bbe031d7d91347938" 111 | }, 112 | "dist": { 113 | "type": "zip", 114 | "url": "https://api.github.com/repos/KnpLabs/php-github-api/zipball/9010dbe21f4b0bae0edae26bbe031d7d91347938", 115 | "reference": "9010dbe21f4b0bae0edae26bbe031d7d91347938", 116 | "shasum": "" 117 | }, 118 | "require": { 119 | "ext-curl": "*", 120 | "guzzle/guzzle": "~3.7", 121 | "php": ">=5.3.2" 122 | }, 123 | "require-dev": { 124 | "phpunit/phpunit": "~4.0" 125 | }, 126 | "suggest": { 127 | "knplabs/gaufrette": "Needed for optional Gaufrette cache" 128 | }, 129 | "type": "library", 130 | "extra": { 131 | "branch-alias": { 132 | "dev-master": "1.4.x-dev" 133 | } 134 | }, 135 | "autoload": { 136 | "psr-4": { 137 | "Github\\": "lib/Github/" 138 | } 139 | }, 140 | "notification-url": "https://packagist.org/downloads/", 141 | "license": [ 142 | "MIT" 143 | ], 144 | "authors": [ 145 | { 146 | "name": "Thibault Duplessis", 147 | "email": "thibault.duplessis@gmail.com", 148 | "homepage": "http://ornicar.github.com" 149 | }, 150 | { 151 | "name": "KnpLabs Team", 152 | "homepage": "http://knplabs.com" 153 | } 154 | ], 155 | "description": "GitHub API v3 client", 156 | "homepage": "https://github.com/KnpLabs/php-github-api", 157 | "keywords": [ 158 | "api", 159 | "gh", 160 | "gist", 161 | "github" 162 | ], 163 | "time": "2015-07-03 14:59:20" 164 | }, 165 | { 166 | "name": "symfony/console", 167 | "version": "v2.7.2", 168 | "source": { 169 | "type": "git", 170 | "url": "https://github.com/symfony/Console.git", 171 | "reference": "8cf484449130cabfd98dcb4694ca9945802a21ed" 172 | }, 173 | "dist": { 174 | "type": "zip", 175 | "url": "https://api.github.com/repos/symfony/Console/zipball/8cf484449130cabfd98dcb4694ca9945802a21ed", 176 | "reference": "8cf484449130cabfd98dcb4694ca9945802a21ed", 177 | "shasum": "" 178 | }, 179 | "require": { 180 | "php": ">=5.3.9" 181 | }, 182 | "require-dev": { 183 | "psr/log": "~1.0", 184 | "symfony/event-dispatcher": "~2.1", 185 | "symfony/phpunit-bridge": "~2.7", 186 | "symfony/process": "~2.1" 187 | }, 188 | "suggest": { 189 | "psr/log": "For using the console logger", 190 | "symfony/event-dispatcher": "", 191 | "symfony/process": "" 192 | }, 193 | "type": "library", 194 | "extra": { 195 | "branch-alias": { 196 | "dev-master": "2.7-dev" 197 | } 198 | }, 199 | "autoload": { 200 | "psr-4": { 201 | "Symfony\\Component\\Console\\": "" 202 | } 203 | }, 204 | "notification-url": "https://packagist.org/downloads/", 205 | "license": [ 206 | "MIT" 207 | ], 208 | "authors": [ 209 | { 210 | "name": "Fabien Potencier", 211 | "email": "fabien@symfony.com" 212 | }, 213 | { 214 | "name": "Symfony Community", 215 | "homepage": "https://symfony.com/contributors" 216 | } 217 | ], 218 | "description": "Symfony Console Component", 219 | "homepage": "https://symfony.com", 220 | "time": "2015-07-09 16:07:40" 221 | }, 222 | { 223 | "name": "symfony/event-dispatcher", 224 | "version": "v2.7.2", 225 | "source": { 226 | "type": "git", 227 | "url": "https://github.com/symfony/EventDispatcher.git", 228 | "reference": "9310b5f9a87ec2ea75d20fec0b0017c77c66dac3" 229 | }, 230 | "dist": { 231 | "type": "zip", 232 | "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/9310b5f9a87ec2ea75d20fec0b0017c77c66dac3", 233 | "reference": "9310b5f9a87ec2ea75d20fec0b0017c77c66dac3", 234 | "shasum": "" 235 | }, 236 | "require": { 237 | "php": ">=5.3.9" 238 | }, 239 | "require-dev": { 240 | "psr/log": "~1.0", 241 | "symfony/config": "~2.0,>=2.0.5", 242 | "symfony/dependency-injection": "~2.6", 243 | "symfony/expression-language": "~2.6", 244 | "symfony/phpunit-bridge": "~2.7", 245 | "symfony/stopwatch": "~2.3" 246 | }, 247 | "suggest": { 248 | "symfony/dependency-injection": "", 249 | "symfony/http-kernel": "" 250 | }, 251 | "type": "library", 252 | "extra": { 253 | "branch-alias": { 254 | "dev-master": "2.7-dev" 255 | } 256 | }, 257 | "autoload": { 258 | "psr-4": { 259 | "Symfony\\Component\\EventDispatcher\\": "" 260 | } 261 | }, 262 | "notification-url": "https://packagist.org/downloads/", 263 | "license": [ 264 | "MIT" 265 | ], 266 | "authors": [ 267 | { 268 | "name": "Fabien Potencier", 269 | "email": "fabien@symfony.com" 270 | }, 271 | { 272 | "name": "Symfony Community", 273 | "homepage": "https://symfony.com/contributors" 274 | } 275 | ], 276 | "description": "Symfony EventDispatcher Component", 277 | "homepage": "https://symfony.com", 278 | "time": "2015-06-18 19:21:56" 279 | } 280 | ], 281 | "packages-dev": [ 282 | { 283 | "name": "doctrine/instantiator", 284 | "version": "1.0.5", 285 | "source": { 286 | "type": "git", 287 | "url": "https://github.com/doctrine/instantiator.git", 288 | "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" 289 | }, 290 | "dist": { 291 | "type": "zip", 292 | "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", 293 | "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", 294 | "shasum": "" 295 | }, 296 | "require": { 297 | "php": ">=5.3,<8.0-DEV" 298 | }, 299 | "require-dev": { 300 | "athletic/athletic": "~0.1.8", 301 | "ext-pdo": "*", 302 | "ext-phar": "*", 303 | "phpunit/phpunit": "~4.0", 304 | "squizlabs/php_codesniffer": "~2.0" 305 | }, 306 | "type": "library", 307 | "extra": { 308 | "branch-alias": { 309 | "dev-master": "1.0.x-dev" 310 | } 311 | }, 312 | "autoload": { 313 | "psr-4": { 314 | "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" 315 | } 316 | }, 317 | "notification-url": "https://packagist.org/downloads/", 318 | "license": [ 319 | "MIT" 320 | ], 321 | "authors": [ 322 | { 323 | "name": "Marco Pivetta", 324 | "email": "ocramius@gmail.com", 325 | "homepage": "http://ocramius.github.com/" 326 | } 327 | ], 328 | "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", 329 | "homepage": "https://github.com/doctrine/instantiator", 330 | "keywords": [ 331 | "constructor", 332 | "instantiate" 333 | ], 334 | "time": "2015-06-14 21:17:01" 335 | }, 336 | { 337 | "name": "phpdocumentor/reflection-docblock", 338 | "version": "2.0.4", 339 | "source": { 340 | "type": "git", 341 | "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", 342 | "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8" 343 | }, 344 | "dist": { 345 | "type": "zip", 346 | "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/d68dbdc53dc358a816f00b300704702b2eaff7b8", 347 | "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8", 348 | "shasum": "" 349 | }, 350 | "require": { 351 | "php": ">=5.3.3" 352 | }, 353 | "require-dev": { 354 | "phpunit/phpunit": "~4.0" 355 | }, 356 | "suggest": { 357 | "dflydev/markdown": "~1.0", 358 | "erusev/parsedown": "~1.0" 359 | }, 360 | "type": "library", 361 | "extra": { 362 | "branch-alias": { 363 | "dev-master": "2.0.x-dev" 364 | } 365 | }, 366 | "autoload": { 367 | "psr-0": { 368 | "phpDocumentor": [ 369 | "src/" 370 | ] 371 | } 372 | }, 373 | "notification-url": "https://packagist.org/downloads/", 374 | "license": [ 375 | "MIT" 376 | ], 377 | "authors": [ 378 | { 379 | "name": "Mike van Riel", 380 | "email": "mike.vanriel@naenius.com" 381 | } 382 | ], 383 | "time": "2015-02-03 12:10:50" 384 | }, 385 | { 386 | "name": "phpspec/prophecy", 387 | "version": "v1.4.1", 388 | "source": { 389 | "type": "git", 390 | "url": "https://github.com/phpspec/prophecy.git", 391 | "reference": "3132b1f44c7bf2ec4c7eb2d3cb78fdeca760d373" 392 | }, 393 | "dist": { 394 | "type": "zip", 395 | "url": "https://api.github.com/repos/phpspec/prophecy/zipball/3132b1f44c7bf2ec4c7eb2d3cb78fdeca760d373", 396 | "reference": "3132b1f44c7bf2ec4c7eb2d3cb78fdeca760d373", 397 | "shasum": "" 398 | }, 399 | "require": { 400 | "doctrine/instantiator": "^1.0.2", 401 | "phpdocumentor/reflection-docblock": "~2.0", 402 | "sebastian/comparator": "~1.1" 403 | }, 404 | "require-dev": { 405 | "phpspec/phpspec": "~2.0" 406 | }, 407 | "type": "library", 408 | "extra": { 409 | "branch-alias": { 410 | "dev-master": "1.4.x-dev" 411 | } 412 | }, 413 | "autoload": { 414 | "psr-0": { 415 | "Prophecy\\": "src/" 416 | } 417 | }, 418 | "notification-url": "https://packagist.org/downloads/", 419 | "license": [ 420 | "MIT" 421 | ], 422 | "authors": [ 423 | { 424 | "name": "Konstantin Kudryashov", 425 | "email": "ever.zet@gmail.com", 426 | "homepage": "http://everzet.com" 427 | }, 428 | { 429 | "name": "Marcello Duarte", 430 | "email": "marcello.duarte@gmail.com" 431 | } 432 | ], 433 | "description": "Highly opinionated mocking framework for PHP 5.3+", 434 | "homepage": "https://github.com/phpspec/prophecy", 435 | "keywords": [ 436 | "Double", 437 | "Dummy", 438 | "fake", 439 | "mock", 440 | "spy", 441 | "stub" 442 | ], 443 | "time": "2015-04-27 22:15:08" 444 | }, 445 | { 446 | "name": "phpunit/php-code-coverage", 447 | "version": "2.1.9", 448 | "source": { 449 | "type": "git", 450 | "url": "https://github.com/sebastianbergmann/php-code-coverage.git", 451 | "reference": "5bd48b86cd282da411bb80baac1398ce3fefac41" 452 | }, 453 | "dist": { 454 | "type": "zip", 455 | "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/5bd48b86cd282da411bb80baac1398ce3fefac41", 456 | "reference": "5bd48b86cd282da411bb80baac1398ce3fefac41", 457 | "shasum": "" 458 | }, 459 | "require": { 460 | "php": ">=5.3.3", 461 | "phpunit/php-file-iterator": "~1.3", 462 | "phpunit/php-text-template": "~1.2", 463 | "phpunit/php-token-stream": "~1.3", 464 | "sebastian/environment": "~1.0", 465 | "sebastian/version": "~1.0" 466 | }, 467 | "require-dev": { 468 | "ext-xdebug": ">=2.1.4", 469 | "phpunit/phpunit": "~4" 470 | }, 471 | "suggest": { 472 | "ext-dom": "*", 473 | "ext-xdebug": ">=2.2.1", 474 | "ext-xmlwriter": "*" 475 | }, 476 | "type": "library", 477 | "extra": { 478 | "branch-alias": { 479 | "dev-master": "2.1.x-dev" 480 | } 481 | }, 482 | "autoload": { 483 | "classmap": [ 484 | "src/" 485 | ] 486 | }, 487 | "notification-url": "https://packagist.org/downloads/", 488 | "license": [ 489 | "BSD-3-Clause" 490 | ], 491 | "authors": [ 492 | { 493 | "name": "Sebastian Bergmann", 494 | "email": "sb@sebastian-bergmann.de", 495 | "role": "lead" 496 | } 497 | ], 498 | "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", 499 | "homepage": "https://github.com/sebastianbergmann/php-code-coverage", 500 | "keywords": [ 501 | "coverage", 502 | "testing", 503 | "xunit" 504 | ], 505 | "time": "2015-07-26 12:54:47" 506 | }, 507 | { 508 | "name": "phpunit/php-file-iterator", 509 | "version": "1.4.1", 510 | "source": { 511 | "type": "git", 512 | "url": "https://github.com/sebastianbergmann/php-file-iterator.git", 513 | "reference": "6150bf2c35d3fc379e50c7602b75caceaa39dbf0" 514 | }, 515 | "dist": { 516 | "type": "zip", 517 | "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/6150bf2c35d3fc379e50c7602b75caceaa39dbf0", 518 | "reference": "6150bf2c35d3fc379e50c7602b75caceaa39dbf0", 519 | "shasum": "" 520 | }, 521 | "require": { 522 | "php": ">=5.3.3" 523 | }, 524 | "type": "library", 525 | "extra": { 526 | "branch-alias": { 527 | "dev-master": "1.4.x-dev" 528 | } 529 | }, 530 | "autoload": { 531 | "classmap": [ 532 | "src/" 533 | ] 534 | }, 535 | "notification-url": "https://packagist.org/downloads/", 536 | "license": [ 537 | "BSD-3-Clause" 538 | ], 539 | "authors": [ 540 | { 541 | "name": "Sebastian Bergmann", 542 | "email": "sb@sebastian-bergmann.de", 543 | "role": "lead" 544 | } 545 | ], 546 | "description": "FilterIterator implementation that filters files based on a list of suffixes.", 547 | "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", 548 | "keywords": [ 549 | "filesystem", 550 | "iterator" 551 | ], 552 | "time": "2015-06-21 13:08:43" 553 | }, 554 | { 555 | "name": "phpunit/php-text-template", 556 | "version": "1.2.1", 557 | "source": { 558 | "type": "git", 559 | "url": "https://github.com/sebastianbergmann/php-text-template.git", 560 | "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" 561 | }, 562 | "dist": { 563 | "type": "zip", 564 | "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", 565 | "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", 566 | "shasum": "" 567 | }, 568 | "require": { 569 | "php": ">=5.3.3" 570 | }, 571 | "type": "library", 572 | "autoload": { 573 | "classmap": [ 574 | "src/" 575 | ] 576 | }, 577 | "notification-url": "https://packagist.org/downloads/", 578 | "license": [ 579 | "BSD-3-Clause" 580 | ], 581 | "authors": [ 582 | { 583 | "name": "Sebastian Bergmann", 584 | "email": "sebastian@phpunit.de", 585 | "role": "lead" 586 | } 587 | ], 588 | "description": "Simple template engine.", 589 | "homepage": "https://github.com/sebastianbergmann/php-text-template/", 590 | "keywords": [ 591 | "template" 592 | ], 593 | "time": "2015-06-21 13:50:34" 594 | }, 595 | { 596 | "name": "phpunit/php-timer", 597 | "version": "1.0.7", 598 | "source": { 599 | "type": "git", 600 | "url": "https://github.com/sebastianbergmann/php-timer.git", 601 | "reference": "3e82f4e9fc92665fafd9157568e4dcb01d014e5b" 602 | }, 603 | "dist": { 604 | "type": "zip", 605 | "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3e82f4e9fc92665fafd9157568e4dcb01d014e5b", 606 | "reference": "3e82f4e9fc92665fafd9157568e4dcb01d014e5b", 607 | "shasum": "" 608 | }, 609 | "require": { 610 | "php": ">=5.3.3" 611 | }, 612 | "type": "library", 613 | "autoload": { 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": "sb@sebastian-bergmann.de", 626 | "role": "lead" 627 | } 628 | ], 629 | "description": "Utility class for timing", 630 | "homepage": "https://github.com/sebastianbergmann/php-timer/", 631 | "keywords": [ 632 | "timer" 633 | ], 634 | "time": "2015-06-21 08:01:12" 635 | }, 636 | { 637 | "name": "phpunit/php-token-stream", 638 | "version": "1.4.3", 639 | "source": { 640 | "type": "git", 641 | "url": "https://github.com/sebastianbergmann/php-token-stream.git", 642 | "reference": "7a9b0969488c3c54fd62b4d504b3ec758fd005d9" 643 | }, 644 | "dist": { 645 | "type": "zip", 646 | "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/7a9b0969488c3c54fd62b4d504b3ec758fd005d9", 647 | "reference": "7a9b0969488c3c54fd62b4d504b3ec758fd005d9", 648 | "shasum": "" 649 | }, 650 | "require": { 651 | "ext-tokenizer": "*", 652 | "php": ">=5.3.3" 653 | }, 654 | "require-dev": { 655 | "phpunit/phpunit": "~4.2" 656 | }, 657 | "type": "library", 658 | "extra": { 659 | "branch-alias": { 660 | "dev-master": "1.4-dev" 661 | } 662 | }, 663 | "autoload": { 664 | "classmap": [ 665 | "src/" 666 | ] 667 | }, 668 | "notification-url": "https://packagist.org/downloads/", 669 | "license": [ 670 | "BSD-3-Clause" 671 | ], 672 | "authors": [ 673 | { 674 | "name": "Sebastian Bergmann", 675 | "email": "sebastian@phpunit.de" 676 | } 677 | ], 678 | "description": "Wrapper around PHP's tokenizer extension.", 679 | "homepage": "https://github.com/sebastianbergmann/php-token-stream/", 680 | "keywords": [ 681 | "tokenizer" 682 | ], 683 | "time": "2015-06-19 03:43:16" 684 | }, 685 | { 686 | "name": "phpunit/phpunit", 687 | "version": "4.7.7", 688 | "source": { 689 | "type": "git", 690 | "url": "https://github.com/sebastianbergmann/phpunit.git", 691 | "reference": "9b97f9d807b862c2de2a36e86690000801c85724" 692 | }, 693 | "dist": { 694 | "type": "zip", 695 | "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/9b97f9d807b862c2de2a36e86690000801c85724", 696 | "reference": "9b97f9d807b862c2de2a36e86690000801c85724", 697 | "shasum": "" 698 | }, 699 | "require": { 700 | "ext-dom": "*", 701 | "ext-json": "*", 702 | "ext-pcre": "*", 703 | "ext-reflection": "*", 704 | "ext-spl": "*", 705 | "php": ">=5.3.3", 706 | "phpspec/prophecy": "~1.3,>=1.3.1", 707 | "phpunit/php-code-coverage": "~2.1", 708 | "phpunit/php-file-iterator": "~1.4", 709 | "phpunit/php-text-template": "~1.2", 710 | "phpunit/php-timer": ">=1.0.6", 711 | "phpunit/phpunit-mock-objects": "~2.3", 712 | "sebastian/comparator": "~1.1", 713 | "sebastian/diff": "~1.2", 714 | "sebastian/environment": "~1.2", 715 | "sebastian/exporter": "~1.2", 716 | "sebastian/global-state": "~1.0", 717 | "sebastian/version": "~1.0", 718 | "symfony/yaml": "~2.1|~3.0" 719 | }, 720 | "suggest": { 721 | "phpunit/php-invoker": "~1.1" 722 | }, 723 | "bin": [ 724 | "phpunit" 725 | ], 726 | "type": "library", 727 | "extra": { 728 | "branch-alias": { 729 | "dev-master": "4.7.x-dev" 730 | } 731 | }, 732 | "autoload": { 733 | "classmap": [ 734 | "src/" 735 | ] 736 | }, 737 | "notification-url": "https://packagist.org/downloads/", 738 | "license": [ 739 | "BSD-3-Clause" 740 | ], 741 | "authors": [ 742 | { 743 | "name": "Sebastian Bergmann", 744 | "email": "sebastian@phpunit.de", 745 | "role": "lead" 746 | } 747 | ], 748 | "description": "The PHP Unit Testing framework.", 749 | "homepage": "https://phpunit.de/", 750 | "keywords": [ 751 | "phpunit", 752 | "testing", 753 | "xunit" 754 | ], 755 | "time": "2015-07-13 11:28:34" 756 | }, 757 | { 758 | "name": "phpunit/phpunit-mock-objects", 759 | "version": "2.3.6", 760 | "source": { 761 | "type": "git", 762 | "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", 763 | "reference": "18dfbcb81d05e2296c0bcddd4db96cade75e6f42" 764 | }, 765 | "dist": { 766 | "type": "zip", 767 | "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/18dfbcb81d05e2296c0bcddd4db96cade75e6f42", 768 | "reference": "18dfbcb81d05e2296c0bcddd4db96cade75e6f42", 769 | "shasum": "" 770 | }, 771 | "require": { 772 | "doctrine/instantiator": "~1.0,>=1.0.2", 773 | "php": ">=5.3.3", 774 | "phpunit/php-text-template": "~1.2", 775 | "sebastian/exporter": "~1.2" 776 | }, 777 | "require-dev": { 778 | "phpunit/phpunit": "~4.4" 779 | }, 780 | "suggest": { 781 | "ext-soap": "*" 782 | }, 783 | "type": "library", 784 | "extra": { 785 | "branch-alias": { 786 | "dev-master": "2.3.x-dev" 787 | } 788 | }, 789 | "autoload": { 790 | "classmap": [ 791 | "src/" 792 | ] 793 | }, 794 | "notification-url": "https://packagist.org/downloads/", 795 | "license": [ 796 | "BSD-3-Clause" 797 | ], 798 | "authors": [ 799 | { 800 | "name": "Sebastian Bergmann", 801 | "email": "sb@sebastian-bergmann.de", 802 | "role": "lead" 803 | } 804 | ], 805 | "description": "Mock Object library for PHPUnit", 806 | "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", 807 | "keywords": [ 808 | "mock", 809 | "xunit" 810 | ], 811 | "time": "2015-07-10 06:54:24" 812 | }, 813 | { 814 | "name": "sebastian/comparator", 815 | "version": "1.2.0", 816 | "source": { 817 | "type": "git", 818 | "url": "https://github.com/sebastianbergmann/comparator.git", 819 | "reference": "937efb279bd37a375bcadf584dec0726f84dbf22" 820 | }, 821 | "dist": { 822 | "type": "zip", 823 | "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/937efb279bd37a375bcadf584dec0726f84dbf22", 824 | "reference": "937efb279bd37a375bcadf584dec0726f84dbf22", 825 | "shasum": "" 826 | }, 827 | "require": { 828 | "php": ">=5.3.3", 829 | "sebastian/diff": "~1.2", 830 | "sebastian/exporter": "~1.2" 831 | }, 832 | "require-dev": { 833 | "phpunit/phpunit": "~4.4" 834 | }, 835 | "type": "library", 836 | "extra": { 837 | "branch-alias": { 838 | "dev-master": "1.2.x-dev" 839 | } 840 | }, 841 | "autoload": { 842 | "classmap": [ 843 | "src/" 844 | ] 845 | }, 846 | "notification-url": "https://packagist.org/downloads/", 847 | "license": [ 848 | "BSD-3-Clause" 849 | ], 850 | "authors": [ 851 | { 852 | "name": "Jeff Welch", 853 | "email": "whatthejeff@gmail.com" 854 | }, 855 | { 856 | "name": "Volker Dusch", 857 | "email": "github@wallbash.com" 858 | }, 859 | { 860 | "name": "Bernhard Schussek", 861 | "email": "bschussek@2bepublished.at" 862 | }, 863 | { 864 | "name": "Sebastian Bergmann", 865 | "email": "sebastian@phpunit.de" 866 | } 867 | ], 868 | "description": "Provides the functionality to compare PHP values for equality", 869 | "homepage": "http://www.github.com/sebastianbergmann/comparator", 870 | "keywords": [ 871 | "comparator", 872 | "compare", 873 | "equality" 874 | ], 875 | "time": "2015-07-26 15:48:44" 876 | }, 877 | { 878 | "name": "sebastian/diff", 879 | "version": "1.3.0", 880 | "source": { 881 | "type": "git", 882 | "url": "https://github.com/sebastianbergmann/diff.git", 883 | "reference": "863df9687835c62aa423a22412d26fa2ebde3fd3" 884 | }, 885 | "dist": { 886 | "type": "zip", 887 | "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/863df9687835c62aa423a22412d26fa2ebde3fd3", 888 | "reference": "863df9687835c62aa423a22412d26fa2ebde3fd3", 889 | "shasum": "" 890 | }, 891 | "require": { 892 | "php": ">=5.3.3" 893 | }, 894 | "require-dev": { 895 | "phpunit/phpunit": "~4.2" 896 | }, 897 | "type": "library", 898 | "extra": { 899 | "branch-alias": { 900 | "dev-master": "1.3-dev" 901 | } 902 | }, 903 | "autoload": { 904 | "classmap": [ 905 | "src/" 906 | ] 907 | }, 908 | "notification-url": "https://packagist.org/downloads/", 909 | "license": [ 910 | "BSD-3-Clause" 911 | ], 912 | "authors": [ 913 | { 914 | "name": "Kore Nordmann", 915 | "email": "mail@kore-nordmann.de" 916 | }, 917 | { 918 | "name": "Sebastian Bergmann", 919 | "email": "sebastian@phpunit.de" 920 | } 921 | ], 922 | "description": "Diff implementation", 923 | "homepage": "http://www.github.com/sebastianbergmann/diff", 924 | "keywords": [ 925 | "diff" 926 | ], 927 | "time": "2015-02-22 15:13:53" 928 | }, 929 | { 930 | "name": "sebastian/environment", 931 | "version": "1.3.0", 932 | "source": { 933 | "type": "git", 934 | "url": "https://github.com/sebastianbergmann/environment.git", 935 | "reference": "4fe0a44cddd8cc19583a024bdc7374eb2fef0b87" 936 | }, 937 | "dist": { 938 | "type": "zip", 939 | "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/4fe0a44cddd8cc19583a024bdc7374eb2fef0b87", 940 | "reference": "4fe0a44cddd8cc19583a024bdc7374eb2fef0b87", 941 | "shasum": "" 942 | }, 943 | "require": { 944 | "php": ">=5.3.3" 945 | }, 946 | "require-dev": { 947 | "phpunit/phpunit": "~4.4" 948 | }, 949 | "type": "library", 950 | "extra": { 951 | "branch-alias": { 952 | "dev-master": "1.3.x-dev" 953 | } 954 | }, 955 | "autoload": { 956 | "classmap": [ 957 | "src/" 958 | ] 959 | }, 960 | "notification-url": "https://packagist.org/downloads/", 961 | "license": [ 962 | "BSD-3-Clause" 963 | ], 964 | "authors": [ 965 | { 966 | "name": "Sebastian Bergmann", 967 | "email": "sebastian@phpunit.de" 968 | } 969 | ], 970 | "description": "Provides functionality to handle HHVM/PHP environments", 971 | "homepage": "http://www.github.com/sebastianbergmann/environment", 972 | "keywords": [ 973 | "Xdebug", 974 | "environment", 975 | "hhvm" 976 | ], 977 | "time": "2015-07-26 06:42:57" 978 | }, 979 | { 980 | "name": "sebastian/exporter", 981 | "version": "1.2.1", 982 | "source": { 983 | "type": "git", 984 | "url": "https://github.com/sebastianbergmann/exporter.git", 985 | "reference": "7ae5513327cb536431847bcc0c10edba2701064e" 986 | }, 987 | "dist": { 988 | "type": "zip", 989 | "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/7ae5513327cb536431847bcc0c10edba2701064e", 990 | "reference": "7ae5513327cb536431847bcc0c10edba2701064e", 991 | "shasum": "" 992 | }, 993 | "require": { 994 | "php": ">=5.3.3", 995 | "sebastian/recursion-context": "~1.0" 996 | }, 997 | "require-dev": { 998 | "phpunit/phpunit": "~4.4" 999 | }, 1000 | "type": "library", 1001 | "extra": { 1002 | "branch-alias": { 1003 | "dev-master": "1.2.x-dev" 1004 | } 1005 | }, 1006 | "autoload": { 1007 | "classmap": [ 1008 | "src/" 1009 | ] 1010 | }, 1011 | "notification-url": "https://packagist.org/downloads/", 1012 | "license": [ 1013 | "BSD-3-Clause" 1014 | ], 1015 | "authors": [ 1016 | { 1017 | "name": "Jeff Welch", 1018 | "email": "whatthejeff@gmail.com" 1019 | }, 1020 | { 1021 | "name": "Volker Dusch", 1022 | "email": "github@wallbash.com" 1023 | }, 1024 | { 1025 | "name": "Bernhard Schussek", 1026 | "email": "bschussek@2bepublished.at" 1027 | }, 1028 | { 1029 | "name": "Sebastian Bergmann", 1030 | "email": "sebastian@phpunit.de" 1031 | }, 1032 | { 1033 | "name": "Adam Harvey", 1034 | "email": "aharvey@php.net" 1035 | } 1036 | ], 1037 | "description": "Provides the functionality to export PHP variables for visualization", 1038 | "homepage": "http://www.github.com/sebastianbergmann/exporter", 1039 | "keywords": [ 1040 | "export", 1041 | "exporter" 1042 | ], 1043 | "time": "2015-06-21 07:55:53" 1044 | }, 1045 | { 1046 | "name": "sebastian/global-state", 1047 | "version": "1.0.0", 1048 | "source": { 1049 | "type": "git", 1050 | "url": "https://github.com/sebastianbergmann/global-state.git", 1051 | "reference": "c7428acdb62ece0a45e6306f1ae85e1c05b09c01" 1052 | }, 1053 | "dist": { 1054 | "type": "zip", 1055 | "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/c7428acdb62ece0a45e6306f1ae85e1c05b09c01", 1056 | "reference": "c7428acdb62ece0a45e6306f1ae85e1c05b09c01", 1057 | "shasum": "" 1058 | }, 1059 | "require": { 1060 | "php": ">=5.3.3" 1061 | }, 1062 | "require-dev": { 1063 | "phpunit/phpunit": "~4.2" 1064 | }, 1065 | "suggest": { 1066 | "ext-uopz": "*" 1067 | }, 1068 | "type": "library", 1069 | "extra": { 1070 | "branch-alias": { 1071 | "dev-master": "1.0-dev" 1072 | } 1073 | }, 1074 | "autoload": { 1075 | "classmap": [ 1076 | "src/" 1077 | ] 1078 | }, 1079 | "notification-url": "https://packagist.org/downloads/", 1080 | "license": [ 1081 | "BSD-3-Clause" 1082 | ], 1083 | "authors": [ 1084 | { 1085 | "name": "Sebastian Bergmann", 1086 | "email": "sebastian@phpunit.de" 1087 | } 1088 | ], 1089 | "description": "Snapshotting of global state", 1090 | "homepage": "http://www.github.com/sebastianbergmann/global-state", 1091 | "keywords": [ 1092 | "global state" 1093 | ], 1094 | "time": "2014-10-06 09:23:50" 1095 | }, 1096 | { 1097 | "name": "sebastian/recursion-context", 1098 | "version": "1.0.1", 1099 | "source": { 1100 | "type": "git", 1101 | "url": "https://github.com/sebastianbergmann/recursion-context.git", 1102 | "reference": "994d4a811bafe801fb06dccbee797863ba2792ba" 1103 | }, 1104 | "dist": { 1105 | "type": "zip", 1106 | "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/994d4a811bafe801fb06dccbee797863ba2792ba", 1107 | "reference": "994d4a811bafe801fb06dccbee797863ba2792ba", 1108 | "shasum": "" 1109 | }, 1110 | "require": { 1111 | "php": ">=5.3.3" 1112 | }, 1113 | "require-dev": { 1114 | "phpunit/phpunit": "~4.4" 1115 | }, 1116 | "type": "library", 1117 | "extra": { 1118 | "branch-alias": { 1119 | "dev-master": "1.0.x-dev" 1120 | } 1121 | }, 1122 | "autoload": { 1123 | "classmap": [ 1124 | "src/" 1125 | ] 1126 | }, 1127 | "notification-url": "https://packagist.org/downloads/", 1128 | "license": [ 1129 | "BSD-3-Clause" 1130 | ], 1131 | "authors": [ 1132 | { 1133 | "name": "Jeff Welch", 1134 | "email": "whatthejeff@gmail.com" 1135 | }, 1136 | { 1137 | "name": "Sebastian Bergmann", 1138 | "email": "sebastian@phpunit.de" 1139 | }, 1140 | { 1141 | "name": "Adam Harvey", 1142 | "email": "aharvey@php.net" 1143 | } 1144 | ], 1145 | "description": "Provides functionality to recursively process PHP variables", 1146 | "homepage": "http://www.github.com/sebastianbergmann/recursion-context", 1147 | "time": "2015-06-21 08:04:50" 1148 | }, 1149 | { 1150 | "name": "sebastian/version", 1151 | "version": "1.0.6", 1152 | "source": { 1153 | "type": "git", 1154 | "url": "https://github.com/sebastianbergmann/version.git", 1155 | "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6" 1156 | }, 1157 | "dist": { 1158 | "type": "zip", 1159 | "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", 1160 | "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", 1161 | "shasum": "" 1162 | }, 1163 | "type": "library", 1164 | "autoload": { 1165 | "classmap": [ 1166 | "src/" 1167 | ] 1168 | }, 1169 | "notification-url": "https://packagist.org/downloads/", 1170 | "license": [ 1171 | "BSD-3-Clause" 1172 | ], 1173 | "authors": [ 1174 | { 1175 | "name": "Sebastian Bergmann", 1176 | "email": "sebastian@phpunit.de", 1177 | "role": "lead" 1178 | } 1179 | ], 1180 | "description": "Library that helps with managing the version number of Git-hosted PHP projects", 1181 | "homepage": "https://github.com/sebastianbergmann/version", 1182 | "time": "2015-06-21 13:59:46" 1183 | }, 1184 | { 1185 | "name": "symfony/var-dumper", 1186 | "version": "v2.7.2", 1187 | "source": { 1188 | "type": "git", 1189 | "url": "https://github.com/symfony/var-dumper.git", 1190 | "reference": "fde603d9f4b2418ff0f0315b93eb039c9aa41205" 1191 | }, 1192 | "dist": { 1193 | "type": "zip", 1194 | "url": "https://api.github.com/repos/symfony/var-dumper/zipball/fde603d9f4b2418ff0f0315b93eb039c9aa41205", 1195 | "reference": "fde603d9f4b2418ff0f0315b93eb039c9aa41205", 1196 | "shasum": "" 1197 | }, 1198 | "require": { 1199 | "php": ">=5.3.9" 1200 | }, 1201 | "require-dev": { 1202 | "symfony/phpunit-bridge": "~2.7" 1203 | }, 1204 | "suggest": { 1205 | "ext-symfony_debug": "" 1206 | }, 1207 | "type": "library", 1208 | "extra": { 1209 | "branch-alias": { 1210 | "dev-master": "2.7-dev" 1211 | } 1212 | }, 1213 | "autoload": { 1214 | "files": [ 1215 | "Resources/functions/dump.php" 1216 | ], 1217 | "psr-4": { 1218 | "Symfony\\Component\\VarDumper\\": "" 1219 | } 1220 | }, 1221 | "notification-url": "https://packagist.org/downloads/", 1222 | "license": [ 1223 | "MIT" 1224 | ], 1225 | "authors": [ 1226 | { 1227 | "name": "Nicolas Grekas", 1228 | "email": "p@tchwork.com" 1229 | }, 1230 | { 1231 | "name": "Symfony Community", 1232 | "homepage": "https://symfony.com/contributors" 1233 | } 1234 | ], 1235 | "description": "Symfony mechanism for exploring and dumping PHP variables", 1236 | "homepage": "https://symfony.com", 1237 | "keywords": [ 1238 | "debug", 1239 | "dump" 1240 | ], 1241 | "time": "2015-07-01 12:07:40" 1242 | }, 1243 | { 1244 | "name": "symfony/yaml", 1245 | "version": "v2.7.2", 1246 | "source": { 1247 | "type": "git", 1248 | "url": "https://github.com/symfony/Yaml.git", 1249 | "reference": "4bfbe0ed3909bfddd75b70c094391ec1f142f860" 1250 | }, 1251 | "dist": { 1252 | "type": "zip", 1253 | "url": "https://api.github.com/repos/symfony/Yaml/zipball/4bfbe0ed3909bfddd75b70c094391ec1f142f860", 1254 | "reference": "4bfbe0ed3909bfddd75b70c094391ec1f142f860", 1255 | "shasum": "" 1256 | }, 1257 | "require": { 1258 | "php": ">=5.3.9" 1259 | }, 1260 | "require-dev": { 1261 | "symfony/phpunit-bridge": "~2.7" 1262 | }, 1263 | "type": "library", 1264 | "extra": { 1265 | "branch-alias": { 1266 | "dev-master": "2.7-dev" 1267 | } 1268 | }, 1269 | "autoload": { 1270 | "psr-4": { 1271 | "Symfony\\Component\\Yaml\\": "" 1272 | } 1273 | }, 1274 | "notification-url": "https://packagist.org/downloads/", 1275 | "license": [ 1276 | "MIT" 1277 | ], 1278 | "authors": [ 1279 | { 1280 | "name": "Fabien Potencier", 1281 | "email": "fabien@symfony.com" 1282 | }, 1283 | { 1284 | "name": "Symfony Community", 1285 | "homepage": "https://symfony.com/contributors" 1286 | } 1287 | ], 1288 | "description": "Symfony Yaml Component", 1289 | "homepage": "https://symfony.com", 1290 | "time": "2015-07-01 11:25:50" 1291 | } 1292 | ], 1293 | "aliases": [], 1294 | "minimum-stability": "stable", 1295 | "stability-flags": [], 1296 | "prefer-stable": false, 1297 | "prefer-lowest": false, 1298 | "platform": { 1299 | "php": "^5.4" 1300 | }, 1301 | "platform-dev": { 1302 | "php": "^5.4", 1303 | "ext-xdebug": "^2.2" 1304 | } 1305 | } 1306 | -------------------------------------------------------------------------------- /phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | tests/Snipper 5 | 6 | 7 | 8 | 9 | src 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/Snipper/Client/ClientInterface.php: -------------------------------------------------------------------------------- 1 | client = new Client(new CachedHttpClient(['cache_dir' => $cacheDir])); 32 | $this->client->authenticate($token, Client::AUTH_HTTP_TOKEN); 33 | } 34 | 35 | /** 36 | * @inheritdoc 37 | * @codeCoverageIgnore 38 | */ 39 | public function getGists() 40 | { 41 | return $this->client->api('gists')->all('starred'); 42 | } 43 | 44 | /** 45 | * @inheritdoc 46 | * @codeCoverageIgnore 47 | */ 48 | public function getGist($id) 49 | { 50 | return $this->client->api('gists')->show($id); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/Snipper/Console/Command/Get.php: -------------------------------------------------------------------------------- 1 | setName('get') 25 | ->setDescription('Get snippet from GitHub Gist service') 26 | ->addArgument( 27 | 'name', 28 | InputArgument::REQUIRED, 29 | 'Snippet name (without hash sign)' 30 | ) 31 | ->addOption( 32 | 'force', 33 | 'f', 34 | InputOption::VALUE_NONE, 35 | 'Overwrite existing file' 36 | ); 37 | } 38 | 39 | /** 40 | * @inheritdoc 41 | * 42 | * @return OutputInterface 43 | */ 44 | protected function execute(InputInterface $in, OutputInterface $out) 45 | { 46 | $name = $in->getArgument('name'); 47 | $force = $in->getOption('force'); 48 | $gists = $this->client->getGists(); 49 | 50 | $found = array_filter($gists, function ($gist) use ($name) { 51 | $tag = '#' . $name; 52 | 53 | return strpos($gist['description'], $tag) !== false; 54 | }); 55 | 56 | $found = array_values($found); 57 | 58 | switch (count($found)) { 59 | case 0: 60 | return $out->writeLn('Snippet with the name \'' . $name . '\' was not found.'); 61 | case 1: 62 | $gist = $this->client->getGist($found[0]['id']); 63 | break; 64 | default: 65 | $choices = []; 66 | 67 | foreach ($gists as $gist) { 68 | $description = trim(str_replace('#' . $name, '', $gist['description'])); 69 | 70 | $choices[] = sprintf('%s - %s', $name, $description); 71 | } 72 | 73 | $index = $this->chooseByIndex( 74 | $in, $out, 75 | 'Snipper found duplicate snippets. Please select which to import:', 76 | $choices 77 | ); 78 | 79 | $gist = $this->client->getGist($found[$index]['id']); 80 | break; 81 | } 82 | 83 | return $this->saveSnippet($in, $out, $gist['files'], $force); 84 | } 85 | 86 | /** 87 | * Save named snippet in cwd 88 | * 89 | * @param InputInterface $in 90 | * @param OutputInterface $out 91 | * @param array $snippet 92 | * @param bool $force Force to overwrite files that already exists 93 | * 94 | * @return OutputInterface 95 | */ 96 | private function saveSnippet(InputInterface $in, OutputInterface $out, array $snippet, $force = false) 97 | { 98 | $cwd = getcwd(); 99 | $imported = []; 100 | $skipped = []; 101 | $overwritten = []; 102 | 103 | $filesize = function ($bytes, $dec = 2) { 104 | $size = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'); 105 | $factor = floor((strlen($bytes) - 1) / 3); 106 | 107 | return sprintf("%.{$dec}f", $bytes / pow(1024, $factor)) . $size[$factor]; 108 | }; 109 | 110 | foreach ($snippet as $filename => $data) { 111 | $filepath = $cwd . DIRECTORY_SEPARATOR . $filename; 112 | 113 | if (file_exists($filepath)) { 114 | $string = sprintf(' %s (%s -> %s)', $filename, $filesize(filesize($filepath)), $filesize($data['size'])); 115 | 116 | if (!$force) { 117 | $skipped[] = $string; 118 | 119 | continue; 120 | } 121 | 122 | $overwritten[] = $string; 123 | } else { 124 | $imported[] = sprintf(' %s (%s)', $filename, $filesize($data['size'])); 125 | } 126 | 127 | file_put_contents($filepath, $data['content']); 128 | } 129 | 130 | if (!empty($imported)) { 131 | $out->writeLn('New files:'); 132 | 133 | foreach ($imported as $string) { 134 | $out->writeLn($string); 135 | } 136 | } 137 | 138 | if (!empty($skipped)) { 139 | $out->writeLn('Skipped files, since they are already exist (use \'-f\' to overwrite files):'); 140 | 141 | foreach ($skipped as $string) { 142 | $out->writeLn($string); 143 | } 144 | } 145 | 146 | if (!empty($overwritten)) { 147 | $out->writeLn('Overwritten files:'); 148 | 149 | foreach ($overwritten as $string) { 150 | $out->writeLn($string); 151 | } 152 | } 153 | 154 | return $out->writeLn('Done.'); 155 | } 156 | } 157 | -------------------------------------------------------------------------------- /src/Snipper/Console/Command/Init.php: -------------------------------------------------------------------------------- 1 | setName('init') 23 | ->setDescription('Initialize Snipper'); 24 | } 25 | 26 | /** 27 | * @inheritdoc 28 | * 29 | * @throws \Exception 30 | * 31 | * @return void 32 | */ 33 | protected function execute(InputInterface $in, OutputInterface $out) 34 | { 35 | $path = OS_HOME_PATH . SNIPPER_CONFIG_FILE_PATH; 36 | 37 | if (!is_writable(OS_HOME_PATH)) { 38 | throw new \Exception('Unable to create default configuration due to permission restrictions - home directory must be writable.'); 39 | } 40 | 41 | if (!is_dir(dirname($path))) { 42 | mkdir(dirname($path)); 43 | } 44 | 45 | $question = new Question('Please enter personal access token for your GitHub account: '); 46 | $token = $this->getHelper('question')->ask($in, $out, $question); 47 | 48 | if (file_exists($path)) { 49 | $out->writeLn('Snipper already initialized. Writing new token...'); 50 | } 51 | 52 | file_put_contents($path, json_encode(['token' => $token], JSON_PRETTY_PRINT)); 53 | 54 | $out->writeLn('Done.'); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/Snipper/Console/Command/SnipperCommand.php: -------------------------------------------------------------------------------- 1 | client = $client; 30 | } 31 | 32 | /** 33 | * Ask user to choose from list of available variants and return selected 34 | * index 35 | * 36 | * @param InputInterface $in 37 | * @param OutputInterface $out 38 | * @param string $question 39 | * @param array $choices 40 | * 41 | * @return mixed 42 | */ 43 | protected function chooseByIndex(InputInterface $in, OutputInterface $out, $question, array $choices) 44 | { 45 | $padding = strlen(count($choices)) - 1; 46 | 47 | $out->writeLn($question); 48 | 49 | for ($i = 0; $i < count($choices); $i++) { 50 | $out->writeLn(sprintf(' [%d] %s', str_pad($i, $padding, ' ', STR_PAD_LEFT), $choices[$i])); 51 | } 52 | 53 | $questionResolver = new Question(' > '); 54 | 55 | // @codeCoverageIgnoreStart 56 | $questionResolver->setValidator(function ($answer) use ($choices) { 57 | $answer = (int) $answer; 58 | 59 | if (!array_key_exists($answer, $choices)) { 60 | throw new \RuntimeException( 61 | 'There is no such option as \'' . $answer . '\'.' 62 | ); 63 | } 64 | 65 | return $answer; 66 | }); 67 | // @codeCoverageIgnoreEnd 68 | 69 | $questionResolver->setMaxAttempts(3); 70 | 71 | return $this->getHelper('question')->ask($in, $out, $questionResolver); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/Snipper/Console/SnipperApplication.php: -------------------------------------------------------------------------------- 1 | getConfig(); 29 | 30 | if (empty($this->config['token'])) { 31 | throw new \Exception('GitHub personal access token is required for application to work. Please run \'snipper init \' to add one.'); 32 | } 33 | 34 | $client = new KnplabsClient($this->config['token']); 35 | 36 | $this 37 | ->addCommands([ 38 | new Command\Init, 39 | new Command\Get($client), 40 | ]); 41 | } 42 | 43 | /** 44 | * Get configuration values from Snipper config file in home dir 45 | * 46 | * @throws \Exception 47 | * 48 | * @return array 49 | */ 50 | protected function getConfig() 51 | { 52 | // @codeCoverageIgnoreStart 53 | if (!is_null($this->config)) { 54 | return $this->config; 55 | } 56 | // @codeCoverageIgnoreEnd 57 | 58 | if (!file_exists(OS_HOME_PATH . SNIPPER_CONFIG_FILE_PATH)) { 59 | throw new \Exception('Configuration file not found. Is Snipper initialized?'); 60 | } 61 | 62 | $config = json_decode(file_get_contents(OS_HOME_PATH . SNIPPER_CONFIG_FILE_PATH), true); 63 | 64 | if (JSON_ERROR_NONE !== json_last_error()) { 65 | throw new \Exception('Unable to parse configuration file: ' . json_last_error_msg() . '.'); 66 | } 67 | 68 | return $this->config = $config; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /tests/.config/snipper.empty.json: -------------------------------------------------------------------------------- 1 | { 2 | "token": "" 3 | } 4 | -------------------------------------------------------------------------------- /tests/.config/snipper.json: -------------------------------------------------------------------------------- 1 | { 2 | "token": "token" 3 | } 4 | -------------------------------------------------------------------------------- /tests/.config/snipper.wrong.json: -------------------------------------------------------------------------------- 1 | { 2 | test: "token" 3 | } 4 | -------------------------------------------------------------------------------- /tests/Snipper/Console/Command/GetTest.php: -------------------------------------------------------------------------------- 1 | testDir); 14 | chdir($this->testDir); 15 | } 16 | 17 | public function tearDown() { 18 | parent::tearDown(); 19 | 20 | if (is_dir($this->testDir)) { 21 | $files = array_diff(scandir($this->testDir), array('..', '.')); 22 | 23 | if (!empty($files)) { 24 | foreach ($files as $file) { 25 | unlink($this->testDir . DIRECTORY_SEPARATOR . $file); 26 | } 27 | } 28 | 29 | rmdir($this->testDir); 30 | } 31 | } 32 | 33 | public function testGetSnippetNotFound() 34 | { 35 | $tester = $this->getCommandTester(new Get($this->getClientMock()), 'get', [ 36 | 'name' => 'notfound', 37 | ]); 38 | 39 | $this->assertRegExp('/not found/', $tester->getDisplay()); 40 | } 41 | 42 | public function testGetFindAndSaveSnippet() 43 | { 44 | $tester = $this->getCommandTester(new Get($this->getClientMock()), 'get', [ 45 | 'name' => 'snippet', 46 | ]); 47 | 48 | $this->assertRegExp('/New files.*test/s', $tester->getDisplay()); 49 | $this->assertFileExists($this->testDir . DIRECTORY_SEPARATOR . 'test'); 50 | } 51 | 52 | public function testGetNotOverwriteSnippet() 53 | { 54 | $client = $this->getClientMock(); 55 | 56 | $this->getCommandTester(new Get($client), 'get', [ 57 | 'name' => 'snippet', 58 | ]); 59 | 60 | $tester = $this->getCommandTester(new Get($client), 'get', [ 61 | 'name' => 'anothersnippet', 62 | ]); 63 | 64 | $this->assertRegExp('/Skipped files.*test/s', $tester->getDisplay()); 65 | $this->assertFileExists($this->testDir . DIRECTORY_SEPARATOR . 'test'); 66 | $this->assertStringEqualsFile($this->testDir . DIRECTORY_SEPARATOR . 'test', 'Test snippet'); 67 | } 68 | 69 | public function testGetOverwriteSnippet() 70 | { 71 | $client = $this->getClientMock(); 72 | 73 | $this->getCommandTester(new Get($client), 'get', [ 74 | 'name' => 'snippet', 75 | ]); 76 | 77 | $tester = $this->getCommandTester(new Get($client), 'get', [ 78 | 'name' => 'anothersnippet', 79 | '-f' => true, 80 | ]); 81 | 82 | $this->assertRegExp('/Overwritten files.*test/s', $tester->getDisplay()); 83 | $this->assertFileExists($this->testDir . DIRECTORY_SEPARATOR . 'test'); 84 | $this->assertStringEqualsFile($this->testDir . DIRECTORY_SEPARATOR . 'test', 'Another test'); 85 | } 86 | 87 | public function testGetAskAboutDuplicates() 88 | { 89 | $questionHelperMock = $this->getMock( 90 | '\Symfony\Component\Console\Helper\QuestionHelper', 91 | ['ask'] 92 | ); 93 | 94 | $questionHelperMock 95 | ->method('ask') 96 | ->willReturn(1); 97 | 98 | $tester = $this->getCommandTester(new Get($this->getClientMock()), 'get', [ 99 | 'name' => 'duplicate' 100 | ], [ 101 | 'question' => $questionHelperMock, 102 | ]); 103 | 104 | $this->assertRegExp('/New files.*test/s', $tester->getDisplay()); 105 | $this->assertFileExists($this->testDir . DIRECTORY_SEPARATOR . 'test'); 106 | $this->assertStringEqualsFile($this->testDir . DIRECTORY_SEPARATOR . 'test', 'Second duplicate'); 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /tests/Snipper/Console/Command/InitTest.php: -------------------------------------------------------------------------------- 1 | getCommandTester(new Init, 'init'); 32 | } 33 | 34 | /** 35 | * @runInSeparateProcess 36 | */ 37 | public function testInitCreatesSnipperHomeDirectory() 38 | { 39 | $this->setDefaultPaths(); 40 | 41 | $tester = $this->getCommandTester(new Init, 'init', [], [ 42 | 'question' => $this->getQuestionHelperMockForTokenAsk('token'), 43 | ]); 44 | 45 | $this->assertRegExp('/Done/', $tester->getDisplay()); 46 | $this->assertFileExists(OS_HOME_PATH . SNIPPER_CONFIG_FILE_PATH); 47 | $this->assertStringEqualsFile(OS_HOME_PATH . SNIPPER_CONFIG_FILE_PATH, json_encode(['token' => 'token'], JSON_PRETTY_PRINT)); 48 | } 49 | 50 | /** 51 | * @runInSeparateProcess 52 | */ 53 | public function testInitReplaceTokenIfInitialized() 54 | { 55 | $this->setDefaultPaths(); 56 | 57 | $this->getCommandTester(new Init, 'init', [], [ 58 | 'question' => $this->getQuestionHelperMockForTokenAsk('token'), 59 | ]); 60 | 61 | $tester = $this->getCommandTester(new Init, 'init', [], [ 62 | 'question' => $this->getQuestionHelperMockForTokenAsk('newtoken'), 63 | ]); 64 | 65 | $this->assertRegExp('/Snipper already initialized/', $tester->getDisplay()); 66 | $this->assertStringEqualsFile(OS_HOME_PATH . SNIPPER_CONFIG_FILE_PATH, json_encode(['token' => 'newtoken'], JSON_PRETTY_PRINT)); 67 | } 68 | 69 | private function setDefaultPaths() 70 | { 71 | define('OS_HOME_PATH', __DIR__); 72 | define('SNIPPER_CONFIG_FILE_PATH', DIRECTORY_SEPARATOR . '.snipper' . DIRECTORY_SEPARATOR . 'snipper.json'); 73 | } 74 | 75 | private function getQuestionHelperMockForTokenAsk($token) 76 | { 77 | $questionHelperMock = $this->getMock( 78 | '\Symfony\Component\Console\Helper\QuestionHelper', 79 | ['ask'] 80 | ); 81 | 82 | $questionHelperMock 83 | ->method('ask') 84 | ->willReturn($token); 85 | 86 | return $questionHelperMock; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /tests/Snipper/Console/Command/TestCase.php: -------------------------------------------------------------------------------- 1 | add($command); 16 | 17 | $testedCommand = $application->get($name); 18 | 19 | if (!empty($helpers)) { 20 | foreach ($helpers as $helperName => $helperMock) { 21 | $testedCommand->getHelperSet()->set($helperMock, $helperName); 22 | } 23 | } 24 | 25 | $tester = new CommandTester($testedCommand); 26 | 27 | $tester->execute(array_merge(['command' => $command->getName(),], $params)); 28 | 29 | return $tester; 30 | } 31 | 32 | protected function getClientMock() 33 | { 34 | $client = new ClientMock(''); 35 | $client->setGists([ 36 | [ 37 | 'id' => 0, 38 | 'description' => '#snippet', 39 | 'files' => [ 40 | 'test' => [ 41 | 'size' => 123, 42 | 'content' => 'Test snippet', 43 | ], 44 | ], 45 | ], 46 | [ 47 | 'id' => 1, 48 | 'description' => '#anothersnippet', 49 | 'files' => [ 50 | 'test' => [ 51 | 'size' => 321, 52 | 'content' => 'Another test', 53 | ], 54 | ], 55 | ], 56 | [ 57 | 'id' => 2, 58 | 'description' => '#duplicate', 59 | 'files' => [ 60 | 'test' => [ 61 | 'size' => 123, 62 | 'content' => 'First duplicate', 63 | ], 64 | ], 65 | ], 66 | [ 67 | 'id' => 3, 68 | 'description' => '#duplicate', 69 | 'files' => [ 70 | 'test' => [ 71 | 'size' => 321, 72 | 'content' => 'Second duplicate', 73 | ], 74 | ], 75 | ], 76 | ]); 77 | 78 | return $client; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /tests/Snipper/Console/SnipperApplicationTest.php: -------------------------------------------------------------------------------- 1 | setDefaultPaths(); 13 | 14 | $snipper = new SnipperApplication; 15 | } 16 | 17 | /** 18 | * @runInSeparateProcess 19 | */ 20 | public function testApplicationHasRightName() 21 | { 22 | $this->setDefaultPaths(); 23 | 24 | $snipper = new SnipperApplication; 25 | 26 | $this->assertEquals('Snipper', $snipper->getName()); 27 | } 28 | 29 | /** 30 | * @runInSeparateProcess 31 | */ 32 | public function testApplicationHasRightVersion() 33 | { 34 | $this->setDefaultPaths(); 35 | 36 | $snipper = new SnipperApplication; 37 | 38 | $this->assertEquals('0.1.4', $snipper->getVersion()); 39 | } 40 | 41 | /** 42 | * @runInSeparateProcess 43 | */ 44 | public function testApplicationHasInitCommand() 45 | { 46 | $this->setDefaultPaths(); 47 | 48 | $snipper = new SnipperApplication; 49 | 50 | $this->assertTrue($snipper->has('init')); 51 | $this->assertInstanceOf('\Snipper\Console\Command\Init', $snipper->get('init')); 52 | } 53 | 54 | /** 55 | * @runInSeparateProcess 56 | */ 57 | public function testApplicationHasGetCommand() 58 | { 59 | $this->setDefaultPaths(); 60 | 61 | $snipper = new SnipperApplication; 62 | 63 | $this->assertTrue($snipper->has('get')); 64 | $this->assertInstanceOf('\Snipper\Console\Command\Get', $snipper->get('get')); 65 | } 66 | 67 | /** 68 | * @runInSeparateProcess 69 | * @expectedException \Exception 70 | * @expectedExceptionMessageRegExp /file not found/ 71 | */ 72 | public function testApplicationThrowsConfigNotFound() 73 | { 74 | define('OS_HOME_PATH', __DIR__ . implode(DIRECTORY_SEPARATOR, ['' ,'..', '..'])); 75 | define('SNIPPER_CONFIG_FILE_PATH', implode(DIRECTORY_SEPARATOR, ['', '.config', 'snipper.missed'])); 76 | 77 | $snipper = new SnipperApplication; 78 | } 79 | 80 | /** 81 | * @runInSeparateProcess 82 | * @expectedException \Exception 83 | * @expectedExceptionMessageRegExp /^Unable to parse/ 84 | */ 85 | public function testApplicationThrowsConfigWrongFormat() 86 | { 87 | define('OS_HOME_PATH', __DIR__ . implode(DIRECTORY_SEPARATOR, ['' ,'..', '..'])); 88 | define('SNIPPER_CONFIG_FILE_PATH', implode(DIRECTORY_SEPARATOR, ['', '.config', 'snipper.wrong.json'])); 89 | 90 | $snipper = new SnipperApplication; 91 | } 92 | 93 | /** 94 | * @runInSeparateProcess 95 | * @expectedException \Exception 96 | * @expectedExceptionMessageRegExp /personal access token is required/ 97 | */ 98 | public function testApplicationThrowsConfigNoToken() 99 | { 100 | define('OS_HOME_PATH', __DIR__ . implode(DIRECTORY_SEPARATOR, ['' ,'..', '..'])); 101 | define('SNIPPER_CONFIG_FILE_PATH', implode(DIRECTORY_SEPARATOR, ['', '.config', 'snipper.empty.json'])); 102 | 103 | $snipper = new SnipperApplication; 104 | } 105 | 106 | private function setDefaultPaths() 107 | { 108 | define('OS_HOME_PATH', __DIR__ . implode(DIRECTORY_SEPARATOR, ['' ,'..', '..'])); 109 | define('SNIPPER_CONFIG_FILE_PATH', implode(DIRECTORY_SEPARATOR, ['', '.config', 'snipper.json'])); 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /tests/Snipper/Mocks/ClientMock.php: -------------------------------------------------------------------------------- 1 | gists; 17 | } 18 | 19 | public function getGist($id) 20 | { 21 | return (isset($this->gists[$id])) ? $this->gists[$id] : []; 22 | } 23 | 24 | public function setGists(array $gists) 25 | { 26 | $this->gists = $gists; 27 | 28 | return $this; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /tests/bootstrap.php: -------------------------------------------------------------------------------- 1 |