| Conditions | 2 |
| Paths | 1 |
| Total Lines | 56 |
| Code Lines | 48 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 51 | protected function getSecurityCheckerMock($empty = false) |
||
| 52 | { |
||
| 53 | // Mock info comes from SensioLabs API docs example output, |
||
| 54 | // and a real (test) silverstripe/installer 3.2.0 installation |
||
| 55 | // (using the aforementioned API) |
||
| 56 | $mockOutput = <<<CVENOTICE |
||
| 57 | { |
||
| 58 | "symfony\/symfony": { |
||
| 59 | "version": "2.1.x-dev", |
||
| 60 | "advisories": { |
||
| 61 | "symfony\/symfony\/CVE-2013-1397.yaml": { |
||
| 62 | "title": "Ability to enable\/disable object support in YAML parsing and dumping", |
||
| 63 | "link": "http:\/\/symfony.com\/blog\/security-release-symfony-2-0-22-and-2-1-7-released", |
||
| 64 | "cve": "CVE-2013-1397" |
||
| 65 | } |
||
| 66 | } |
||
| 67 | }, |
||
| 68 | "silverstripe\/framework": { |
||
| 69 | "version": "3.2.0", |
||
| 70 | "advisories": { |
||
| 71 | "silverstripe\/framework\/SS-2016-002-1.yaml": { |
||
| 72 | "title": "SS-2016-002: CSRF vulnerability in GridFieldAddExistingAutocompleter", |
||
| 73 | "link": "https:\/\/www.silverstripe.org\/download\/security-releases\/ss-2016-002\/", |
||
| 74 | "cve": "" |
||
| 75 | }, |
||
| 76 | "silverstripe\/framework\/SS-2016-003-1.yaml": { |
||
| 77 | "title": "SS-2016-003: Hostname, IP and Protocol Spoofing through HTTP Headers", |
||
| 78 | "link": "https:\/\/www.silverstripe.org\/download\/security-releases\/ss-2016-003\/", |
||
| 79 | "cve": "" |
||
| 80 | }, |
||
| 81 | "silverstripe\/framework\/SS-2015-028-1.yaml": { |
||
| 82 | "title": "SS-2015-028: Missing security check on dev\/build\/defaults", |
||
| 83 | "link": "https:\/\/www.silverstripe.org\/download\/security-releases\/ss-2015-028\/", |
||
| 84 | "cve": "" |
||
| 85 | }, |
||
| 86 | "silverstripe\/framework\/SS-2015-027-1.yaml": { |
||
| 87 | "title": "SS-2015-027: HtmlEditor embed url sanitisation", |
||
| 88 | "link": "https:\/\/www.silverstripe.org\/download\/security-releases\/ss-2015-027\/", |
||
| 89 | "cve": "" |
||
| 90 | }, |
||
| 91 | "silverstripe\/framework\/SS-2015-026-1.yaml": { |
||
| 92 | "title": "SS-2015-026: Form field validation message XSS vulnerability", |
||
| 93 | "link": "https:\/\/www.silverstripe.org\/download\/security-releases\/ss-2015-026\/", |
||
| 94 | "cve": "" |
||
| 95 | } |
||
| 96 | } |
||
| 97 | } |
||
| 98 | } |
||
| 99 | CVENOTICE; |
||
| 100 | |||
| 101 | $securityCheckerMock = $this->getMockBuilder(SecurityChecker::class)->setMethods(['check'])->getMock(); |
||
| 102 | $securityCheckerMock->expects($this->any())->method('check')->will($this->returnValue( |
||
| 103 | $empty ? new Result(0, '{}', 'json') : new Result(6, $mockOutput, 'json') |
||
| 104 | )); |
||
| 105 | |||
| 106 | return $securityCheckerMock; |
||
| 107 | } |
||
| 159 |