Skip to content

Commit

Permalink
fix code style with PHp CS fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
Axel VENET committed Feb 2, 2017
1 parent 085041c commit 80f4be6
Show file tree
Hide file tree
Showing 47 changed files with 934 additions and 730 deletions.
16 changes: 8 additions & 8 deletions example.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require_once('vendor/autoload.php');

use PhpAbac\Abac;

$countries = include('tests/fixtures/countries.php');
$visas = include('tests/fixtures/visas.php');
$users = include('tests/fixtures/users.php');
Expand Down Expand Up @@ -35,31 +35,31 @@
$user1Vehicle = $abac->enforce('vehicle-homologation', $users[0], $vehicles[0], [
'dynamic_attributes' => ['proprietaire' => 1]
]);
if($user1Vehicle === true) {
if ($user1Vehicle === true) {
echo("GRANTED : The vehicle 1 is able to be approved for the user 1\n");
} else {
echo("FAIL : The system didn't grant access\n");
}
$user3Vehicle = $abac->enforce('vehicle-homologation', $users[2], $vehicles[1], [
'dynamic_attributes' => ['proprietaire' => 3]
]);
if(!$user3Vehicle !== true) {
if (!$user3Vehicle !== true) {
echo("DENIED : The vehicle 2 is not approved for the user 3 because its last technical review is too old\n");
} else {
echo("FAIL : The system didn't deny access\n");
}
$user4Vehicle = $abac->enforce('vehicle-homologation', $users[3], $vehicles[3], [
'dynamic_attributes' => ['proprietaire' => 4]
]);
if($user4Vehicle !== true) {
if ($user4Vehicle !== true) {
echo("DENIED : The vehicle 4 is not able to be approved for the user 4 because he has no driving license\n");
} else {
echo("FAIL : The system didn't deny access\n");
}
$user5Vehicle = $abac->enforce('vehicle-homologation', $users[3], $vehicles[3], [
'dynamic_attributes' => ['proprietaire' => 1]
]);
if($user5Vehicle !== true) {
if ($user5Vehicle !== true) {
echo("DENIED : The vehicle 4 is not able to be approved for the user 2 because he doesn't own the vehicle\n");
} else {
echo("FAIL : The system didn't deny access\n");
Expand All @@ -69,7 +69,7 @@
'code-pays' => 'US'
]
]);
if($userTravel1 !== true) {
if ($userTravel1 !== true) {
echo("DENIED: The user 1 is not allowed to travel to the USA because he doesn't have an US visa\n");
} else {
echo('FAIL: The system didn\'t deny access');
Expand All @@ -79,8 +79,8 @@
'code-pays' => 'US'
]
]);
if($userTravel2 === true) {
if ($userTravel2 === true) {
echo("GRANTED: The user 2 is allowed to travel to the USA\n");
} else {
echo('FAIL: The system didn\'t grant access');
}
}
17 changes: 11 additions & 6 deletions example/Country.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

namespace PhpAbac\Example;

class Country {
class Country
{
/** @var string **/
protected $name;
/** @var string **/
Expand All @@ -12,7 +13,8 @@ class Country {
* @param string $name
* @return \PhpAbac\Example\Country
*/
public function setName($name) {
public function setName($name)
{
$this->name = $name;

return $this;
Expand All @@ -21,15 +23,17 @@ public function setName($name) {
/**
* @return string
*/
public function getName() {
public function getName()
{
return $this->name;
}

/**
* @param string $code
* @return \PhpAbac\Example\Country
*/
public function setCode($code) {
public function setCode($code)
{
$this->code = $code;

return $this;
Expand All @@ -38,7 +42,8 @@ public function setCode($code) {
/**
* @return string
*/
public function getCode() {
public function getCode()
{
return $this->code;
}
}
}
94 changes: 57 additions & 37 deletions example/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

namespace PhpAbac\Example;

class User {
class User
{
/** @var int **/
private $id;
/** @var string **/
Expand All @@ -24,7 +25,8 @@ class User {
* @param int $id
* @return \PhpAbac\Example\User
*/
public function setId($id) {
public function setId($id)
{
$this->id = $id;

return $this;
Expand All @@ -33,15 +35,17 @@ public function setId($id) {
/**
* @return int
*/
public function getId() {
public function getId()
{
return $this->id;
}

/**
* @param string $name
* @return \PhpAbac\Example\User
*/
public function setName($name) {
public function setName($name)
{
$this->name = $name;

return $this;
Expand All @@ -50,15 +54,17 @@ public function setName($name) {
/**
* @return string
*/
public function getName() {
public function getName()
{
return $this->name;
}

/**
* @param int $age
* @return \PhpAbac\Example\User
*/
public function setAge($age) {
public function setAge($age)
{
$this->age = $age;

return $this;
Expand All @@ -67,15 +73,17 @@ public function setAge($age) {
/**
* @return int
*/
public function getAge() {
public function getAge()
{
return $this->age;
}

/**
* @param string $parentNationality
* @return \PhpAbac\Example\User
*/
public function setParentNationality($parentNationality) {
public function setParentNationality($parentNationality)
{
$this->parentNationality = $parentNationality;

return $this;
Expand All @@ -84,15 +92,17 @@ public function setParentNationality($parentNationality) {
/**
* @return bool
*/
public function getParentNationality() {
public function getParentNationality()
{
return $this->parentNationality;
}

/**
* @param \PhpAbac\Example\Visa $visa
* @return \PhpAbac\Example\User
*/
public function addVisa(Visa $visa) {
public function addVisa(Visa $visa)
{
$this->visas[$visa->getId()] = $visa;

return $this;
Expand All @@ -102,8 +112,9 @@ public function addVisa(Visa $visa) {
* @param \PhpAbac\Example\Visa $visa
* @return \PhpAbac\Example\User
*/
public function removeVisa(Visa $visa) {
if(isset($this->visas[$visa->getId()])) {
public function removeVisa(Visa $visa)
{
if (isset($this->visas[$visa->getId()])) {
unset($this->visas[$visa->getId()]);
}
return $this;
Expand All @@ -112,32 +123,36 @@ public function removeVisa(Visa $visa) {
/**
* @return array
*/
public function getVisas() {
public function getVisas()
{
return $this->visas;
}

/**
* Return a specific visa
*
* @param Visa $visa
*
* @return mixed|null
*/
public function getVisa($country_code) {
/** @var Visa $visa */
$visas = [];
foreach($this->visas as $visa) {
if ($visa->getCountry()->getCode() == $country_code)
$visas[] = $visa;
}
return $visas;
}

/**
* Return a specific visa
*
* @param Visa $visa
*
* @return mixed|null
*/
public function getVisa($country_code)
{
/** @var Visa $visa */
$visas = [];
foreach ($this->visas as $visa) {
if ($visa->getCountry()->getCode() == $country_code) {
$visas[] = $visa;
}
}
return $visas;
}

/**
* @param bool $hasDoneJapd
* @return \PhpAbac\Example\User
*/
public function setHasDoneJapd($hasDoneJapd) {
public function setHasDoneJapd($hasDoneJapd)
{
$this->hasDoneJapd = $hasDoneJapd;

return $this;
Expand All @@ -146,15 +161,17 @@ public function setHasDoneJapd($hasDoneJapd) {
/**
* @return bool
*/
public function getHasDoneJapd() {
public function getHasDoneJapd()
{
return $this->hasDoneJapd;
}

/**
* @param bool $hasDrivingLicense
* @return \PhpAbac\Example\User
*/
public function setHasDrivingLicense($hasDrivingLicense) {
public function setHasDrivingLicense($hasDrivingLicense)
{
$this->hasDrivingLicense = $hasDrivingLicense;

return $this;
Expand All @@ -163,7 +180,8 @@ public function setHasDrivingLicense($hasDrivingLicense) {
/**
* @return bool
*/
public function getHasDrivingLicense() {
public function getHasDrivingLicense()
{
return $this->hasDrivingLicense;
}

Expand All @@ -173,7 +191,8 @@ public function getHasDrivingLicense() {
*
* @param $country
*/
public function setCountry($country) {
public function setCountry($country)
{
$this->country = $country;

return $this;
Expand All @@ -182,7 +201,8 @@ public function setCountry($country) {
/**
* @return string Iso code of the user country
*/
public function getCountry() {
public function getCountry()
{
return $this->country;
}
}
}
Loading

0 comments on commit 80f4be6

Please sign in to comment.