{"id":19144393,"url":"https://github.com/piotrpress/accessor","last_synced_at":"2026-06-11T07:30:16.283Z","repository":{"id":57041812,"uuid":"332479655","full_name":"PiotrPress/accessor","owner":"PiotrPress","description":"This library provides an access to protected/private, also static, methods/properties of an object/class.","archived":false,"fork":false,"pushed_at":"2021-01-24T16:00:25.000Z","size":13,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-03T15:49:17.997Z","etag":null,"topics":["access","accessor","call","caller","invoke","invoker","non-public-method","non-public-property","private","private-method","private-property","protected","protected-method","protected-property","static-private-method","static-private-property","static-protected-method","static-protected-property"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PiotrPress.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-01-24T15:09:28.000Z","updated_at":"2021-01-24T16:14:39.000Z","dependencies_parsed_at":"2022-08-24T02:50:43.144Z","dependency_job_id":null,"html_url":"https://github.com/PiotrPress/accessor","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PiotrPress%2Faccessor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PiotrPress%2Faccessor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PiotrPress%2Faccessor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PiotrPress%2Faccessor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PiotrPress","download_url":"https://codeload.github.com/PiotrPress/accessor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240225245,"owners_count":19767885,"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":["access","accessor","call","caller","invoke","invoker","non-public-method","non-public-property","private","private-method","private-property","protected","protected-method","protected-property","static-private-method","static-private-property","static-protected-method","static-protected-property"],"created_at":"2024-11-09T07:34:44.329Z","updated_at":"2026-06-11T07:30:15.658Z","avatar_url":"https://github.com/PiotrPress.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Accessor\n\nThis library provides an access to protected/private, also static, methods/properties of an object/class.\n\n## Installation\n\n```console\ncomposer require piotrpress/accessor\n```\n\n## Usage\n\n### Example class\n\n```php\nclass Example {\n    private $privateProperty = 'privateProperty';\n    protected $protectedProperty = 'protectedProperty';\n    static private $staticPrivateProperty = 'staticPrivateProperty';\n    static protected $staticProtectedProperty = 'staticProtectedProperty';\n    \n    private function privateMethod( $arg1, $arg2 ) { echo $arg1 . $arg2; }\n    protected function protectedMethod( $arg1, $arg2 ) { echo $arg1 . $arg2; }\n    static private function staticPrivateMethod( $arg1, $arg2 ) { echo $arg1 . $arg2; }\n    static protected function staticProtectedMethod( $arg1, $arg2 ) { echo $arg1 . $arg2; }\n}\n```\n\n### Including library\n\n```php\nrequire __DIR__ . '/vendor/autoload.php';\n\nuse PiotrPress\\Accessor;\n```\n\n### Calling methods\n\n```php\n$accessor = new Accessor( new Example() );\n\n$accessor-\u003eprivateMethod( 'arg1', 'arg2' );\n$accessor-\u003eprotectedMethod( 'arg1', 'arg2' );\n```\n\n### Calling static methods\n\n```php\n$accessor = new Accessor( 'Example' );\n\n$accessor-\u003estaticPrivateMethod( 'arg1', 'arg2' );\n$accessor-\u003estaticProtectedMethod( 'arg1', 'arg2' );\n```\n\n### Getting properties\n\n```php\n$accessor = new Accessor( new Example() );\n\necho $accessor-\u003eprivateProperty;\necho $accessor-\u003eprotectedProperty;\n```\n\n### Getting static properties\n\n```php\n$accessor = new Accessor( 'Example' );\n\necho $accessor-\u003estaticPrivateProperty;\necho $accessor-\u003estaticProtectedProperty;\n```\n\n### Setting properties\n\n```php\n$accessor = new Accessor( new Example() );\n\n$accessor-\u003eprivateProperty = 'newPrivateProperty';\n$accessor-\u003eprotectedProperty = 'newProtectedProperty';\n```\n\n### Setting static properties\n\n```php\n$accessor = new Accessor( 'Example' );\n\n$accessor-\u003estaticPrivateProperty = 'newStaticPrivateProperty';\n$accessor-\u003estaticProtectedProperty = 'newStaticProtectedProperty';\n```\n\n## License\n\nGPL3.0","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpiotrpress%2Faccessor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpiotrpress%2Faccessor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpiotrpress%2Faccessor/lists"}