{"id":13828097,"url":"https://github.com/icewind1991/interceptor","last_synced_at":"2025-03-19T16:31:25.692Z","repository":{"id":47114624,"uuid":"43209889","full_name":"icewind1991/interceptor","owner":"icewind1991","description":"Intercept php includes","archived":false,"fork":false,"pushed_at":"2019-12-23T11:01:48.000Z","size":168,"stargazers_count":16,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-17T09:06:18.348Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/icewind1991.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-09-26T15:06:06.000Z","updated_at":"2021-02-02T17:21:08.000Z","dependencies_parsed_at":"2022-07-20T15:18:05.772Z","dependency_job_id":null,"html_url":"https://github.com/icewind1991/interceptor","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icewind1991%2Finterceptor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icewind1991%2Finterceptor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icewind1991%2Finterceptor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icewind1991%2Finterceptor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/icewind1991","download_url":"https://codeload.github.com/icewind1991/interceptor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244463768,"owners_count":20456943,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T09:02:32.192Z","updated_at":"2025-03-19T16:31:25.373Z","avatar_url":"https://github.com/icewind1991.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"# Interceptor\n\n[![Build Status](https://travis-ci.org/icewind1991/interceptor.svg?branch=master)](https://travis-ci.org/icewind1991/interceptor)\n[![Code Coverage](https://scrutinizer-ci.com/g/icewind1991/interceptor/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/icewind1991/interceptor/?branch=master)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/icewind1991/interceptor/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/icewind1991/interceptor/?branch=master)\n\nIntercept php includes\n\n```\ncomposer require icewind/interceptor\n```\n\n## Usage\n\n```php\nuse Icewind\\Interceptor\\Interceptor;\n\n$interceptor = new Interceptor();\n$interceptor-\u003eaddWhiteList(__DIR__ . '/src');\n$interceptor-\u003eaddHook(function($code) {\n    return str_replace('foo', 'bar', $code);\n});\n\n$interceptor-\u003esetUp();\n\nrequire 'src/foo.php'\n```\n\n## API\n\n- `addWhiteList(string $path)`: Add a folder to the white list\n- `addBlackList(string $path)`: Add a folder to the black list\n - Only white listed files will be intercepted\n - A file is white listed if it has a parent folder that is white listed\n without there being a more direct parent folder that is black listed\n- `addHook(callable $hook)`: Register a hook to the intercepter\n - the registered callback will be called for every include which is intercepted\n - The code being included will be passed as the first argument\n - The path being included will be passed as second argument\n - If the hook returns a string the loaded code will be replaced by the return value\n- `setUp()` start intercepting includes\n- `tearDown()` stop intercepting includes\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ficewind1991%2Finterceptor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ficewind1991%2Finterceptor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ficewind1991%2Finterceptor/lists"}