Skip to content

Commit 0cfcafb

Browse files
committed
Change Code Style to fit PSR-2
1 parent 907f509 commit 0cfcafb

File tree

86 files changed

+7885
-7929
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+7885
-7929
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
.idea
2+
.php_cs.cache
23
composer.phar
34
composer.lock
5+
php-cs-fixer.phar
46
vendor

.php_cs.dist

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()
4+
->in('src')
5+
->in('tests')
6+
;
7+
8+
return PhpCsFixer\Config::create()
9+
->setRules([
10+
'@PSR2' => true,
11+
'array_syntax' => [
12+
'syntax' => 'short',
13+
],
14+
'blank_line_after_opening_tag' => true,
15+
'blank_line_before_statement' => [
16+
'statements' => [
17+
'break',
18+
'continue',
19+
'declare',
20+
'return',
21+
'throw',
22+
'try',
23+
],
24+
],
25+
'concat_space' => [
26+
'spacing' => 'one',
27+
],
28+
'general_phpdoc_annotation_remove' => [
29+
'package',
30+
],
31+
'linebreak_after_opening_tag' => true,
32+
'method_separation' => true,
33+
'phpdoc_add_missing_param_annotation' => true,
34+
'phpdoc_align' => true,
35+
'phpdoc_annotation_without_dot' => true,
36+
'phpdoc_indent' => true,
37+
'phpdoc_no_alias_tag' => true,
38+
'phpdoc_no_empty_return' => true,
39+
'phpdoc_order' => true,
40+
'phpdoc_scalar' => true,
41+
'phpdoc_separation' => true,
42+
'phpdoc_single_line_var_spacing' => true,
43+
'phpdoc_to_comment' => true,
44+
'phpdoc_trim' => true,
45+
'phpdoc_types' => true,
46+
'phpdoc_var_without_name' => true,
47+
'no_blank_lines_after_class_opening' => true,
48+
//'simplified_null_return' => true,
49+
//'psr4' => true,
50+
'single_quote' => true,
51+
])
52+
->setFinder($finder)
53+
;

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
# Changelog
22

33
All notable changes to this project will be documented in this file.
4-
This project adheres to [Semantic Versioning](http://semver.org/).
4+
5+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
6+
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
57

68
## [Unreleased]
79

810
### Changed
911

12+
- Change Code Style to PSR-2
1013
- Support for PHP 5.5 dropped, PHP >=5.6 is now required
1114
- Tests in Travis for PHP 7.2 and nightly added
1215

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ $ phpunit
9696

9797
## Contributing
9898

99-
Please feel free to fork and sending Pull Requests. This project follows [Semantic Versioning 2](http://semver.org).
99+
Please feel free to fork and sending Pull Requests. This project follows [Semantic Versioning 2](http://semver.org) and [PSR-2](http://www.php-fig.org/psr/psr-2/).
100100

101101
## Credits
102102

src/AccessInterface.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
*/
2525
interface AccessInterface
2626
{
27-
public function get($key);
27+
public function get($key);
2828

29-
public function has($key);
29+
public function has($key);
3030

31-
public function getKeys();
31+
public function getKeys();
3232

33-
public function asArray();
33+
public function asArray();
3434
}

src/Attributes.php

Lines changed: 61 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -32,82 +32,76 @@
3232
*/
3333
final class Attributes implements AttributesInterface
3434
{
35-
use AccessTrait;
35+
use AccessTrait;
3636

37-
/**
38-
* @var DataContainerInterface
39-
*/
40-
protected $container;
37+
/**
38+
* @var DataContainerInterface
39+
*/
40+
protected $container;
4141

42-
/**
43-
* @var FactoryManagerInterface
44-
*/
45-
protected $manager;
42+
/**
43+
* @var FactoryManagerInterface
44+
*/
45+
protected $manager;
4646

47-
/**
48-
* Sets the manager and parent
49-
*
50-
* @param FactoryManagerInterface $manager The manager
51-
* @param AccessInterface $parent The parent
52-
*/
53-
public function __construct(FactoryManagerInterface $manager, AccessInterface $parent = null)
54-
{
55-
$this->manager = $manager;
47+
/**
48+
* Sets the manager and parent
49+
*
50+
* @param FactoryManagerInterface $manager The manager
51+
* @param AccessInterface $parent The parent
52+
*/
53+
public function __construct(FactoryManagerInterface $manager, AccessInterface $parent = null)
54+
{
55+
$this->manager = $manager;
5656

57-
$this->container = new DataContainer();
58-
}
57+
$this->container = new DataContainer();
58+
}
5959

60-
/**
61-
* Parses the data for this element
62-
*
63-
* @param mixed $object The data
64-
*
65-
* @return self
66-
*
67-
* @throws ValidationException
68-
*/
69-
public function parse($object)
70-
{
71-
if ( ! is_object($object) )
72-
{
73-
throw new ValidationException('Attributes has to be an object, "' . gettype($object) . '" given.');
74-
}
60+
/**
61+
* Parses the data for this element
62+
*
63+
* @param mixed $object The data
64+
*
65+
* @throws ValidationException
66+
*
67+
* @return self
68+
*/
69+
public function parse($object)
70+
{
71+
if (! is_object($object)) {
72+
throw new ValidationException('Attributes has to be an object, "' . gettype($object) . '" given.');
73+
}
7574

76-
if ( property_exists($object, 'type') or property_exists($object, 'id') or property_exists($object, 'relationships') or property_exists($object, 'links') )
77-
{
78-
throw new ValidationException('These properties are not allowed in attributes: `type`, `id`, `relationships`, `links`');
79-
}
75+
if (property_exists($object, 'type') or property_exists($object, 'id') or property_exists($object, 'relationships') or property_exists($object, 'links')) {
76+
throw new ValidationException('These properties are not allowed in attributes: `type`, `id`, `relationships`, `links`');
77+
}
8078

81-
$object_vars = get_object_vars($object);
79+
$object_vars = get_object_vars($object);
8280

83-
if ( count($object_vars) === 0 )
84-
{
85-
return $this;
86-
}
81+
if (count($object_vars) === 0) {
82+
return $this;
83+
}
8784

88-
foreach ($object_vars as $name => $value)
89-
{
90-
$this->container->set($name, $value);
91-
}
85+
foreach ($object_vars as $name => $value) {
86+
$this->container->set($name, $value);
87+
}
9288

93-
return $this;
94-
}
89+
return $this;
90+
}
9591

96-
/**
97-
* Get a value by the key of this object
98-
*
99-
* @param string $key The key of the value
100-
* @return mixed The value
101-
*/
102-
public function get($key)
103-
{
104-
try
105-
{
106-
return $this->container->get($key);
107-
}
108-
catch (AccessException $e)
109-
{
110-
throw new AccessException('"' . $key . '" doesn\'t exist in this object.');
111-
}
112-
}
92+
/**
93+
* Get a value by the key of this object
94+
*
95+
* @param string $key The key of the value
96+
*
97+
* @return mixed The value
98+
*/
99+
public function get($key)
100+
{
101+
try {
102+
return $this->container->get($key);
103+
} catch (AccessException $e) {
104+
throw new AccessException('"' . $key . '" doesn\'t exist in this object.');
105+
}
106+
}
113107
}

src/AttributesInterface.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,6 @@
2222
/**
2323
* Attributes Interface
2424
*/
25-
interface AttributesInterface extends ElementInterface { }
25+
interface AttributesInterface extends ElementInterface
26+
{
27+
}

0 commit comments

Comments
 (0)