Skip to content

Commit

Permalink
CS fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Angatar committed Dec 8, 2023
1 parent 894928d commit 4cf9522
Show file tree
Hide file tree
Showing 17 changed files with 50 additions and 49 deletions.
2 changes: 1 addition & 1 deletion src/Command/ExtractCardinalitiesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

use ApiPlatform\SchemaGenerator\CardinalitiesExtractor;
use ApiPlatform\SchemaGenerator\GoodRelationsBridge;
use ApiPlatform\SchemaGenerator\SchemaGeneratorConfiguration;
use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfGraph;
use ApiPlatform\SchemaGenerator\SchemaGeneratorConfiguration;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
Expand Down
2 changes: 1 addition & 1 deletion src/Schema/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
use ApiPlatform\SchemaGenerator\GoodRelationsBridge;
use ApiPlatform\SchemaGenerator\PhpTypeConverter;
use ApiPlatform\SchemaGenerator\Printer;
use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfGraph;
use ApiPlatform\SchemaGenerator\TwigBuilder;
use ApiPlatform\SchemaGenerator\TypesGenerator;
use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfGraph;
use Symfony\Component\Console\Logger\ConsoleLogger;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
Expand Down
2 changes: 1 addition & 1 deletion src/Schema/PropertyGenerator/PropertyGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
use ApiPlatform\SchemaGenerator\PropertyGenerator\PropertyGeneratorInterface;
use ApiPlatform\SchemaGenerator\Schema\Model\Property as SchemaProperty;
use ApiPlatform\SchemaGenerator\Schema\Model\Type\PrimitiveType;
use ApiPlatform\SchemaGenerator\Schema\TypeConverter;
use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfResource;
use ApiPlatform\SchemaGenerator\Schema\TypeConverter;
use Psr\Log\LoggerAwareTrait;

