Commit 34aca270 authored by Brian Hatchet's avatar Brian Hatchet :speech_balloon:

Linting

1 merge request!307WIP: Epic/permissions open channels
Pipeline #79271154 passed with stages
in 11 minutes and 10 seconds
<?php
namespace Minds\Common;
use ReflectionClass;
use ReflectionClass;
abstract class ChannelMode
{
......@@ -16,6 +17,6 @@ abstract class ChannelMode
final public static function isValid($value) : bool
{
return in_array($value, static::toArray());
return in_array($value, static::toArray(), true);
}
}
......@@ -4,12 +4,13 @@ namespace Minds\Core\Permissions\Entities;
use Minds\Traits\MagicAttributes;
/**
/**
* Class Permissions
* @method Permissions setAllowComments(bool $allowComments)
* @method bool getAllowComments();
*/
class EntityPermissions {
class EntityPermissions
{
use MagicAttributes;
/** @var bool AllowComments */
......
......@@ -30,10 +30,10 @@ class Manager
$this->save = $save ?: new Save(); //Mockable, else instantiate a new one on save.
}
/**
/**
* Save permissions for an entity and propegate it to linked objects
* @param mixed $entity a minds entity that implements the save function
* @param Permissions $permissions the flag to apply to the entity
* @param Permissions $permissions the flag to apply to the entity
*/
public function save($entity, EntityPermissions $permissions)
{
......
......@@ -25,7 +25,7 @@ class Manager
* Permissions contains the user's role per entity, channel and group
* @param array $opts
* - user_guid: long, the user's guid for calculating permissions
* - guids: array long, the list of entities to permit
* - guids: array long, the list of entities to permit
* @return Permissions A map of channels, groups and entities with the user's role for each
*/
public function getList(array $opts = [])
......
......@@ -33,7 +33,8 @@ class Permissions implements \JsonSerializable
/** @var EntitiesBuilder */
private $entitiesBuilder;
public function setUser(User $user) {
public function setUser(User $user)
{
throw new ImmutableException('User can only be set in the constructor');
}
......
......@@ -5,6 +5,7 @@ namespace Minds\Core\Permissions;
use Minds\Core\Di\Provider as DiProvider;
use Minds\Core\Permissions\Entities;
use Minds\Core\Permissions\Manager;
class Provider extends DiProvider
{
public function register()
......
......@@ -60,5 +60,5 @@ class Roles extends Rbac
$this->addRole(new GroupNonSubscriberRole());
$this->addRole(new GroupOwnerRole());
$this->addRole(new GroupSubscriberRole());
}
}
}
......@@ -58,7 +58,8 @@ class PermissionsSpec extends ObjectBehavior
$this->shouldHaveType(Permissions::class);
}
public function it_should_except_when_setting_a_user() {
public function it_should_except_when_setting_a_user()
{
$this->shouldThrow(new ImmutableException('User can only be set in the constructor'))
->duringSetUser($this->user);
}
......
......@@ -53,18 +53,21 @@ class UserSpec extends ObjectBehavior
$this->isOnchainBooster()->shouldReturn(false);
}
function it_should_have_a_default_mode_of_open() {
public function it_should_have_a_default_mode_of_open()
{
$this->getMode()->shouldEqual(ChannelMode::OPEN);
}
function it_should_assign_channel_modes() {
$this->setMode(ChannelMode::CLOSED);
public function it_should_assign_channel_modes()
{
$this->setMode(ChannelMode::CLOSED);
$this->getMode()->shouldEqual(ChannelMode::CLOSED);
$this->setMode(ChannelMode::MODERATED);
$this->setMode(ChannelMode::MODERATED);
$this->getMode()->shouldEqual(ChannelMode::MODERATED);
}
function it_should_export_values() {
public function it_should_export_values()
{
$export = $this->export()->getWrappedObject();
expect($export['mode'])->shouldEqual(ChannelMode::OPEN);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment