diff --git a/src/Statement/Statement.php b/src/Statement/Statement.php index 896d6262..06183b85 100644 --- a/src/Statement/Statement.php +++ b/src/Statement/Statement.php @@ -51,6 +51,17 @@ public function __construct( Claim $claim, ReferenceList $references = null ) { $this->references = $references === null ? new ReferenceList() : $references; } + /** + * @since 2.2 + * + * @param Snak $mainSnak + * + * @return Statement + */ + public static function newFromMainSnak( Snak $mainSnak ) { + return new self( new Claim( $mainSnak ) ); + } + /** * Returns the references attached to this statement. * diff --git a/tests/unit/Statement/StatementTest.php b/tests/unit/Statement/StatementTest.php index 0df7ed54..8e1d0f22 100644 --- a/tests/unit/Statement/StatementTest.php +++ b/tests/unit/Statement/StatementTest.php @@ -367,4 +367,11 @@ public function testGetClaim() { $this->assertSame( $qualifiers, $claim->getQualifiers() ); } + public function testNewFromMainSnak() { + $snak = new PropertyNoValueSnak( new PropertyId( 'P42' ) ); + + $statement = Statement::newFromMainSnak( $snak ); + $this->assertEquals( $snak, $statement->getMainSnak() ); + } + }