final class PropertyGenerator implements PropertyGeneratorInterface
Expand Down
21 changes: 11 additions & 10 deletions src/Schema/Rdf/RdfResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class RdfResource implements \ArrayAccess
*
* @param EasyRdfGraph|RdfGraph|null $graph
*/
public function __construct(?string $uri, $graph = null, ?EasyRdfResource $resource = null)
public function __construct(?string $uri, $graph = null, EasyRdfResource $resource = null)
{
$graph = ($graph instanceof RdfGraph) ? $graph->getEasyGraph() : $graph;
$this->resource = $resource ?? new EasyRdfResource($uri, $graph);
Expand Down Expand Up @@ -174,7 +174,7 @@ public function localId(): ?string
* Returns the label of the resource in the given language with given style
* or make use of the default label if none exists in the defined language.
*/
private function labelAsName(?string $language, ?string $namingConvention = null): ?string
private function labelAsName(?string $language, string $namingConvention = null): ?string
{
// English is the default language, forseeing graphs with several ones.
$language = $language ?: 'en';
Expand All @@ -185,18 +185,19 @@ private function labelAsName(?string $language, ?string $namingConvention = null
return $label ? u($label->getValue())->snake()->__toString() :
($defaultLabel ? u($defaultLabel->getValue())->snake()->__toString() : null);
}

// default is camel case style as with schema.org
return $label ? u($label->getValue())->camel()->__toString() :
($defaultLabel ? u($defaultLabel->getValue())->camel()->__toString() : null);
}

/**
* Gets the graph related to this resource as a Schema Generator's RdfGraph.
*/
public function getGraph(): ?RdfGraph
{
return ($this->hasGraph()) ? RdfGraph::fromEasyRdf($this->resource->getGraph()) : null;
}
/**
* Gets the graph related to this resource as a Schema Generator's RdfGraph.
*/
public function getGraph(): ?RdfGraph
{
return ($this->hasGraph()) ? RdfGraph::fromEasyRdf($this->resource->getGraph()) : null;
}

/**
* Returns true if the current RdfResource belongs to a graph.
Expand Down Expand Up @@ -405,7 +406,7 @@ public function offsetExists($offset): bool
/**
* Array Access Interface: perform get at using array syntax.
*
* @return mixed Can return all value types.
* @return mixed can return all value types
*/
#[\ReturnTypeWillChange]
public function offsetGet($offset)
Expand Down
2 changes: 1 addition & 1 deletion src/TypesGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
use ApiPlatform\SchemaGenerator\Schema\Model\Property as SchemaProperty;
use ApiPlatform\SchemaGenerator\Schema\PropertyGenerator\IdPropertyGenerator;
use ApiPlatform\SchemaGenerator\Schema\PropertyGenerator\PropertyGenerator;
use ApiPlatform\SchemaGenerator\Schema\TypeConverter;
use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfGraph;
use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfResource;
use ApiPlatform\SchemaGenerator\Schema\TypeConverter;
use ApiPlatform\SchemaGenerator\SchemaGeneratorConfigurationHolder as Config;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
use ApiPlatform\SchemaGenerator\Schema\Model\Class_ as SchemaClass;
use ApiPlatform\SchemaGenerator\Schema\Model\Property as SchemaProperty;
use ApiPlatform\SchemaGenerator\Schema\Model\Type\PrimitiveType as SchemaPrimitiveType;
use ApiPlatform\SchemaGenerator\SchemaGeneratorConfiguration;
use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfGraph;
use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfResource;
use ApiPlatform\SchemaGenerator\SchemaGeneratorConfiguration;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Definition\Processor;
use Symfony\Component\String\Inflector\EnglishInflector;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
use ApiPlatform\SchemaGenerator\PhpTypeConverter;
use ApiPlatform\SchemaGenerator\Schema\Model\Class_ as SchemaClass;
use ApiPlatform\SchemaGenerator\Schema\Model\Property;
use ApiPlatform\SchemaGenerator\TypesGenerator;
use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfGraph;
use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfResource;
use ApiPlatform\SchemaGenerator\TypesGenerator;
use Nette\PhpGenerator\Literal;
use PHPUnit\Framework\TestCase;
use Symfony\Component\String\Inflector\EnglishInflector;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
use ApiPlatform\SchemaGenerator\PhpTypeConverter;
use ApiPlatform\SchemaGenerator\Schema\Model\Class_ as SchemaClass;
use ApiPlatform\SchemaGenerator\Schema\Model\Property;
use ApiPlatform\SchemaGenerator\SchemaGeneratorConfiguration;
use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfGraph;
use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfResource;
use ApiPlatform\SchemaGenerator\SchemaGeneratorConfiguration;
use PHPUnit\Framework\TestCase;
use Symfony\Component\String\Inflector\EnglishInflector;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
use ApiPlatform\SchemaGenerator\Schema\Model\Class_ as SchemaClass;
use ApiPlatform\SchemaGenerator\Schema\Model\Property;
use ApiPlatform\SchemaGenerator\Schema\Model\Type\PrimitiveType as SchemaPrimitiveType;
use ApiPlatform\SchemaGenerator\TypesGenerator;
use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfGraph;
use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfResource;
use ApiPlatform\SchemaGenerator\TypesGenerator;
use Nette\PhpGenerator\Literal;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
use ApiPlatform\SchemaGenerator\Schema\Model\Class_ as SchemaClass;
use ApiPlatform\SchemaGenerator\Schema\Model\Property;
use ApiPlatform\SchemaGenerator\Schema\Model\Type\PrimitiveType as SchemaPrimitiveType;
use ApiPlatform\SchemaGenerator\SchemaGeneratorConfiguration;
use ApiPlatform\SchemaGenerator\TypesGenerator;
use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfGraph;
use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfResource;
use ApiPlatform\SchemaGenerator\SchemaGeneratorConfiguration;
use ApiPlatform\SchemaGenerator\TypesGenerator;
use Nette\PhpGenerator\Literal;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Definition\Processor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
use ApiPlatform\SchemaGenerator\PhpTypeConverter;
use ApiPlatform\SchemaGenerator\Schema\Model\Class_ as SchemaClass;
use ApiPlatform\SchemaGenerator\Schema\Model\Property;
use ApiPlatform\SchemaGenerator\SchemaGeneratorConfiguration;
use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfGraph;
use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfResource;
use ApiPlatform\SchemaGenerator\SchemaGeneratorConfiguration;
use Nette\PhpGenerator\Literal;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Definition\Processor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
use ApiPlatform\SchemaGenerator\Schema\Model\Class_ as SchemaClass;
use ApiPlatform\SchemaGenerator\Schema\Model\Property;
use ApiPlatform\SchemaGenerator\Schema\Model\Type\PrimitiveType as SchemaPrimitiveType;
use ApiPlatform\SchemaGenerator\SchemaGeneratorConfiguration;
use ApiPlatform\SchemaGenerator\TypesGenerator;
use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfGraph;
use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfResource;
use ApiPlatform\SchemaGenerator\SchemaGeneratorConfiguration;
use ApiPlatform\SchemaGenerator\TypesGenerator;
use Nette\PhpGenerator\Literal;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Definition\Processor;
Expand Down
2 changes: 1 addition & 1 deletion tests/ClassMutator/ClassParentMutatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
use ApiPlatform\SchemaGenerator\Model\Use_;
use ApiPlatform\SchemaGenerator\PhpTypeConverter;
use ApiPlatform\SchemaGenerator\Schema\Model\Class_ as SchemaClass;
use ApiPlatform\SchemaGenerator\SchemaGeneratorConfiguration;
use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfGraph;
use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfResource;
use ApiPlatform\SchemaGenerator\SchemaGeneratorConfiguration;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;
use Prophecy\Prophecy\ObjectProphecy;
Expand Down
4 changes: 2 additions & 2 deletions tests/ClassMutator/ClassPropertiesAppenderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
use ApiPlatform\SchemaGenerator\Schema\Model\Property;
use ApiPlatform\SchemaGenerator\Schema\Model\Type\PrimitiveType as SchemaPrimitiveType;
use ApiPlatform\SchemaGenerator\Schema\PropertyGenerator\PropertyGenerator as SchemaPropertyGenerator;
use ApiPlatform\SchemaGenerator\Schema\TypeConverter;
use ApiPlatform\SchemaGenerator\SchemaGeneratorConfiguration;
use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfGraph;
use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfResource;
use ApiPlatform\SchemaGenerator\Schema\TypeConverter;
use ApiPlatform\SchemaGenerator\SchemaGeneratorConfiguration;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;
use Prophecy\Prophecy\ObjectProphecy;
Expand Down
2 changes: 1 addition & 1 deletion tests/Schema/Model/ClassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
use ApiPlatform\SchemaGenerator\Model\Use_;
use ApiPlatform\SchemaGenerator\Schema\Model\Class_ as SchemaClass;
use ApiPlatform\SchemaGenerator\Schema\Model\Property as SchemaProperty;
use ApiPlatform\SchemaGenerator\SchemaGeneratorConfiguration;
use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfGraph;
use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfResource;
use ApiPlatform\SchemaGenerator\SchemaGeneratorConfiguration;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Definition\Processor;
use Symfony\Component\String\Inflector\EnglishInflector;
Expand Down
42 changes: 21 additions & 21 deletions tests/Schema/Rdf/RdfResourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,18 +188,18 @@ public function testUpdateResourceName(): void
}
}

public function testResetResourceNamingBehavior(): void
{
foreach (self::$testGroups as $testValues) {
$resource = $this->createConfiguredRdfResource($this->getAllTypesRdfResourceConfig($testValues), $testValues['resourceUri'], $testValues['graph']);
public function testResetResourceNamingBehavior(): void
{
foreach (self::$testGroups as $testValues) {
$resource = $this->createConfiguredRdfResource($this->getAllTypesRdfResourceConfig($testValues), $testValues['resourceUri'], $testValues['graph']);

$resource->resetResourceNamingBehavior();
$this->assertNull($resource->getResourceName());
$resource->resetResourceNamingBehavior();
$this->assertNull($resource->getResourceName());

$resource->updateResourceName();
$this->assertEquals($testValues['id'], $resource->localName());
}
}
$resource->updateResourceName();
$this->assertEquals($testValues['id'], $resource->localName());
}
}

public function testLocalId(): void
{
Expand All @@ -220,17 +220,17 @@ public function testLabelAsName(): void
}
}

public function testGetGraph(): void
{
foreach (self::$testGroups as $testValues) {
$resource = new RdfResource($testValues['resourceUri']);
$this->assertNull($resource->getGraph());
$resource = new RdfResource($testValues['resourceUri'], $testValues['graph']);
$this->assertInstanceOf(RdfGraph::class, $resource->getGraph());
$resource = new RdfResource($testValues['resourceUri'], new EasyRdfGraph($testValues['graphUri']));
$this->assertInstanceOf(RdfGraph::class, $resource->getGraph());
}
}
public function testGetGraph(): void
{
foreach (self::$testGroups as $testValues) {
$resource = new RdfResource($testValues['resourceUri']);
$this->assertNull($resource->getGraph());
$resource = new RdfResource($testValues['resourceUri'], $testValues['graph']);
$this->assertInstanceOf(RdfGraph::class, $resource->getGraph());
$resource = new RdfResource($testValues['resourceUri'], new EasyRdfGraph($testValues['graphUri']));
$this->assertInstanceOf(RdfGraph::class, $resource->getGraph());
}
}

public function testAll(): void
{
Expand Down
2 changes: 1 addition & 1 deletion tests/TypesGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
use ApiPlatform\SchemaGenerator\GoodRelationsBridge;
use ApiPlatform\SchemaGenerator\PhpTypeConverter;
use ApiPlatform\SchemaGenerator\Printer;
use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfGraph;
use ApiPlatform\SchemaGenerator\SchemaGeneratorConfiguration;
use ApiPlatform\SchemaGenerator\TypesGenerator;
use ApiPlatform\SchemaGenerator\Schema\Rdf\RdfGraph;
use EasyRdf\RdfNamespace;
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;
Expand Down

0 comments on commit 4cf9522

Please sign in to comment.